babylon.d.ts 1.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Set of assets to keep when moving a scene into an asset container.
  7. */
  8. class KeepAssets {
  9. /**
  10. * Cameras to keep.
  11. */
  12. cameras: Camera[];
  13. /**
  14. * Lights to keep.
  15. */
  16. lights: Light[];
  17. /**
  18. * Meshes to keep.
  19. */
  20. meshes: AbstractMesh[];
  21. /**
  22. * Skeletons to keep.
  23. */
  24. skeletons: Skeleton[];
  25. /**
  26. * ParticleSystems to keep.
  27. */
  28. particleSystems: IParticleSystem[];
  29. /**
  30. * Animations to keep.
  31. */
  32. animations: Animation[];
  33. /**
  34. * AnimationGroups to keep.
  35. */
  36. animationGroups: AnimationGroup[];
  37. /**
  38. * MultiMaterials to keep.
  39. */
  40. multiMaterials: MultiMaterial[];
  41. /**
  42. * Materials to keep.
  43. */
  44. materials: Material[];
  45. /**
  46. * MorphTargetManagers to keep.
  47. */
  48. morphTargetManagers: MorphTargetManager[];
  49. /**
  50. * Geometries to keep.
  51. */
  52. geometries: Geometry[];
  53. /**
  54. * TransformNodes to keep.
  55. */
  56. transformNodes: TransformNode[];
  57. /**
  58. * LensFlareSystems to keep.
  59. */
  60. lensFlareSystems: LensFlareSystem[];
  61. /**
  62. * ShadowGenerators to keep.
  63. */
  64. shadowGenerators: ShadowGenerator[];
  65. /**
  66. * ActionManagers to keep.
  67. */
  68. actionManagers: ActionManager[];
  69. /**
  70. * Sounds to keep.
  71. */
  72. sounds: Sound[];
  73. /**
  74. * Textures to keep.
  75. */
  76. textures: Texture[];
  77. /**
  78. * Effect layers to keep.
  79. */
  80. effectLayers: EffectLayer[];
  81. }
  82. /**
  83. * Container with a set of assets that can be added or removed from a scene.
  84. */
  85. class AssetContainer {
  86. /**
  87. * The scene the AssetContainer belongs to.
  88. */
  89. scene: Scene;
  90. /**
  91. * Cameras populated in the container.
  92. */
  93. cameras: Camera[];
  94. /**
  95. * Lights populated in the container.
  96. */
  97. lights: Light[];
  98. /**
  99. * Meshes populated in the container.
  100. */
  101. meshes: AbstractMesh[];
  102. /**
  103. * Skeletons populated in the container.
  104. */
  105. skeletons: Skeleton[];
  106. /**
  107. * ParticleSystems populated in the container.
  108. */
  109. particleSystems: IParticleSystem[];
  110. /**
  111. * Animations populated in the container.
  112. */
  113. animations: Animation[];
  114. /**
  115. * AnimationGroups populated in the container.
  116. */
  117. animationGroups: AnimationGroup[];
  118. /**
  119. * MultiMaterials populated in the container.
  120. */
  121. multiMaterials: MultiMaterial[];
  122. /**
  123. * Materials populated in the container.
  124. */
  125. materials: Material[];
  126. /**
  127. * MorphTargetManagers populated in the container.
  128. */
  129. morphTargetManagers: MorphTargetManager[];
  130. /**
  131. * Geometries populated in the container.
  132. */
  133. geometries: Geometry[];
  134. /**
  135. * TransformNodes populated in the container.
  136. */
  137. transformNodes: TransformNode[];
  138. /**
  139. * LensFlareSystems populated in the container.
  140. */
  141. lensFlareSystems: LensFlareSystem[];
  142. /**
  143. * ShadowGenerators populated in the container.
  144. */
  145. shadowGenerators: ShadowGenerator[];
  146. /**
  147. * ActionManagers populated in the container.
  148. */
  149. actionManagers: ActionManager[];
  150. /**
  151. * Sounds populated in the container.
  152. */
  153. sounds: Sound[];
  154. /**
  155. * Textures populated in the container.
  156. */
  157. textures: Texture[];
  158. /**
  159. * Effect layers populated in the container.
  160. */
  161. effectLayers: EffectLayer[];
  162. /**
  163. * Instantiates an AssetContainer.
  164. * @param scene The scene the AssetContainer belongs to.
  165. */
  166. constructor(scene: Scene);
  167. /**
  168. * Adds all the assets from the container to the scene.
  169. */
  170. addAllToScene(): void;
  171. /**
  172. * Removes all the assets in the container from the scene
  173. */
  174. removeAllFromScene(): void;
  175. private _moveAssets<T>(sourceAssets, targetAssets, keepAssets);
  176. /**
  177. * Removes all the assets contained in the scene and adds them to the container.
  178. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  179. */
  180. moveAllFromScene(keepAssets?: KeepAssets): void;
  181. }
  182. }
  183. interface Window {
  184. mozIndexedDB: IDBFactory;
  185. webkitIndexedDB: IDBFactory;
  186. msIndexedDB: IDBFactory;
  187. webkitURL: typeof URL;
  188. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  189. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  190. WebGLRenderingContext: WebGLRenderingContext;
  191. MSGesture: MSGesture;
  192. CANNON: any;
  193. AudioContext: AudioContext;
  194. webkitAudioContext: AudioContext;
  195. PointerEvent: any;
  196. Math: Math;
  197. Uint8Array: Uint8ArrayConstructor;
  198. Float32Array: Float32ArrayConstructor;
  199. mozURL: typeof URL;
  200. msURL: typeof URL;
  201. VRFrameData: any;
  202. DracoDecoderModule: any;
  203. }
  204. interface WebGLRenderingContext {
  205. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  206. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  207. vertexAttribDivisor(index: number, divisor: number): void;
  208. createVertexArray(): any;
  209. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  210. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  211. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  212. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  213. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  214. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  215. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  216. createQuery(): WebGLQuery;
  217. deleteQuery(query: WebGLQuery): void;
  218. beginQuery(target: number, query: WebGLQuery): void;
  219. endQuery(target: number): void;
  220. getQueryParameter(query: WebGLQuery, pname: number): any;
  221. getQuery(target: number, pname: number): any;
  222. MAX_SAMPLES: number;
  223. RGBA8: number;
  224. READ_FRAMEBUFFER: number;
  225. DRAW_FRAMEBUFFER: number;
  226. UNIFORM_BUFFER: number;
  227. HALF_FLOAT_OES: number;
  228. RGBA16F: number;
  229. RGBA32F: number;
  230. R32F: number;
  231. RG32F: number;
  232. RGB32F: number;
  233. RED: number;
  234. RG: number;
  235. UNSIGNED_INT_24_8: number;
  236. DEPTH24_STENCIL8: number;
  237. drawBuffers(buffers: number[]): void;
  238. readBuffer(src: number): void;
  239. readonly COLOR_ATTACHMENT0: number;
  240. readonly COLOR_ATTACHMENT1: number;
  241. readonly COLOR_ATTACHMENT2: number;
  242. readonly COLOR_ATTACHMENT3: number;
  243. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  244. ANY_SAMPLES_PASSED: number;
  245. QUERY_RESULT_AVAILABLE: number;
  246. QUERY_RESULT: number;
  247. }
  248. interface Document {
  249. mozCancelFullScreen(): void;
  250. msCancelFullScreen(): void;
  251. mozFullScreen: boolean;
  252. msIsFullScreen: boolean;
  253. fullscreen: boolean;
  254. mozPointerLockElement: HTMLElement;
  255. msPointerLockElement: HTMLElement;
  256. webkitPointerLockElement: HTMLElement;
  257. }
  258. interface HTMLCanvasElement {
  259. msRequestPointerLock?(): void;
  260. mozRequestPointerLock?(): void;
  261. webkitRequestPointerLock?(): void;
  262. }
  263. interface CanvasRenderingContext2D {
  264. msImageSmoothingEnabled: boolean;
  265. }
  266. interface WebGLBuffer {
  267. references: number;
  268. capacity: number;
  269. is32Bits: boolean;
  270. }
  271. interface WebGLProgram {
  272. transformFeedback?: WebGLTransformFeedback | null;
  273. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  274. }
  275. interface MouseEvent {
  276. mozMovementX: number;
  277. mozMovementY: number;
  278. webkitMovementX: number;
  279. webkitMovementY: number;
  280. msMovementX: number;
  281. msMovementY: number;
  282. }
  283. interface Navigator {
  284. mozGetVRDevices: (any: any) => any;
  285. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  286. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  287. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  288. webkitGetGamepads(): Gamepad[];
  289. msGetGamepads(): Gamepad[];
  290. webkitGamepads(): Gamepad[];
  291. }
  292. interface HTMLVideoElement {
  293. mozSrcObject: any;
  294. }
  295. interface Screen {
  296. orientation: string;
  297. mozOrientation: string;
  298. }
  299. interface Math {
  300. fround(x: number): number;
  301. imul(a: number, b: number): number;
  302. }
  303. interface EXT_disjoint_timer_query {
  304. QUERY_COUNTER_BITS_EXT: number;
  305. TIME_ELAPSED_EXT: number;
  306. TIMESTAMP_EXT: number;
  307. GPU_DISJOINT_EXT: number;
  308. QUERY_RESULT_EXT: number;
  309. QUERY_RESULT_AVAILABLE_EXT: number;
  310. queryCounterEXT(query: WebGLQuery, target: number): void;
  311. createQueryEXT(): WebGLQuery;
  312. beginQueryEXT(target: number, query: WebGLQuery): void;
  313. endQueryEXT(target: number): void;
  314. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  315. deleteQueryEXT(query: WebGLQuery): void;
  316. }
  317. interface WebGLUniformLocation {
  318. _currentState: any;
  319. }
  320. declare module BABYLON {
  321. /**
  322. * Node is the basic class for all scene objects (Mesh, Light Camera).
  323. */
  324. class Node {
  325. /**
  326. * Gets or sets the name of the node
  327. */
  328. name: string;
  329. /**
  330. * Gets or sets the id of the node
  331. */
  332. id: string;
  333. /**
  334. * Gets or sets the unique id of the node
  335. */
  336. uniqueId: number;
  337. /**
  338. * Gets or sets a string used to store user defined state for the node
  339. */
  340. state: string;
  341. /**
  342. * Gets or sets an object used to store user defined information for the node
  343. */
  344. metadata: any;
  345. /**
  346. * Gets or sets a boolean used to define if the node must be serialized
  347. */
  348. doNotSerialize: boolean;
  349. /** @hidden */
  350. _isDisposed: boolean;
  351. /**
  352. * Gets a list of Animations associated with the node
  353. */
  354. animations: Animation[];
  355. private _ranges;
  356. /**
  357. * Callback raised when the node is ready to be used
  358. */
  359. onReady: (node: Node) => void;
  360. private _isEnabled;
  361. private _isReady;
  362. /** @hidden */
  363. _currentRenderId: number;
  364. private _parentRenderId;
  365. protected _childRenderId: number;
  366. /** @hidden */
  367. _waitingParentId: Nullable<string>;
  368. private _scene;
  369. /** @hidden */
  370. _cache: any;
  371. private _parentNode;
  372. private _children;
  373. /**
  374. * Gets a boolean indicating if the node has been disposed
  375. * @returns true if the node was disposed
  376. */
  377. isDisposed(): boolean;
  378. /**
  379. * Gets or sets the parent of the node
  380. */
  381. parent: Nullable<Node>;
  382. private _animationPropertiesOverride;
  383. /**
  384. * Gets or sets the animation properties override
  385. */
  386. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  387. /**
  388. * Gets a string idenfifying the name of the class
  389. * @returns "Node" string
  390. */
  391. getClassName(): string;
  392. /**
  393. * An event triggered when the mesh is disposed
  394. */
  395. onDisposeObservable: Observable<Node>;
  396. private _onDisposeObserver;
  397. /**
  398. * Sets a callback that will be raised when the node will be disposed
  399. */
  400. onDispose: () => void;
  401. /**
  402. * Creates a new Node
  403. * @param {string} name - the name and id to be given to this node
  404. * @param {BABYLON.Scene} the scene this node will be added to
  405. */
  406. constructor(name: string, scene?: Nullable<Scene>);
  407. /**
  408. * Gets the scene of the node
  409. * @returns a {BABYLON.Scene}
  410. */
  411. getScene(): Scene;
  412. /**
  413. * Gets the engine of the node
  414. * @returns a {BABYLON.Engine}
  415. */
  416. getEngine(): Engine;
  417. private _behaviors;
  418. /**
  419. * Attach a behavior to the node
  420. * @see http://doc.babylonjs.com/features/behaviour
  421. * @param behavior defines the behavior to attach
  422. * @returns the current Node
  423. */
  424. addBehavior(behavior: Behavior<Node>): Node;
  425. /**
  426. * Remove an attached behavior
  427. * @see http://doc.babylonjs.com/features/behaviour
  428. * @param behavior defines the behavior to attach
  429. * @returns the current Node
  430. */
  431. removeBehavior(behavior: Behavior<Node>): Node;
  432. /**
  433. * Gets the list of attached behaviors
  434. * @see http://doc.babylonjs.com/features/behaviour
  435. */
  436. readonly behaviors: Behavior<Node>[];
  437. /**
  438. * Gets an attached behavior by name
  439. * @param name defines the name of the behavior to look for
  440. * @see http://doc.babylonjs.com/features/behaviour
  441. * @returns null if behavior was not found else the requested behavior
  442. */
  443. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  444. /**
  445. * Returns the world matrix of the node
  446. * @returns a matrix containing the node's world matrix
  447. */
  448. getWorldMatrix(): Matrix;
  449. /** @hidden */
  450. _getWorldMatrixDeterminant(): number;
  451. /** @hidden */
  452. _initCache(): void;
  453. /** @hidden */
  454. updateCache(force?: boolean): void;
  455. /** @hidden */
  456. _updateCache(ignoreParentClass?: boolean): void;
  457. /** @hidden */
  458. _isSynchronized(): boolean;
  459. /** @hidden */
  460. _markSyncedWithParent(): void;
  461. /** @hidden */
  462. isSynchronizedWithParent(): boolean;
  463. /** @hidden */
  464. isSynchronized(updateCache?: boolean): boolean;
  465. /** @hidden */
  466. hasNewParent(update?: boolean): boolean;
  467. /**
  468. * Is this node ready to be used/rendered
  469. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  470. * @return true if the node is ready
  471. */
  472. isReady(completeCheck?: boolean): boolean;
  473. /**
  474. * Is this node enabled?
  475. * 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
  476. * @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
  477. * @return whether this node (and its parent) is enabled
  478. */
  479. isEnabled(checkAncestors?: boolean): boolean;
  480. /**
  481. * Set the enabled state of this node
  482. * @param value defines the new enabled state
  483. */
  484. setEnabled(value: boolean): void;
  485. /**
  486. * Is this node a descendant of the given node?
  487. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  488. * @param ancestor defines the parent node to inspect
  489. * @returns a boolean indicating if this node is a descendant of the given node
  490. */
  491. isDescendantOf(ancestor: Node): boolean;
  492. /** @hidden */
  493. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  494. /**
  495. * Will return all nodes that have this node as ascendant
  496. * @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
  497. * @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
  498. * @return all children nodes of all types
  499. */
  500. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  501. /**
  502. * Get all child-meshes of this node
  503. * @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
  504. * @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
  505. * @returns an array of {BABYLON.AbstractMesh}
  506. */
  507. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  508. /**
  509. * Get all child-transformNodes of this node
  510. * @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
  511. * @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
  512. * @returns an array of {BABYLON.TransformNode}
  513. */
  514. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  515. /**
  516. * Get all direct children of this node
  517. * @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
  518. * @returns an array of {BABYLON.Node}
  519. */
  520. getChildren(predicate?: (node: Node) => boolean): Node[];
  521. /** @hidden */
  522. _setReady(state: boolean): void;
  523. /**
  524. * Get an animation by name
  525. * @param name defines the name of the animation to look for
  526. * @returns null if not found else the requested animation
  527. */
  528. getAnimationByName(name: string): Nullable<Animation>;
  529. /**
  530. * Creates an animation range for this node
  531. * @param name defines the name of the range
  532. * @param from defines the starting key
  533. * @param to defines the end key
  534. */
  535. createAnimationRange(name: string, from: number, to: number): void;
  536. /**
  537. * Delete a specific animation range
  538. * @param name defines the name of the range to delete
  539. * @param deleteFrames defines if animation frames from the range must be deleted as well
  540. */
  541. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  542. /**
  543. * Get an animation range by name
  544. * @param name defines the name of the animation range to look for
  545. * @returns null if not found else the requested animation range
  546. */
  547. getAnimationRange(name: string): Nullable<AnimationRange>;
  548. /**
  549. * Will start the animation sequence
  550. * @param name defines the range frames for animation sequence
  551. * @param loop defines if the animation should loop (false by default)
  552. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  553. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  554. * @returns the object created for this animation. If range does not exist, it will return null
  555. */
  556. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  557. /**
  558. * Serialize animation ranges into a JSON compatible object
  559. * @returns serialization object
  560. */
  561. serializeAnimationRanges(): any;
  562. /**
  563. * Computes the world matrix of the node
  564. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  565. * @returns the world matrix
  566. */
  567. computeWorldMatrix(force?: boolean): Matrix;
  568. /**
  569. * Releases resources associated with this node.
  570. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  571. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  572. */
  573. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  574. /**
  575. * Parse animation range data from a serialization object and store them into a given node
  576. * @param node defines where to store the animation ranges
  577. * @param parsedNode defines the serialization object to read data from
  578. * @param scene defines the hosting scene
  579. */
  580. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  581. }
  582. }
  583. declare module BABYLON {
  584. /**
  585. * Define an interface for all classes that will hold resources
  586. */
  587. interface IDisposable {
  588. /**
  589. * Releases all held resources
  590. */
  591. dispose(): void;
  592. }
  593. /**
  594. * Interface used to let developers provide their own mesh selection mechanism
  595. */
  596. interface IActiveMeshCandidateProvider {
  597. /**
  598. * Return the list of active meshes
  599. * @param scene defines the current scene
  600. * @returns the list of active meshes
  601. */
  602. getMeshes(scene: Scene): AbstractMesh[];
  603. /**
  604. * Indicates if the meshes have been checked to make sure they are isEnabled()
  605. */
  606. readonly checksIsEnabled: boolean;
  607. }
  608. /**
  609. * This class is used by the onRenderingGroupObservable
  610. */
  611. class RenderingGroupInfo {
  612. /**
  613. * The Scene that being rendered
  614. */
  615. scene: Scene;
  616. /**
  617. * The camera currently used for the rendering pass
  618. */
  619. camera: Nullable<Camera>;
  620. /**
  621. * The ID of the renderingGroup being processed
  622. */
  623. renderingGroupId: number;
  624. /**
  625. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  626. */
  627. renderStage: number;
  628. /**
  629. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  630. * This stage will be fired no matter what
  631. */
  632. static STAGE_PRECLEAR: number;
  633. /**
  634. * Called before opaque object are rendered.
  635. * This stage will be fired only if there's 3D Opaque content to render
  636. */
  637. static STAGE_PREOPAQUE: number;
  638. /**
  639. * Called after the opaque objects are rendered and before the transparent ones
  640. * This stage will be fired only if there's 3D transparent content to render
  641. */
  642. static STAGE_PRETRANSPARENT: number;
  643. /**
  644. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  645. * This stage will be fired no matter what
  646. */
  647. static STAGE_POSTTRANSPARENT: number;
  648. }
  649. /**
  650. * Represents a scene to be rendered by the engine.
  651. * @see http://doc.babylonjs.com/features/scene
  652. */
  653. class Scene implements IAnimatable {
  654. private static _FOGMODE_NONE;
  655. private static _FOGMODE_EXP;
  656. private static _FOGMODE_EXP2;
  657. private static _FOGMODE_LINEAR;
  658. private static _uniqueIdCounter;
  659. /**
  660. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  661. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  662. */
  663. static MinDeltaTime: number;
  664. /**
  665. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  666. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  667. */
  668. static MaxDeltaTime: number;
  669. /** The fog is deactivated */
  670. static readonly FOGMODE_NONE: number;
  671. /** The fog density is following an exponential function */
  672. static readonly FOGMODE_EXP: number;
  673. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  674. static readonly FOGMODE_EXP2: number;
  675. /** The fog density is following a linear function. */
  676. static readonly FOGMODE_LINEAR: number;
  677. /**
  678. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  679. */
  680. autoClear: boolean;
  681. /**
  682. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  683. */
  684. autoClearDepthAndStencil: boolean;
  685. /**
  686. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  687. */
  688. clearColor: Color4;
  689. /**
  690. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  691. */
  692. ambientColor: Color3;
  693. /** @hidden */
  694. _environmentBRDFTexture: BaseTexture;
  695. /** @hidden */
  696. protected _environmentTexture: BaseTexture;
  697. /**
  698. * Texture used in all pbr material as the reflection texture.
  699. * As in the majority of the scene they are the same (exception for multi room and so on),
  700. * this is easier to reference from here than from all the materials.
  701. */
  702. /**
  703. * Texture used in all pbr material as the reflection texture.
  704. * As in the majority of the scene they are the same (exception for multi room and so on),
  705. * this is easier to set here than in all the materials.
  706. */
  707. environmentTexture: BaseTexture;
  708. /** @hidden */
  709. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  710. /**
  711. * Default image processing configuration used either in the rendering
  712. * Forward main pass or through the imageProcessingPostProcess if present.
  713. * As in the majority of the scene they are the same (exception for multi camera),
  714. * this is easier to reference from here than from all the materials and post process.
  715. *
  716. * No setter as we it is a shared configuration, you can set the values instead.
  717. */
  718. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  719. private _forceWireframe;
  720. /**
  721. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  722. */
  723. forceWireframe: boolean;
  724. private _forcePointsCloud;
  725. /**
  726. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  727. */
  728. forcePointsCloud: boolean;
  729. /**
  730. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  731. */
  732. forceShowBoundingBoxes: boolean;
  733. /**
  734. * Gets or sets the active clipplane
  735. */
  736. clipPlane: Nullable<Plane>;
  737. /**
  738. * Gets or sets a boolean indicating if animations are enabled
  739. */
  740. animationsEnabled: boolean;
  741. private _animationPropertiesOverride;
  742. /**
  743. * Gets or sets the animation properties override
  744. */
  745. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  746. /**
  747. * Gets or sets a boolean indicating if a constant deltatime has to be used
  748. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  749. */
  750. useConstantAnimationDeltaTime: boolean;
  751. /**
  752. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  753. * Please note that it requires to run a ray cast through the scene on every frame
  754. */
  755. constantlyUpdateMeshUnderPointer: boolean;
  756. /**
  757. * Defines the HTML cursor to use when hovering over interactive elements
  758. */
  759. hoverCursor: string;
  760. /**
  761. * Defines the HTML default cursor to use (empty by default)
  762. */
  763. defaultCursor: string;
  764. /**
  765. * This is used to call preventDefault() on pointer down
  766. * in order to block unwanted artifacts like system double clicks
  767. */
  768. preventDefaultOnPointerDown: boolean;
  769. /**
  770. * Gets or sets user defined metadata
  771. */
  772. metadata: any;
  773. /**
  774. * Gets the name of the plugin used to load this scene (null by default)
  775. */
  776. loadingPluginName: string;
  777. /**
  778. * Use this array to add regular expressions used to disable offline support for specific urls
  779. */
  780. disableOfflineSupportExceptionRules: RegExp[];
  781. private _spritePredicate;
  782. /**
  783. * An event triggered when the scene is disposed.
  784. */
  785. onDisposeObservable: Observable<Scene>;
  786. private _onDisposeObserver;
  787. /** Sets a function to be executed when this scene is disposed. */
  788. onDispose: () => void;
  789. /**
  790. * An event triggered before rendering the scene (right after animations and physics)
  791. */
  792. onBeforeRenderObservable: Observable<Scene>;
  793. private _onBeforeRenderObserver;
  794. /** Sets a function to be executed before rendering this scene */
  795. beforeRender: Nullable<() => void>;
  796. /**
  797. * An event triggered after rendering the scene
  798. */
  799. onAfterRenderObservable: Observable<Scene>;
  800. private _onAfterRenderObserver;
  801. /** Sets a function to be executed after rendering this scene */
  802. afterRender: Nullable<() => void>;
  803. /**
  804. * An event triggered before animating the scene
  805. */
  806. onBeforeAnimationsObservable: Observable<Scene>;
  807. /**
  808. * An event triggered after animations processing
  809. */
  810. onAfterAnimationsObservable: Observable<Scene>;
  811. /**
  812. * An event triggered before draw calls are ready to be sent
  813. */
  814. onBeforeDrawPhaseObservable: Observable<Scene>;
  815. /**
  816. * An event triggered after draw calls have been sent
  817. */
  818. onAfterDrawPhaseObservable: Observable<Scene>;
  819. /**
  820. * An event triggered when physic simulation is about to be run
  821. */
  822. onBeforePhysicsObservable: Observable<Scene>;
  823. /**
  824. * An event triggered when physic simulation has been done
  825. */
  826. onAfterPhysicsObservable: Observable<Scene>;
  827. /**
  828. * An event triggered when the scene is ready
  829. */
  830. onReadyObservable: Observable<Scene>;
  831. /**
  832. * An event triggered before rendering a camera
  833. */
  834. onBeforeCameraRenderObservable: Observable<Camera>;
  835. private _onBeforeCameraRenderObserver;
  836. /** Sets a function to be executed before rendering a camera*/
  837. beforeCameraRender: () => void;
  838. /**
  839. * An event triggered after rendering a camera
  840. */
  841. onAfterCameraRenderObservable: Observable<Camera>;
  842. private _onAfterCameraRenderObserver;
  843. /** Sets a function to be executed after rendering a camera*/
  844. afterCameraRender: () => void;
  845. /**
  846. * An event triggered when active meshes evaluation is about to start
  847. */
  848. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  849. /**
  850. * An event triggered when active meshes evaluation is done
  851. */
  852. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  853. /**
  854. * An event triggered when particles rendering is about to start
  855. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  856. */
  857. onBeforeParticlesRenderingObservable: Observable<Scene>;
  858. /**
  859. * An event triggered when particles rendering is done
  860. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  861. */
  862. onAfterParticlesRenderingObservable: Observable<Scene>;
  863. /**
  864. * An event triggered when sprites rendering is about to start
  865. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  866. */
  867. onBeforeSpritesRenderingObservable: Observable<Scene>;
  868. /**
  869. * An event triggered when sprites rendering is done
  870. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  871. */
  872. onAfterSpritesRenderingObservable: Observable<Scene>;
  873. /**
  874. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  875. */
  876. onDataLoadedObservable: Observable<Scene>;
  877. /**
  878. * An event triggered when a camera is created
  879. */
  880. onNewCameraAddedObservable: Observable<Camera>;
  881. /**
  882. * An event triggered when a camera is removed
  883. */
  884. onCameraRemovedObservable: Observable<Camera>;
  885. /**
  886. * An event triggered when a light is created
  887. */
  888. onNewLightAddedObservable: Observable<Light>;
  889. /**
  890. * An event triggered when a light is removed
  891. */
  892. onLightRemovedObservable: Observable<Light>;
  893. /**
  894. * An event triggered when a geometry is created
  895. */
  896. onNewGeometryAddedObservable: Observable<Geometry>;
  897. /**
  898. * An event triggered when a geometry is removed
  899. */
  900. onGeometryRemovedObservable: Observable<Geometry>;
  901. /**
  902. * An event triggered when a transform node is created
  903. */
  904. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  905. /**
  906. * An event triggered when a transform node is removed
  907. */
  908. onTransformNodeRemovedObservable: Observable<TransformNode>;
  909. /**
  910. * An event triggered when a mesh is created
  911. */
  912. onNewMeshAddedObservable: Observable<AbstractMesh>;
  913. /**
  914. * An event triggered when a mesh is removed
  915. */
  916. onMeshRemovedObservable: Observable<AbstractMesh>;
  917. /**
  918. * An event triggered when render targets are about to be rendered
  919. * Can happen multiple times per frame.
  920. */
  921. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  922. /**
  923. * An event triggered when render targets were rendered.
  924. * Can happen multiple times per frame.
  925. */
  926. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  927. /**
  928. * An event triggered before calculating deterministic simulation step
  929. */
  930. onBeforeStepObservable: Observable<Scene>;
  931. /**
  932. * An event triggered after calculating deterministic simulation step
  933. */
  934. onAfterStepObservable: Observable<Scene>;
  935. /**
  936. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  937. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  938. * 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)
  939. */
  940. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  941. /**
  942. * Gets a list of Animations associated with the scene
  943. */
  944. animations: Animation[];
  945. private _registeredForLateAnimationBindings;
  946. /**
  947. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  948. */
  949. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  950. /**
  951. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  952. */
  953. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  954. /**
  955. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  956. */
  957. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  958. private _onPointerMove;
  959. private _onPointerDown;
  960. private _onPointerUp;
  961. /** Deprecated. Use onPointerObservable instead */
  962. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  963. /** Deprecated. Use onPointerObservable instead */
  964. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  965. /** Deprecated. Use onPointerObservable instead */
  966. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  967. /** Deprecated. Use onPointerObservable instead */
  968. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  969. private _gamepadManager;
  970. /**
  971. * Gets the gamepad manager associated with the scene
  972. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  973. */
  974. readonly gamepadManager: GamepadManager;
  975. /**
  976. * 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).
  977. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  978. */
  979. onPrePointerObservable: Observable<PointerInfoPre>;
  980. /**
  981. * Observable event triggered each time an input event is received from the rendering canvas
  982. */
  983. onPointerObservable: Observable<PointerInfo>;
  984. /**
  985. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  986. */
  987. readonly unTranslatedPointer: Vector2;
  988. /** The distance in pixel that you have to move to prevent some events */
  989. static DragMovementThreshold: number;
  990. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  991. static LongPressDelay: number;
  992. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  993. static DoubleClickDelay: number;
  994. /** If you need to check double click without raising a single click at first click, enable this flag */
  995. static ExclusiveDoubleClickMode: boolean;
  996. private _initClickEvent;
  997. private _initActionManager;
  998. private _delayedSimpleClick;
  999. private _delayedSimpleClickTimeout;
  1000. private _previousDelayedSimpleClickTimeout;
  1001. private _meshPickProceed;
  1002. private _previousButtonPressed;
  1003. private _currentPickResult;
  1004. private _previousPickResult;
  1005. private _totalPointersPressed;
  1006. private _doubleClickOccured;
  1007. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1008. cameraToUseForPointers: Nullable<Camera>;
  1009. private _pointerX;
  1010. private _pointerY;
  1011. private _unTranslatedPointerX;
  1012. private _unTranslatedPointerY;
  1013. private _startingPointerPosition;
  1014. private _previousStartingPointerPosition;
  1015. private _startingPointerTime;
  1016. private _previousStartingPointerTime;
  1017. private _pointerCaptures;
  1018. private _timeAccumulator;
  1019. private _currentStepId;
  1020. private _currentInternalStep;
  1021. /** @hidden */
  1022. _mirroredCameraPosition: Nullable<Vector3>;
  1023. /**
  1024. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1025. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1026. */
  1027. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1028. /**
  1029. * Observable event triggered each time an keyboard event is received from the hosting window
  1030. */
  1031. onKeyboardObservable: Observable<KeyboardInfo>;
  1032. private _onKeyDown;
  1033. private _onKeyUp;
  1034. private _onCanvasFocusObserver;
  1035. private _onCanvasBlurObserver;
  1036. private _useRightHandedSystem;
  1037. /**
  1038. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1039. */
  1040. useRightHandedSystem: boolean;
  1041. /**
  1042. * Sets the step Id used by deterministic lock step
  1043. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1044. * @param newStepId defines the step Id
  1045. */
  1046. setStepId(newStepId: number): void;
  1047. /**
  1048. * Gets the step Id used by deterministic lock step
  1049. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1050. * @returns the step Id
  1051. */
  1052. getStepId(): number;
  1053. /**
  1054. * Gets the internal step used by deterministic lock step
  1055. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1056. * @returns the internal step
  1057. */
  1058. getInternalStep(): number;
  1059. private _fogEnabled;
  1060. /**
  1061. * Gets or sets a boolean indicating if fog is enabled on this scene
  1062. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1063. */
  1064. fogEnabled: boolean;
  1065. private _fogMode;
  1066. /**
  1067. * Gets or sets the fog mode to use
  1068. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1069. */
  1070. fogMode: number;
  1071. /**
  1072. * Gets or sets the fog color to use
  1073. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1074. */
  1075. fogColor: Color3;
  1076. /**
  1077. * Gets or sets the fog density to use
  1078. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1079. */
  1080. fogDensity: number;
  1081. /**
  1082. * Gets or sets the fog start distance to use
  1083. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1084. */
  1085. fogStart: number;
  1086. /**
  1087. * Gets or sets the fog end distance to use
  1088. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1089. */
  1090. fogEnd: number;
  1091. private _shadowsEnabled;
  1092. /**
  1093. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1094. */
  1095. shadowsEnabled: boolean;
  1096. private _lightsEnabled;
  1097. /**
  1098. * Gets or sets a boolean indicating if lights are enabled on this scene
  1099. */
  1100. lightsEnabled: boolean;
  1101. /**
  1102. * All of the lights added to this scene
  1103. * @see http://doc.babylonjs.com/babylon101/lights
  1104. */
  1105. lights: Light[];
  1106. /** All of the cameras added to this scene.
  1107. * @see http://doc.babylonjs.com/babylon101/cameras
  1108. */
  1109. cameras: Camera[];
  1110. /** All of the active cameras added to this scene. */
  1111. activeCameras: Camera[];
  1112. /** The current active camera */
  1113. activeCamera: Nullable<Camera>;
  1114. /**
  1115. * All of the tranform nodes added to this scene
  1116. * @see http://doc.babylonjs.com/how_to/transformnode
  1117. */
  1118. transformNodes: TransformNode[];
  1119. /**
  1120. * All of the (abstract) meshes added to this scene
  1121. */
  1122. meshes: AbstractMesh[];
  1123. /**
  1124. * All of the animation groups added to this scene
  1125. * @see http://doc.babylonjs.com/how_to/group
  1126. */
  1127. animationGroups: AnimationGroup[];
  1128. private _geometries;
  1129. /**
  1130. * All of the materials added to this scene
  1131. * @see http://doc.babylonjs.com/babylon101/materials
  1132. */
  1133. materials: Material[];
  1134. /**
  1135. * All of the multi-materials added to this scene
  1136. * @see http://doc.babylonjs.com/how_to/multi_materials
  1137. */
  1138. multiMaterials: MultiMaterial[];
  1139. private _defaultMaterial;
  1140. /** The default material used on meshes when no material is affected */
  1141. /** The default material used on meshes when no material is affected */
  1142. defaultMaterial: Material;
  1143. private _texturesEnabled;
  1144. /**
  1145. * Gets or sets a boolean indicating if textures are enabled on this scene
  1146. */
  1147. texturesEnabled: boolean;
  1148. /**
  1149. * All of the textures added to this scene
  1150. */
  1151. textures: BaseTexture[];
  1152. /**
  1153. * Gets or sets a boolean indicating if particles are enabled on this scene
  1154. */
  1155. particlesEnabled: boolean;
  1156. /**
  1157. * All of the particle systems added to this scene
  1158. * @see http://doc.babylonjs.com/babylon101/particles
  1159. */
  1160. particleSystems: IParticleSystem[];
  1161. /**
  1162. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1163. */
  1164. spritesEnabled: boolean;
  1165. /**
  1166. * All of the sprite managers added to this scene
  1167. * @see http://doc.babylonjs.com/babylon101/sprites
  1168. */
  1169. spriteManagers: SpriteManager[];
  1170. /**
  1171. * The list of layers (background and foreground) of the scene
  1172. */
  1173. layers: Layer[];
  1174. /**
  1175. * The list of effect layers (highlights/glow) added to the scene
  1176. * @see http://doc.babylonjs.com/how_to/highlight_layer
  1177. * @see http://doc.babylonjs.com/how_to/glow_layer
  1178. */
  1179. effectLayers: EffectLayer[];
  1180. private _skeletonsEnabled;
  1181. /**
  1182. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1183. */
  1184. skeletonsEnabled: boolean;
  1185. /**
  1186. * The list of skeletons added to the scene
  1187. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  1188. */
  1189. skeletons: Skeleton[];
  1190. /**
  1191. * The list of morph target managers added to the scene
  1192. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  1193. */
  1194. morphTargetManagers: MorphTargetManager[];
  1195. /**
  1196. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1197. */
  1198. lensFlaresEnabled: boolean;
  1199. /**
  1200. * The list of lens flare system added to the scene
  1201. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  1202. */
  1203. lensFlareSystems: LensFlareSystem[];
  1204. /**
  1205. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1206. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1207. */
  1208. collisionsEnabled: boolean;
  1209. private _workerCollisions;
  1210. /** @hidden */
  1211. collisionCoordinator: ICollisionCoordinator;
  1212. /**
  1213. * Defines the gravity applied to this scene (used only for collisions)
  1214. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1215. */
  1216. gravity: Vector3;
  1217. /**
  1218. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1219. */
  1220. postProcessesEnabled: boolean;
  1221. /**
  1222. * The list of postprocesses added to the scene
  1223. */
  1224. postProcesses: PostProcess[];
  1225. /**
  1226. * Gets the current postprocess manager
  1227. */
  1228. postProcessManager: PostProcessManager;
  1229. private _postProcessRenderPipelineManager;
  1230. /**
  1231. * Gets the postprocess render pipeline manager
  1232. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1233. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1234. */
  1235. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1236. /**
  1237. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1238. */
  1239. renderTargetsEnabled: boolean;
  1240. /**
  1241. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1242. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1243. */
  1244. dumpNextRenderTargets: boolean;
  1245. /**
  1246. * The list of user defined render targets added to the scene
  1247. */
  1248. customRenderTargets: RenderTargetTexture[];
  1249. /**
  1250. * Defines if texture loading must be delayed
  1251. * If true, textures will only be loaded when they need to be rendered
  1252. */
  1253. useDelayedTextureLoading: boolean;
  1254. /**
  1255. * Gets the list of meshes imported to the scene through SceneLoader
  1256. */
  1257. importedMeshesFiles: String[];
  1258. /**
  1259. * Gets or sets a boolean indicating if probes are enabled on this scene
  1260. */
  1261. probesEnabled: boolean;
  1262. /**
  1263. * The list of reflection probes added to the scene
  1264. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1265. */
  1266. reflectionProbes: ReflectionProbe[];
  1267. /**
  1268. * @hidden
  1269. */
  1270. database: Database;
  1271. /**
  1272. * Gets or sets the action manager associated with the scene
  1273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1274. */
  1275. actionManager: ActionManager;
  1276. /** @hidden */
  1277. _actionManagers: ActionManager[];
  1278. private _meshesForIntersections;
  1279. /**
  1280. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1281. */
  1282. proceduralTexturesEnabled: boolean;
  1283. /**
  1284. * The list of procedural textures added to the scene
  1285. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1286. */
  1287. proceduralTextures: ProceduralTexture[];
  1288. private _mainSoundTrack;
  1289. /**
  1290. * The list of sound tracks added to the scene
  1291. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1292. */
  1293. soundTracks: SoundTrack[];
  1294. private _audioEnabled;
  1295. private _headphone;
  1296. /**
  1297. * Gets the main soundtrack associated with the scene
  1298. */
  1299. readonly mainSoundTrack: SoundTrack;
  1300. /**
  1301. * Gets or sets the VRExperienceHelper attached to the scene
  1302. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1303. * @ignorenaming
  1304. */
  1305. VRHelper: VRExperienceHelper;
  1306. /**
  1307. * Gets or sets the simplification queue attached to the scene
  1308. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1309. */
  1310. simplificationQueue: SimplificationQueue;
  1311. private _engine;
  1312. private _totalVertices;
  1313. /** @hidden */
  1314. _activeIndices: PerfCounter;
  1315. /** @hidden */
  1316. _activeParticles: PerfCounter;
  1317. /** @hidden */
  1318. _activeBones: PerfCounter;
  1319. private _animationRatio;
  1320. private _animationTimeLast;
  1321. private _animationTime;
  1322. /**
  1323. * Gets or sets a general scale for animation speed
  1324. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1325. */
  1326. animationTimeScale: number;
  1327. /** @hidden */
  1328. _cachedMaterial: Nullable<Material>;
  1329. /** @hidden */
  1330. _cachedEffect: Nullable<Effect>;
  1331. /** @hidden */
  1332. _cachedVisibility: Nullable<number>;
  1333. private _renderId;
  1334. private _executeWhenReadyTimeoutId;
  1335. private _intermediateRendering;
  1336. private _viewUpdateFlag;
  1337. private _projectionUpdateFlag;
  1338. private _alternateViewUpdateFlag;
  1339. private _alternateProjectionUpdateFlag;
  1340. /** @hidden */
  1341. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1342. private _activeRequests;
  1343. private _pendingData;
  1344. private _isDisposed;
  1345. /**
  1346. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1347. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1348. */
  1349. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1350. private _activeMeshes;
  1351. private _processedMaterials;
  1352. private _renderTargets;
  1353. /** @hidden */
  1354. _activeParticleSystems: SmartArray<IParticleSystem>;
  1355. private _activeSkeletons;
  1356. private _softwareSkinnedMeshes;
  1357. private _renderingManager;
  1358. private _physicsEngine;
  1359. /** @hidden */
  1360. _activeAnimatables: Animatable[];
  1361. private _transformMatrix;
  1362. private _sceneUbo;
  1363. private _alternateSceneUbo;
  1364. private _pickWithRayInverseMatrix;
  1365. private _boundingBoxRenderer;
  1366. private _outlineRenderer;
  1367. private _viewMatrix;
  1368. private _projectionMatrix;
  1369. private _alternateViewMatrix;
  1370. private _alternateProjectionMatrix;
  1371. private _alternateTransformMatrix;
  1372. private _useAlternateCameraConfiguration;
  1373. private _alternateRendering;
  1374. /** @hidden */
  1375. _forcedViewPosition: Nullable<Vector3>;
  1376. /** @hidden */
  1377. readonly _isAlternateRenderingEnabled: boolean;
  1378. private _frustumPlanes;
  1379. /**
  1380. * Gets the list of frustum planes (built from the active camera)
  1381. */
  1382. readonly frustumPlanes: Plane[];
  1383. /**
  1384. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1385. * This is useful if there are more lights that the maximum simulteanous authorized
  1386. */
  1387. requireLightSorting: boolean;
  1388. private _selectionOctree;
  1389. private _pointerOverMesh;
  1390. private _pointerOverSprite;
  1391. private _debugLayer;
  1392. private _depthRenderer;
  1393. private _geometryBufferRenderer;
  1394. /**
  1395. * Gets the current geometry buffer associated to the scene.
  1396. */
  1397. /**
  1398. * Sets the current geometry buffer for the scene.
  1399. */
  1400. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1401. private _pickedDownMesh;
  1402. private _pickedUpMesh;
  1403. private _pickedDownSprite;
  1404. private _externalData;
  1405. private _uid;
  1406. /**
  1407. * Creates a new Scene
  1408. * @param engine defines the engine to use to render this scene
  1409. */
  1410. constructor(engine: Engine);
  1411. /**
  1412. * Gets the debug layer associated with the scene
  1413. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1414. */
  1415. readonly debugLayer: DebugLayer;
  1416. /**
  1417. * Gets a boolean indicating if collisions are processed on a web worker
  1418. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1419. */
  1420. workerCollisions: boolean;
  1421. /**
  1422. * Gets the octree used to boost mesh selection (picking)
  1423. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1424. */
  1425. readonly selectionOctree: Octree<AbstractMesh>;
  1426. /**
  1427. * Gets the mesh that is currently under the pointer
  1428. */
  1429. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1430. /**
  1431. * Gets the current on-screen X position of the pointer
  1432. */
  1433. readonly pointerX: number;
  1434. /**
  1435. * Gets the current on-screen Y position of the pointer
  1436. */
  1437. readonly pointerY: number;
  1438. /**
  1439. * Gets the cached material (ie. the latest rendered one)
  1440. * @returns the cached material
  1441. */
  1442. getCachedMaterial(): Nullable<Material>;
  1443. /**
  1444. * Gets the cached effect (ie. the latest rendered one)
  1445. * @returns the cached effect
  1446. */
  1447. getCachedEffect(): Nullable<Effect>;
  1448. /**
  1449. * Gets the cached visibility state (ie. the latest rendered one)
  1450. * @returns the cached visibility state
  1451. */
  1452. getCachedVisibility(): Nullable<number>;
  1453. /**
  1454. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1455. * @param material defines the current material
  1456. * @param effect defines the current effect
  1457. * @param visibility defines the current visibility state
  1458. * @returns true if one parameter is not cached
  1459. */
  1460. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1461. /**
  1462. * Gets the bounding box renderer associated with the scene
  1463. * @returns a BoundingBoxRenderer
  1464. */
  1465. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1466. /**
  1467. * Gets the outline renderer associated with the scene
  1468. * @returns a OutlineRenderer
  1469. */
  1470. getOutlineRenderer(): OutlineRenderer;
  1471. /**
  1472. * Gets the engine associated with the scene
  1473. * @returns an Engine
  1474. */
  1475. getEngine(): Engine;
  1476. /**
  1477. * Gets the total number of vertices rendered per frame
  1478. * @returns the total number of vertices rendered per frame
  1479. */
  1480. getTotalVertices(): number;
  1481. /**
  1482. * Gets the performance counter for total vertices
  1483. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1484. */
  1485. readonly totalVerticesPerfCounter: PerfCounter;
  1486. /**
  1487. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1488. * @returns the total number of active indices rendered per frame
  1489. */
  1490. getActiveIndices(): number;
  1491. /**
  1492. * Gets the performance counter for active indices
  1493. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1494. */
  1495. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1496. /**
  1497. * Gets the total number of active particles rendered per frame
  1498. * @returns the total number of active particles rendered per frame
  1499. */
  1500. getActiveParticles(): number;
  1501. /**
  1502. * Gets the performance counter for active particles
  1503. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1504. */
  1505. readonly activeParticlesPerfCounter: PerfCounter;
  1506. /**
  1507. * Gets the total number of active bones rendered per frame
  1508. * @returns the total number of active bones rendered per frame
  1509. */
  1510. getActiveBones(): number;
  1511. /**
  1512. * Gets the performance counter for active bones
  1513. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1514. */
  1515. readonly activeBonesPerfCounter: PerfCounter;
  1516. /** @hidden */
  1517. getInterFramePerfCounter(): number;
  1518. /** @hidden */
  1519. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1520. /** @hidden */
  1521. getLastFrameDuration(): number;
  1522. /** @hidden */
  1523. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1524. /** @hidden */
  1525. getEvaluateActiveMeshesDuration(): number;
  1526. /** @hidden */
  1527. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1528. /**
  1529. * Gets the array of active meshes
  1530. * @returns an array of AbstractMesh
  1531. */
  1532. getActiveMeshes(): SmartArray<AbstractMesh>;
  1533. /** @hidden */
  1534. getRenderTargetsDuration(): number;
  1535. /** @hidden */
  1536. getRenderDuration(): number;
  1537. /** @hidden */
  1538. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1539. /** @hidden */
  1540. getParticlesDuration(): number;
  1541. /** @hidden */
  1542. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1543. /** @hidden */
  1544. getSpritesDuration(): number;
  1545. /** @hidden */
  1546. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1547. /**
  1548. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1549. * @returns a number
  1550. */
  1551. getAnimationRatio(): number;
  1552. /**
  1553. * Gets an unique Id for the current frame
  1554. * @returns a number
  1555. */
  1556. getRenderId(): number;
  1557. /** Call this function if you want to manually increment the render Id*/
  1558. incrementRenderId(): void;
  1559. private _updatePointerPosition(evt);
  1560. private _createUbo();
  1561. private _createAlternateUbo();
  1562. /**
  1563. * Use this method to simulate a pointer move on a mesh
  1564. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1565. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1566. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1567. * @returns the current scene
  1568. */
  1569. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1570. private _processPointerMove(pickResult, evt);
  1571. /**
  1572. * Use this method to simulate a pointer down on a mesh
  1573. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1574. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1575. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1576. * @returns the current scene
  1577. */
  1578. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1579. private _processPointerDown(pickResult, evt);
  1580. /**
  1581. * Use this method to simulate a pointer up on a mesh
  1582. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1583. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1584. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1585. * @returns the current scene
  1586. */
  1587. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1588. private _processPointerUp(pickResult, evt, clickInfo);
  1589. /**
  1590. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1591. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1592. * @returns true if the pointer was captured
  1593. */
  1594. isPointerCaptured(pointerId?: number): boolean;
  1595. /**
  1596. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1597. * @param attachUp defines if you want to attach events to pointerup
  1598. * @param attachDown defines if you want to attach events to pointerdown
  1599. * @param attachMove defines if you want to attach events to pointermove
  1600. */
  1601. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1602. /** Detaches all event handlers*/
  1603. detachControl(): void;
  1604. /**
  1605. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1606. * Delay loaded resources are not taking in account
  1607. * @return true if all required resources are ready
  1608. */
  1609. isReady(): boolean;
  1610. /** Resets all cached information relative to material (including effect and visibility) */
  1611. resetCachedMaterial(): void;
  1612. /**
  1613. * Registers a function to be called before every frame render
  1614. * @param func defines the function to register
  1615. */
  1616. registerBeforeRender(func: () => void): void;
  1617. /**
  1618. * Unregisters a function called before every frame render
  1619. * @param func defines the function to unregister
  1620. */
  1621. unregisterBeforeRender(func: () => void): void;
  1622. /**
  1623. * Registers a function to be called after every frame render
  1624. * @param func defines the function to register
  1625. */
  1626. registerAfterRender(func: () => void): void;
  1627. /**
  1628. * Unregisters a function called after every frame render
  1629. * @param func defines the function to unregister
  1630. */
  1631. unregisterAfterRender(func: () => void): void;
  1632. private _executeOnceBeforeRender(func);
  1633. /**
  1634. * The provided function will run before render once and will be disposed afterwards.
  1635. * A timeout delay can be provided so that the function will be executed in N ms.
  1636. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1637. * @param func The function to be executed.
  1638. * @param timeout optional delay in ms
  1639. */
  1640. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1641. /** @hidden */
  1642. _addPendingData(data: any): void;
  1643. /** @hidden */
  1644. _removePendingData(data: any): void;
  1645. /**
  1646. * Returns the number of items waiting to be loaded
  1647. * @returns the number of items waiting to be loaded
  1648. */
  1649. getWaitingItemsCount(): number;
  1650. /**
  1651. * Returns a boolean indicating if the scene is still loading data
  1652. */
  1653. readonly isLoading: boolean;
  1654. /**
  1655. * Registers a function to be executed when the scene is ready
  1656. * @param {Function} func - the function to be executed
  1657. */
  1658. executeWhenReady(func: () => void): void;
  1659. /**
  1660. * Returns a promise that resolves when the scene is ready
  1661. * @returns A promise that resolves when the scene is ready
  1662. */
  1663. whenReadyAsync(): Promise<void>;
  1664. /** @hidden */
  1665. _checkIsReady(): void;
  1666. /**
  1667. * Will start the animation sequence of a given target
  1668. * @param target defines the target
  1669. * @param from defines from which frame should animation start
  1670. * @param to defines until which frame should animation run.
  1671. * @param weight defines the weight to apply to the animation (1.0 by default)
  1672. * @param loop defines if the animation loops
  1673. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1674. * @param onAnimationEnd defines the function to be executed when the animation ends
  1675. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1676. * @returns the animatable object created for this animation
  1677. */
  1678. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1679. /**
  1680. * Will start the animation sequence of a given target
  1681. * @param target defines the target
  1682. * @param from defines from which frame should animation start
  1683. * @param to defines until which frame should animation run.
  1684. * @param loop defines if the animation loops
  1685. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1686. * @param onAnimationEnd defines the function to be executed when the animation ends
  1687. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1688. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1689. * @returns the animatable object created for this animation
  1690. */
  1691. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean): Animatable;
  1692. /**
  1693. * Begin a new animation on a given node
  1694. * @param target defines the target where the animation will take place
  1695. * @param animations defines the list of animations to start
  1696. * @param from defines the initial value
  1697. * @param to defines the final value
  1698. * @param loop defines if you want animation to loop (off by default)
  1699. * @param speedRatio defines the speed ratio to apply to all animations
  1700. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1701. * @returns the list of created animatables
  1702. */
  1703. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1704. /**
  1705. * Begin a new animation on a given node and its hierarchy
  1706. * @param target defines the root node where the animation will take place
  1707. * @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.
  1708. * @param animations defines the list of animations to start
  1709. * @param from defines the initial value
  1710. * @param to defines the final value
  1711. * @param loop defines if you want animation to loop (off by default)
  1712. * @param speedRatio defines the speed ratio to apply to all animations
  1713. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1714. * @returns the list of animatables created for all nodes
  1715. */
  1716. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1717. /**
  1718. * Gets the animatable associated with a specific target
  1719. * @param target defines the target of the animatable
  1720. * @returns the required animatable if found
  1721. */
  1722. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1723. /**
  1724. * Gets all animatables associated with a given target
  1725. * @param target defines the target to look animatables for
  1726. * @returns an array of Animatables
  1727. */
  1728. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1729. /**
  1730. * Gets all animatable attached to the scene
  1731. */
  1732. readonly animatables: Animatable[];
  1733. /**
  1734. * Will stop the animation of the given target
  1735. * @param target - the target
  1736. * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
  1737. */
  1738. stopAnimation(target: any, animationName?: string): void;
  1739. /**
  1740. * Stops and removes all animations that have been applied to the scene
  1741. */
  1742. stopAllAnimations(): void;
  1743. private _animate();
  1744. /** @hidden */
  1745. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1746. private _processLateAnimationBindingsForMatrices(holder);
  1747. private _processLateAnimationBindingsForQuaternions(holder);
  1748. private _processLateAnimationBindings();
  1749. /** @hidden */
  1750. _switchToAlternateCameraConfiguration(active: boolean): void;
  1751. /**
  1752. * Gets the current view matrix
  1753. * @returns a Matrix
  1754. */
  1755. getViewMatrix(): Matrix;
  1756. /**
  1757. * Gets the current projection matrix
  1758. * @returns a Matrix
  1759. */
  1760. getProjectionMatrix(): Matrix;
  1761. /**
  1762. * Gets the current transform matrix
  1763. * @returns a Matrix made of View * Projection
  1764. */
  1765. getTransformMatrix(): Matrix;
  1766. /**
  1767. * Sets the current transform matrix
  1768. * @param view defines the View matrix to use
  1769. * @param projection defines the Projection matrix to use
  1770. */
  1771. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1772. /** @hidden */
  1773. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1774. /**
  1775. * Gets the uniform buffer used to store scene data
  1776. * @returns a UniformBuffer
  1777. */
  1778. getSceneUniformBuffer(): UniformBuffer;
  1779. /**
  1780. * Gets an unique (relatively to the current scene) Id
  1781. * @returns an unique number for the scene
  1782. */
  1783. getUniqueId(): number;
  1784. /**
  1785. * Add a mesh to the list of scene's meshes
  1786. * @param newMesh defines the mesh to add
  1787. */
  1788. addMesh(newMesh: AbstractMesh): void;
  1789. /**
  1790. * Remove a mesh for the list of scene's meshes
  1791. * @param toRemove defines the mesh to remove
  1792. * @param recursive if all child meshes should also be removed from the scene
  1793. * @returns the index where the mesh was in the mesh list
  1794. */
  1795. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1796. /**
  1797. * Add a transform node to the list of scene's transform nodes
  1798. * @param newTransformNode defines the transform node to add
  1799. */
  1800. addTransformNode(newTransformNode: TransformNode): void;
  1801. /**
  1802. * Remove a transform node for the list of scene's transform nodes
  1803. * @param toRemove defines the transform node to remove
  1804. * @returns the index where the transform node was in the transform node list
  1805. */
  1806. removeTransformNode(toRemove: TransformNode): number;
  1807. /**
  1808. * Remove a skeleton for the list of scene's skeletons
  1809. * @param toRemove defines the skeleton to remove
  1810. * @returns the index where the skeleton was in the skeleton list
  1811. */
  1812. removeSkeleton(toRemove: Skeleton): number;
  1813. /**
  1814. * Remove a morph target for the list of scene's morph targets
  1815. * @param toRemove defines the morph target to remove
  1816. * @returns the index where the morph target was in the morph target list
  1817. */
  1818. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1819. /**
  1820. * Remove a light for the list of scene's lights
  1821. * @param toRemove defines the light to remove
  1822. * @returns the index where the light was in the light list
  1823. */
  1824. removeLight(toRemove: Light): number;
  1825. /**
  1826. * Remove a camera for the list of scene's cameras
  1827. * @param toRemove defines the camera to remove
  1828. * @returns the index where the camera was in the camera list
  1829. */
  1830. removeCamera(toRemove: Camera): number;
  1831. /**
  1832. * Remove a particle system for the list of scene's particle systems
  1833. * @param toRemove defines the particle system to remove
  1834. * @returns the index where the particle system was in the particle system list
  1835. */
  1836. removeParticleSystem(toRemove: IParticleSystem): number;
  1837. /**
  1838. * Remove a animation for the list of scene's animations
  1839. * @param toRemove defines the animation to remove
  1840. * @returns the index where the animation was in the animation list
  1841. */
  1842. removeAnimation(toRemove: Animation): number;
  1843. /**
  1844. * Removes the given animation group from this scene.
  1845. * @param toRemove The animation group to remove
  1846. * @returns The index of the removed animation group
  1847. */
  1848. removeAnimationGroup(toRemove: AnimationGroup): number;
  1849. /**
  1850. * Removes the given multi-material from this scene.
  1851. * @param toRemove The multi-material to remove
  1852. * @returns The index of the removed multi-material
  1853. */
  1854. removeMultiMaterial(toRemove: MultiMaterial): number;
  1855. /**
  1856. * Removes the given material from this scene.
  1857. * @param toRemove The material to remove
  1858. * @returns The index of the removed material
  1859. */
  1860. removeMaterial(toRemove: Material): number;
  1861. /**
  1862. * Removes the given lens flare system from this scene.
  1863. * @param toRemove The lens flare system to remove
  1864. * @returns The index of the removed lens flare system
  1865. */
  1866. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1867. /**
  1868. * Removes the given action manager from this scene.
  1869. * @param toRemove The action manager to remove
  1870. * @returns The index of the removed action manager
  1871. */
  1872. removeActionManager(toRemove: ActionManager): number;
  1873. /**
  1874. * Removes the given effect layer from this scene.
  1875. * @param toRemove defines the effect layer to remove
  1876. * @returns the index of the removed effect layer
  1877. */
  1878. removeEffectLayer(toRemove: EffectLayer): number;
  1879. /**
  1880. * Removes the given texture from this scene.
  1881. * @param toRemove The texture to remove
  1882. * @returns The index of the removed texture
  1883. */
  1884. removeTexture(toRemove: BaseTexture): number;
  1885. /**
  1886. * Adds the given light to this scene
  1887. * @param newLight The light to add
  1888. */
  1889. addLight(newLight: Light): void;
  1890. /**
  1891. * Sorts the list list based on light priorities
  1892. */
  1893. sortLightsByPriority(): void;
  1894. /**
  1895. * Adds the given camera to this scene
  1896. * @param newCamera The camera to add
  1897. */
  1898. addCamera(newCamera: Camera): void;
  1899. /**
  1900. * Adds the given skeleton to this scene
  1901. * @param newSkeleton The skeleton to add
  1902. */
  1903. addSkeleton(newSkeleton: Skeleton): void;
  1904. /**
  1905. * Adds the given particle system to this scene
  1906. * @param newParticleSystem The particle system to add
  1907. */
  1908. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1909. /**
  1910. * Adds the given animation to this scene
  1911. * @param newAnimation The animation to add
  1912. */
  1913. addAnimation(newAnimation: Animation): void;
  1914. /**
  1915. * Adds the given animation group to this scene.
  1916. * @param newAnimationGroup The animation group to add
  1917. */
  1918. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1919. /**
  1920. * Adds the given multi-material to this scene
  1921. * @param newMultiMaterial The multi-material to add
  1922. */
  1923. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1924. /**
  1925. * Adds the given material to this scene
  1926. * @param newMaterial The material to add
  1927. */
  1928. addMaterial(newMaterial: Material): void;
  1929. /**
  1930. * Adds the given morph target to this scene
  1931. * @param newMorphTargetManager The morph target to add
  1932. */
  1933. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1934. /**
  1935. * Adds the given geometry to this scene
  1936. * @param newGeometry The geometry to add
  1937. */
  1938. addGeometry(newGeometry: Geometry): void;
  1939. /**
  1940. * Adds the given lens flare system to this scene
  1941. * @param newLensFlareSystem The lens flare system to add
  1942. */
  1943. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1944. /**
  1945. * Adds the given effect layer to this scene
  1946. * @param newEffectLayer defines the effect layer to add
  1947. */
  1948. addEffectLayer(newEffectLayer: EffectLayer): void;
  1949. /**
  1950. * Adds the given action manager to this scene
  1951. * @param newActionManager The action manager to add
  1952. */
  1953. addActionManager(newActionManager: ActionManager): void;
  1954. /**
  1955. * Adds the given texture to this scene.
  1956. * @param newTexture The texture to add
  1957. */
  1958. addTexture(newTexture: BaseTexture): void;
  1959. /**
  1960. * Switch active camera
  1961. * @param newCamera defines the new active camera
  1962. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1963. */
  1964. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1965. /**
  1966. * sets the active camera of the scene using its ID
  1967. * @param id defines the camera's ID
  1968. * @return the new active camera or null if none found.
  1969. */
  1970. setActiveCameraByID(id: string): Nullable<Camera>;
  1971. /**
  1972. * sets the active camera of the scene using its name
  1973. * @param name defines the camera's name
  1974. * @returns the new active camera or null if none found.
  1975. */
  1976. setActiveCameraByName(name: string): Nullable<Camera>;
  1977. /**
  1978. * get an animation group using its name
  1979. * @param name defines the material's name
  1980. * @return the animation group or null if none found.
  1981. */
  1982. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1983. /**
  1984. * get a material using its id
  1985. * @param id defines the material's ID
  1986. * @return the material or null if none found.
  1987. */
  1988. getMaterialByID(id: string): Nullable<Material>;
  1989. /**
  1990. * Gets a material using its name
  1991. * @param name defines the material's name
  1992. * @return the material or null if none found.
  1993. */
  1994. getMaterialByName(name: string): Nullable<Material>;
  1995. /**
  1996. * Gets a lens flare system using its name
  1997. * @param name defines the name to look for
  1998. * @returns the lens flare system or null if not found
  1999. */
  2000. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  2001. /**
  2002. * Gets a lens flare system using its id
  2003. * @param id defines the id to look for
  2004. * @returns the lens flare system or null if not found
  2005. */
  2006. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  2007. /**
  2008. * Gets a camera using its id
  2009. * @param id defines the id to look for
  2010. * @returns the camera or null if not found
  2011. */
  2012. getCameraByID(id: string): Nullable<Camera>;
  2013. /**
  2014. * Gets a camera using its unique id
  2015. * @param uniqueId defines the unique id to look for
  2016. * @returns the camera or null if not found
  2017. */
  2018. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2019. /**
  2020. * Gets a camera using its name
  2021. * @param name defines the camera's name
  2022. * @return the camera or null if none found.
  2023. */
  2024. getCameraByName(name: string): Nullable<Camera>;
  2025. /**
  2026. * Gets a bone using its id
  2027. * @param id defines the bone's id
  2028. * @return the bone or null if not found
  2029. */
  2030. getBoneByID(id: string): Nullable<Bone>;
  2031. /**
  2032. * Gets a bone using its id
  2033. * @param name defines the bone's name
  2034. * @return the bone or null if not found
  2035. */
  2036. getBoneByName(name: string): Nullable<Bone>;
  2037. /**
  2038. * Gets a light node using its name
  2039. * @param name defines the the light's name
  2040. * @return the light or null if none found.
  2041. */
  2042. getLightByName(name: string): Nullable<Light>;
  2043. /**
  2044. * Gets a light node using its id
  2045. * @param id defines the light's id
  2046. * @return the light or null if none found.
  2047. */
  2048. getLightByID(id: string): Nullable<Light>;
  2049. /**
  2050. * Gets a light node using its scene-generated unique ID
  2051. * @param uniqueId defines the light's unique id
  2052. * @return the light or null if none found.
  2053. */
  2054. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2055. /**
  2056. * Gets a particle system by id
  2057. * @param id defines the particle system id
  2058. * @return the corresponding system or null if none found
  2059. */
  2060. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2061. /**
  2062. * Gets a geometry using its ID
  2063. * @param id defines the geometry's id
  2064. * @return the geometry or null if none found.
  2065. */
  2066. getGeometryByID(id: string): Nullable<Geometry>;
  2067. /**
  2068. * Add a new geometry to this scene
  2069. * @param geometry defines the geometry to be added to the scene.
  2070. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2071. * @return a boolean defining if the geometry was added or not
  2072. */
  2073. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2074. /**
  2075. * Removes an existing geometry
  2076. * @param geometry defines the geometry to be removed from the scene
  2077. * @return a boolean defining if the geometry was removed or not
  2078. */
  2079. removeGeometry(geometry: Geometry): boolean;
  2080. /**
  2081. * Gets the list of geometries attached to the scene
  2082. * @returns an array of Geometry
  2083. */
  2084. getGeometries(): Geometry[];
  2085. /**
  2086. * Gets the first added mesh found of a given ID
  2087. * @param id defines the id to search for
  2088. * @return the mesh found or null if not found at all
  2089. */
  2090. getMeshByID(id: string): Nullable<AbstractMesh>;
  2091. /**
  2092. * Gets a list of meshes using their id
  2093. * @param id defines the id to search for
  2094. * @returns a list of meshes
  2095. */
  2096. getMeshesByID(id: string): Array<AbstractMesh>;
  2097. /**
  2098. * Gets the first added transform node found of a given ID
  2099. * @param id defines the id to search for
  2100. * @return the found transform node or null if not found at all.
  2101. */
  2102. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2103. /**
  2104. * Gets a list of transform nodes using their id
  2105. * @param id defines the id to search for
  2106. * @returns a list of transform nodes
  2107. */
  2108. getTransformNodesByID(id: string): Array<TransformNode>;
  2109. /**
  2110. * Gets a mesh with its auto-generated unique id
  2111. * @param uniqueId defines the unique id to search for
  2112. * @return the found mesh or null if not found at all.
  2113. */
  2114. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2115. /**
  2116. * Gets a the last added mesh using a given id
  2117. * @param id defines the id to search for
  2118. * @return the found mesh or null if not found at all.
  2119. */
  2120. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2121. /**
  2122. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2123. * @param id defines the id to search for
  2124. * @return the found node or null if not found at all
  2125. */
  2126. getLastEntryByID(id: string): Nullable<Node>;
  2127. /**
  2128. * Gets a node (Mesh, Camera, Light) using a given id
  2129. * @param id defines the id to search for
  2130. * @return the found node or null if not found at all
  2131. */
  2132. getNodeByID(id: string): Nullable<Node>;
  2133. /**
  2134. * Gets a node (Mesh, Camera, Light) using a given name
  2135. * @param name defines the name to search for
  2136. * @return the found node or null if not found at all.
  2137. */
  2138. getNodeByName(name: string): Nullable<Node>;
  2139. /**
  2140. * Gets a mesh using a given name
  2141. * @param name defines the name to search for
  2142. * @return the found mesh or null if not found at all.
  2143. */
  2144. getMeshByName(name: string): Nullable<AbstractMesh>;
  2145. /**
  2146. * Gets a transform node using a given name
  2147. * @param name defines the name to search for
  2148. * @return the found transform node or null if not found at all.
  2149. */
  2150. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2151. /**
  2152. * Gets a sound using a given name
  2153. * @param name defines the name to search for
  2154. * @return the found sound or null if not found at all.
  2155. */
  2156. getSoundByName(name: string): Nullable<Sound>;
  2157. /**
  2158. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2159. * @param id defines the id to search for
  2160. * @return the found skeleton or null if not found at all.
  2161. */
  2162. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2163. /**
  2164. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2165. * @param id defines the id to search for
  2166. * @return the found skeleton or null if not found at all.
  2167. */
  2168. getSkeletonById(id: string): Nullable<Skeleton>;
  2169. /**
  2170. * Gets a skeleton using a given name
  2171. * @param name defines the name to search for
  2172. * @return the found skeleton or null if not found at all.
  2173. */
  2174. getSkeletonByName(name: string): Nullable<Skeleton>;
  2175. /**
  2176. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2177. * @param id defines the id to search for
  2178. * @return the found morph target manager or null if not found at all.
  2179. */
  2180. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2181. /**
  2182. * Gets a boolean indicating if the given mesh is active
  2183. * @param mesh defines the mesh to look for
  2184. * @returns true if the mesh is in the active list
  2185. */
  2186. isActiveMesh(mesh: AbstractMesh): boolean;
  2187. /**
  2188. * Return a the first highlight layer of the scene with a given name.
  2189. * @param name The name of the highlight layer to look for.
  2190. * @return The highlight layer if found otherwise null.
  2191. */
  2192. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  2193. /**
  2194. * Return a the first highlight layer of the scene with a given name.
  2195. * @param name The name of the highlight layer to look for.
  2196. * @return The highlight layer if found otherwise null.
  2197. */
  2198. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  2199. /**
  2200. * Return a unique id as a string which can serve as an identifier for the scene
  2201. */
  2202. readonly uid: string;
  2203. /**
  2204. * Add an externaly attached data from its key.
  2205. * This method call will fail and return false, if such key already exists.
  2206. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2207. * @param key the unique key that identifies the data
  2208. * @param data the data object to associate to the key for this Engine instance
  2209. * @return true if no such key were already present and the data was added successfully, false otherwise
  2210. */
  2211. addExternalData<T>(key: string, data: T): boolean;
  2212. /**
  2213. * Get an externaly attached data from its key
  2214. * @param key the unique key that identifies the data
  2215. * @return the associated data, if present (can be null), or undefined if not present
  2216. */
  2217. getExternalData<T>(key: string): Nullable<T>;
  2218. /**
  2219. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2220. * @param key the unique key that identifies the data
  2221. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2222. * @return the associated data, can be null if the factory returned null.
  2223. */
  2224. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2225. /**
  2226. * Remove an externaly attached data from the Engine instance
  2227. * @param key the unique key that identifies the data
  2228. * @return true if the data was successfully removed, false if it doesn't exist
  2229. */
  2230. removeExternalData(key: string): boolean;
  2231. private _evaluateSubMesh(subMesh, mesh);
  2232. /**
  2233. * Clear the processed materials smart array preventing retention point in material dispose.
  2234. */
  2235. freeProcessedMaterials(): void;
  2236. /**
  2237. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2238. */
  2239. freeActiveMeshes(): void;
  2240. /**
  2241. * Clear the info related to rendering groups preventing retention points during dispose.
  2242. */
  2243. freeRenderingGroups(): void;
  2244. /** @hidden */
  2245. _isInIntermediateRendering(): boolean;
  2246. private _activeMeshCandidateProvider;
  2247. /**
  2248. * Defines the current active mesh candidate provider
  2249. * @param provider defines the provider to use
  2250. */
  2251. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2252. /**
  2253. * Gets the current active mesh candidate provider
  2254. * @returns the current active mesh candidate provider
  2255. */
  2256. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2257. private _activeMeshesFrozen;
  2258. /**
  2259. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2260. * @returns the current scene
  2261. */
  2262. freezeActiveMeshes(): Scene;
  2263. /**
  2264. * Use this function to restart evaluating active meshes on every frame
  2265. * @returns the current scene
  2266. */
  2267. unfreezeActiveMeshes(): Scene;
  2268. private _evaluateActiveMeshes();
  2269. private _activeMesh(sourceMesh, mesh);
  2270. /**
  2271. * Update the transform matrix to update from the current active camera
  2272. * @param force defines a boolean used to force the update even if cache is up to date
  2273. */
  2274. updateTransformMatrix(force?: boolean): void;
  2275. /**
  2276. * 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)
  2277. * @param alternateCamera defines the camera to use
  2278. */
  2279. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2280. private _renderForCamera(camera, rigParent?);
  2281. private _processSubCameras(camera);
  2282. private _checkIntersections();
  2283. /**
  2284. * Render the scene
  2285. */
  2286. render(): void;
  2287. private _updateAudioParameters();
  2288. /**
  2289. * Gets or sets if audio support is enabled
  2290. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2291. */
  2292. audioEnabled: boolean;
  2293. private _disableAudio();
  2294. private _enableAudio();
  2295. /**
  2296. * Gets or sets if audio will be output to headphones
  2297. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2298. */
  2299. headphone: boolean;
  2300. private _switchAudioModeForHeadphones();
  2301. private _switchAudioModeForNormalSpeakers();
  2302. /**
  2303. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2304. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2305. * @returns the created depth renderer
  2306. */
  2307. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2308. /**
  2309. * Disables a depth renderer for a given camera
  2310. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2311. */
  2312. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2313. /**
  2314. * Enables a GeometryBufferRender and associates it with the scene
  2315. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2316. * @returns the GeometryBufferRenderer
  2317. */
  2318. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2319. /**
  2320. * Disables the GeometryBufferRender associated with the scene
  2321. */
  2322. disableGeometryBufferRenderer(): void;
  2323. /**
  2324. * Freeze all materials
  2325. * A frozen material will not be updatable but should be faster to render
  2326. */
  2327. freezeMaterials(): void;
  2328. /**
  2329. * Unfreeze all materials
  2330. * A frozen material will not be updatable but should be faster to render
  2331. */
  2332. unfreezeMaterials(): void;
  2333. /**
  2334. * Releases all held ressources
  2335. */
  2336. dispose(): void;
  2337. /**
  2338. * Gets if the scene is already disposed
  2339. */
  2340. readonly isDisposed: boolean;
  2341. /**
  2342. * Releases sounds & soundtracks
  2343. */
  2344. disposeSounds(): void;
  2345. /**
  2346. * Get the world extend vectors with an optional filter
  2347. *
  2348. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2349. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2350. */
  2351. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2352. min: Vector3;
  2353. max: Vector3;
  2354. };
  2355. /**
  2356. * Creates or updates the octree used to boost selection (picking)
  2357. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2358. * @param maxCapacity defines the maximum capacity per leaf
  2359. * @param maxDepth defines the maximum depth of the octree
  2360. * @returns an octree of AbstractMesh
  2361. */
  2362. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2363. /**
  2364. * Creates a ray that can be used to pick in the scene
  2365. * @param x defines the x coordinate of the origin (on-screen)
  2366. * @param y defines the y coordinate of the origin (on-screen)
  2367. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2368. * @param camera defines the camera to use for the picking
  2369. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2370. * @returns a Ray
  2371. */
  2372. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2373. /**
  2374. * Creates a ray that can be used to pick in the scene
  2375. * @param x defines the x coordinate of the origin (on-screen)
  2376. * @param y defines the y coordinate of the origin (on-screen)
  2377. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2378. * @param result defines the ray where to store the picking ray
  2379. * @param camera defines the camera to use for the picking
  2380. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2381. * @returns the current scene
  2382. */
  2383. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2384. /**
  2385. * Creates a ray that can be used to pick in the scene
  2386. * @param x defines the x coordinate of the origin (on-screen)
  2387. * @param y defines the y coordinate of the origin (on-screen)
  2388. * @param camera defines the camera to use for the picking
  2389. * @returns a Ray
  2390. */
  2391. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2392. /**
  2393. * Creates a ray that can be used to pick in the scene
  2394. * @param x defines the x coordinate of the origin (on-screen)
  2395. * @param y defines the y coordinate of the origin (on-screen)
  2396. * @param result defines the ray where to store the picking ray
  2397. * @param camera defines the camera to use for the picking
  2398. * @returns the current scene
  2399. */
  2400. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2401. private _internalPick(rayFunction, predicate?, fastCheck?);
  2402. private _internalMultiPick(rayFunction, predicate?);
  2403. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  2404. private _tempPickingRay;
  2405. /** Launch a ray to try to pick a mesh in the scene
  2406. * @param x position on screen
  2407. * @param y position on screen
  2408. * @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
  2409. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2410. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2411. * @returns a PickingInfo
  2412. */
  2413. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2414. /** Launch a ray to try to pick a sprite in the scene
  2415. * @param x position on screen
  2416. * @param y position on screen
  2417. * @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
  2418. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2419. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2420. * @returns a PickingInfo
  2421. */
  2422. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2423. private _cachedRayForTransform;
  2424. /** Use the given ray to pick a mesh in the scene
  2425. * @param ray The ray to use to pick meshes
  2426. * @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
  2427. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2428. * @returns a PickingInfo
  2429. */
  2430. pickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2431. /**
  2432. * Launch a ray to try to pick a mesh in the scene
  2433. * @param x X position on screen
  2434. * @param y Y position on screen
  2435. * @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
  2436. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2437. * @returns an array of PickingInfo
  2438. */
  2439. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2440. /**
  2441. * Launch a ray to try to pick a mesh in the scene
  2442. * @param ray Ray to use
  2443. * @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
  2444. * @returns an array of PickingInfo
  2445. */
  2446. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2447. /**
  2448. * Force the value of meshUnderPointer
  2449. * @param mesh defines the mesh to use
  2450. */
  2451. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2452. /**
  2453. * Gets the mesh under the pointer
  2454. * @returns a Mesh or null if no mesh is under the pointer
  2455. */
  2456. getPointerOverMesh(): Nullable<AbstractMesh>;
  2457. /**
  2458. * Force the sprite under the pointer
  2459. * @param sprite defines the sprite to use
  2460. */
  2461. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2462. /**
  2463. * Gets the sprite under the pointer
  2464. * @returns a Sprite or null if no sprite is under the pointer
  2465. */
  2466. getPointerOverSprite(): Nullable<Sprite>;
  2467. /**
  2468. * Gets the current physics engine
  2469. * @returns a PhysicsEngine or null if none attached
  2470. */
  2471. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2472. /**
  2473. * Enables physics to the current scene
  2474. * @param gravity defines the scene's gravity for the physics engine
  2475. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2476. * @return a boolean indicating if the physics engine was initialized
  2477. */
  2478. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2479. /**
  2480. * Disables and disposes the physics engine associated with the scene
  2481. */
  2482. disablePhysicsEngine(): void;
  2483. /**
  2484. * Gets a boolean indicating if there is an active physics engine
  2485. * @returns a boolean indicating if there is an active physics engine
  2486. */
  2487. isPhysicsEnabled(): boolean;
  2488. /**
  2489. * Deletes a physics compound impostor
  2490. * @param compound defines the compound to delete
  2491. */
  2492. deleteCompoundImpostor(compound: any): void;
  2493. /** @hidden */
  2494. _rebuildGeometries(): void;
  2495. /** @hidden */
  2496. _rebuildTextures(): void;
  2497. /**
  2498. * Creates a default light for the scene.
  2499. * @param replace Whether to replace the existing lights in the scene.
  2500. */
  2501. createDefaultLight(replace?: boolean): void;
  2502. /**
  2503. * Creates a default camera for the scene.
  2504. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  2505. * @param replace Whether to replace the existing active camera in the scene.
  2506. * @param attachCameraControls Whether to attach camera controls to the canvas.
  2507. */
  2508. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2509. /**
  2510. * Creates a default camera and a default light
  2511. * @param createArcRotateCamera defines that the camera will be an ArcRotateCamera
  2512. * @param replace defines if the camera and/or light will replace the existing ones
  2513. * @param attachCameraControls defines if attachControl will be called on the new camera
  2514. */
  2515. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2516. /**
  2517. * Creates a new sky box
  2518. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2519. * @param environmentTexture defines the texture to use as environment texture
  2520. * @param pbr defines if PBRMaterial must be used instead of StandardMaterial
  2521. * @param scale defines the overall scale of the skybox
  2522. * @param blur defines if blurring must be applied to the environment texture (works only with pbr === true)
  2523. * @param setGlobalEnvTexture defines a boolean indicating that scene.environmentTexture must match the current skybox texture (true by default)
  2524. * @returns a new mesh holding the sky box
  2525. */
  2526. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2527. /**
  2528. * Creates a new environment
  2529. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2530. * @param options defines the options you can use to configure the environment
  2531. * @returns the new EnvironmentHelper
  2532. */
  2533. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2534. /**
  2535. * Creates a new VREXperienceHelper
  2536. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2537. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2538. * @returns a new VREXperienceHelper
  2539. */
  2540. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2541. private _getByTags(list, tagsQuery, forEach?);
  2542. /**
  2543. * Get a list of meshes by tags
  2544. * @param tagsQuery defines the tags query to use
  2545. * @param forEach defines a predicate used to filter results
  2546. * @returns an array of Mesh
  2547. */
  2548. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2549. /**
  2550. * Get a list of cameras by tags
  2551. * @param tagsQuery defines the tags query to use
  2552. * @param forEach defines a predicate used to filter results
  2553. * @returns an array of Camera
  2554. */
  2555. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2556. /**
  2557. * Get a list of lights by tags
  2558. * @param tagsQuery defines the tags query to use
  2559. * @param forEach defines a predicate used to filter results
  2560. * @returns an array of Light
  2561. */
  2562. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2563. /**
  2564. * Get a list of materials by tags
  2565. * @param tagsQuery defines the tags query to use
  2566. * @param forEach defines a predicate used to filter results
  2567. * @returns an array of Material
  2568. */
  2569. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2570. /**
  2571. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2572. * This allowed control for front to back rendering or reversly depending of the special needs.
  2573. *
  2574. * @param renderingGroupId The rendering group id corresponding to its index
  2575. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2576. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2577. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2578. */
  2579. 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;
  2580. /**
  2581. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2582. *
  2583. * @param renderingGroupId The rendering group id corresponding to its index
  2584. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2585. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2586. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2587. */
  2588. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2589. /**
  2590. * Will flag all materials as dirty to trigger new shader compilation
  2591. * @param flag defines the flag used to specify which material part must be marked as dirty
  2592. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2593. */
  2594. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2595. /** @hidden */
  2596. _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;
  2597. /** @hidden */
  2598. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2599. }
  2600. }
  2601. declare module BABYLON {
  2602. type Nullable<T> = T | null;
  2603. type float = number;
  2604. type double = number;
  2605. type int = number;
  2606. type FloatArray = number[] | Float32Array;
  2607. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2608. /**
  2609. * Alias for types that can be used by a Buffer or VertexBuffer.
  2610. */
  2611. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2612. }
  2613. declare module BABYLON {
  2614. /**
  2615. * The action to be carried out following a trigger
  2616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2617. */
  2618. class Action {
  2619. /** the trigger, with or without parameters, for the action */
  2620. triggerOptions: any;
  2621. /**
  2622. * Trigger for the action
  2623. */
  2624. trigger: number;
  2625. /**
  2626. * Internal only - manager for action
  2627. * @hidden
  2628. */
  2629. _actionManager: ActionManager;
  2630. private _nextActiveAction;
  2631. private _child;
  2632. private _condition?;
  2633. private _triggerParameter;
  2634. /**
  2635. * An event triggered prior to action being executed.
  2636. */
  2637. onBeforeExecuteObservable: Observable<Action>;
  2638. /**
  2639. * Creates a new Action
  2640. * @param triggerOptions the trigger, with or without parameters, for the action
  2641. * @param condition an optional determinant of action
  2642. */
  2643. constructor(
  2644. /** the trigger, with or without parameters, for the action */
  2645. triggerOptions: any, condition?: Condition);
  2646. /**
  2647. * Internal only
  2648. * @hidden
  2649. */
  2650. _prepare(): void;
  2651. /**
  2652. * Gets the trigger parameters
  2653. * @returns the trigger parameters
  2654. */
  2655. getTriggerParameter(): any;
  2656. /**
  2657. * Internal only - executes current action event
  2658. * @hidden
  2659. */
  2660. _executeCurrent(evt?: ActionEvent): void;
  2661. /**
  2662. * Execute placeholder for child classes
  2663. * @param evt optional action event
  2664. */
  2665. execute(evt?: ActionEvent): void;
  2666. /**
  2667. * Skips to next active action
  2668. */
  2669. skipToNextActiveAction(): void;
  2670. /**
  2671. * Adds action to chain of actions, may be a DoNothingAction
  2672. * @param action defines the next action to execute
  2673. * @returns The action passed in
  2674. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2675. */
  2676. then(action: Action): Action;
  2677. /**
  2678. * Internal only
  2679. * @hidden
  2680. */
  2681. _getProperty(propertyPath: string): string;
  2682. /**
  2683. * Internal only
  2684. * @hidden
  2685. */
  2686. _getEffectiveTarget(target: any, propertyPath: string): any;
  2687. /**
  2688. * Serialize placeholder for child classes
  2689. * @param parent of child
  2690. * @returns the serialized object
  2691. */
  2692. serialize(parent: any): any;
  2693. /**
  2694. * Internal only called by serialize
  2695. * @hidden
  2696. */
  2697. protected _serialize(serializedAction: any, parent?: any): any;
  2698. /**
  2699. * Internal only
  2700. * @hidden
  2701. */
  2702. static _SerializeValueAsString: (value: any) => string;
  2703. /**
  2704. * Internal only
  2705. * @hidden
  2706. */
  2707. static _GetTargetProperty: (target: Scene | Node) => {
  2708. name: string;
  2709. targetType: string;
  2710. value: string;
  2711. };
  2712. }
  2713. }
  2714. declare module BABYLON {
  2715. /**
  2716. * ActionEvent is the event being sent when an action is triggered.
  2717. */
  2718. class ActionEvent {
  2719. /** The mesh or sprite that triggered the action */
  2720. source: any;
  2721. /** The X mouse cursor position at the time of the event */
  2722. pointerX: number;
  2723. /** The Y mouse cursor position at the time of the event */
  2724. pointerY: number;
  2725. /** The mesh that is currently pointed at (can be null) */
  2726. meshUnderPointer: Nullable<AbstractMesh>;
  2727. /** the original (browser) event that triggered the ActionEvent */
  2728. sourceEvent: any;
  2729. /** additional data for the event */
  2730. additionalData: any;
  2731. /**
  2732. * Creates a new ActionEvent
  2733. * @param source The mesh or sprite that triggered the action
  2734. * @param pointerX The X mouse cursor position at the time of the event
  2735. * @param pointerY The Y mouse cursor position at the time of the event
  2736. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2737. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2738. * @param additionalData additional data for the event
  2739. */
  2740. constructor(
  2741. /** The mesh or sprite that triggered the action */
  2742. source: any,
  2743. /** The X mouse cursor position at the time of the event */
  2744. pointerX: number,
  2745. /** The Y mouse cursor position at the time of the event */
  2746. pointerY: number,
  2747. /** The mesh that is currently pointed at (can be null) */
  2748. meshUnderPointer: Nullable<AbstractMesh>,
  2749. /** the original (browser) event that triggered the ActionEvent */
  2750. sourceEvent?: any,
  2751. /** additional data for the event */
  2752. additionalData?: any);
  2753. /**
  2754. * Helper function to auto-create an ActionEvent from a source mesh.
  2755. * @param source The source mesh that triggered the event
  2756. * @param evt The original (browser) event
  2757. * @param additionalData additional data for the event
  2758. * @returns the new ActionEvent
  2759. */
  2760. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2761. /**
  2762. * Helper function to auto-create an ActionEvent from a source sprite
  2763. * @param source The source sprite that triggered the event
  2764. * @param scene Scene associated with the sprite
  2765. * @param evt The original (browser) event
  2766. * @param additionalData additional data for the event
  2767. * @returns the new ActionEvent
  2768. */
  2769. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2770. /**
  2771. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2772. * @param scene the scene where the event occurred
  2773. * @param evt The original (browser) event
  2774. * @returns the new ActionEvent
  2775. */
  2776. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2777. /**
  2778. * Helper function to auto-create an ActionEvent from a primitive
  2779. * @param prim defines the target primitive
  2780. * @param pointerPos defines the pointer position
  2781. * @param evt The original (browser) event
  2782. * @param additionalData additional data for the event
  2783. * @returns the new ActionEvent
  2784. */
  2785. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2786. }
  2787. /**
  2788. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2789. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2791. */
  2792. class ActionManager {
  2793. private static _NothingTrigger;
  2794. private static _OnPickTrigger;
  2795. private static _OnLeftPickTrigger;
  2796. private static _OnRightPickTrigger;
  2797. private static _OnCenterPickTrigger;
  2798. private static _OnPickDownTrigger;
  2799. private static _OnDoublePickTrigger;
  2800. private static _OnPickUpTrigger;
  2801. private static _OnLongPressTrigger;
  2802. private static _OnPointerOverTrigger;
  2803. private static _OnPointerOutTrigger;
  2804. private static _OnEveryFrameTrigger;
  2805. private static _OnIntersectionEnterTrigger;
  2806. private static _OnIntersectionExitTrigger;
  2807. private static _OnKeyDownTrigger;
  2808. private static _OnKeyUpTrigger;
  2809. private static _OnPickOutTrigger;
  2810. /**
  2811. * Nothing
  2812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2813. */
  2814. static readonly NothingTrigger: number;
  2815. /**
  2816. * On pick
  2817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2818. */
  2819. static readonly OnPickTrigger: number;
  2820. /**
  2821. * On left pick
  2822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2823. */
  2824. static readonly OnLeftPickTrigger: number;
  2825. /**
  2826. * On right pick
  2827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2828. */
  2829. static readonly OnRightPickTrigger: number;
  2830. /**
  2831. * On center pick
  2832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2833. */
  2834. static readonly OnCenterPickTrigger: number;
  2835. /**
  2836. * On pick down
  2837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2838. */
  2839. static readonly OnPickDownTrigger: number;
  2840. /**
  2841. * On double pick
  2842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2843. */
  2844. static readonly OnDoublePickTrigger: number;
  2845. /**
  2846. * On pick up
  2847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2848. */
  2849. static readonly OnPickUpTrigger: number;
  2850. /**
  2851. * On pick out.
  2852. * This trigger will only be raised if you also declared a OnPickDown
  2853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2854. */
  2855. static readonly OnPickOutTrigger: number;
  2856. /**
  2857. * On long press
  2858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2859. */
  2860. static readonly OnLongPressTrigger: number;
  2861. /**
  2862. * On pointer over
  2863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2864. */
  2865. static readonly OnPointerOverTrigger: number;
  2866. /**
  2867. * On pointer out
  2868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2869. */
  2870. static readonly OnPointerOutTrigger: number;
  2871. /**
  2872. * On every frame
  2873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2874. */
  2875. static readonly OnEveryFrameTrigger: number;
  2876. /**
  2877. * On intersection enter
  2878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2879. */
  2880. static readonly OnIntersectionEnterTrigger: number;
  2881. /**
  2882. * On intersection exit
  2883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2884. */
  2885. static readonly OnIntersectionExitTrigger: number;
  2886. /**
  2887. * On key down
  2888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2889. */
  2890. static readonly OnKeyDownTrigger: number;
  2891. /**
  2892. * On key up
  2893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2894. */
  2895. static readonly OnKeyUpTrigger: number;
  2896. /** Gets the list of active triggers */
  2897. static Triggers: {
  2898. [key: string]: number;
  2899. };
  2900. /** Gets the list of actions */
  2901. actions: Action[];
  2902. /** Gets the cursor to use when hovering items */
  2903. hoverCursor: string;
  2904. private _scene;
  2905. /**
  2906. * Creates a new action manager
  2907. * @param scene defines the hosting scene
  2908. */
  2909. constructor(scene: Scene);
  2910. /**
  2911. * Releases all associated resources
  2912. */
  2913. dispose(): void;
  2914. /**
  2915. * Gets hosting scene
  2916. * @returns the hosting scene
  2917. */
  2918. getScene(): Scene;
  2919. /**
  2920. * Does this action manager handles actions of any of the given triggers
  2921. * @param triggers defines the triggers to be tested
  2922. * @return a boolean indicating whether one (or more) of the triggers is handled
  2923. */
  2924. hasSpecificTriggers(triggers: number[]): boolean;
  2925. /**
  2926. * Does this action manager handles actions of a given trigger
  2927. * @param trigger defines the trigger to be tested
  2928. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2929. * @return whether the trigger is handled
  2930. */
  2931. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2932. /**
  2933. * Does this action manager has pointer triggers
  2934. */
  2935. readonly hasPointerTriggers: boolean;
  2936. /**
  2937. * Does this action manager has pick triggers
  2938. */
  2939. readonly hasPickTriggers: boolean;
  2940. /**
  2941. * Does exist one action manager with at least one trigger
  2942. **/
  2943. static readonly HasTriggers: boolean;
  2944. /**
  2945. * Does exist one action manager with at least one pick trigger
  2946. **/
  2947. static readonly HasPickTriggers: boolean;
  2948. /**
  2949. * Does exist one action manager that handles actions of a given trigger
  2950. * @param trigger defines the trigger to be tested
  2951. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2952. **/
  2953. static HasSpecificTrigger(trigger: number): boolean;
  2954. /**
  2955. * Registers an action to this action manager
  2956. * @param action defines the action to be registered
  2957. * @return the action amended (prepared) after registration
  2958. */
  2959. registerAction(action: Action): Nullable<Action>;
  2960. /**
  2961. * Unregisters an action to this action manager
  2962. * @param action defines the action to be unregistered
  2963. * @return a boolean indicating whether the action has been unregistered
  2964. */
  2965. unregisterAction(action: Action): Boolean;
  2966. /**
  2967. * Process a specific trigger
  2968. * @param trigger defines the trigger to process
  2969. * @param evt defines the event details to be processed
  2970. */
  2971. processTrigger(trigger: number, evt?: ActionEvent): void;
  2972. /** @hidden */
  2973. _getEffectiveTarget(target: any, propertyPath: string): any;
  2974. /** @hidden */
  2975. _getProperty(propertyPath: string): string;
  2976. /**
  2977. * Serialize this manager to a JSON object
  2978. * @param name defines the property name to store this manager
  2979. * @returns a JSON representation of this manager
  2980. */
  2981. serialize(name: string): any;
  2982. /**
  2983. * Creates a new ActionManager from a JSON data
  2984. * @param parsedActions defines the JSON data to read from
  2985. * @param object defines the hosting mesh
  2986. * @param scene defines the hosting scene
  2987. */
  2988. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  2989. /**
  2990. * Get a trigger name by index
  2991. * @param trigger defines the trigger index
  2992. * @returns a trigger name
  2993. */
  2994. static GetTriggerName(trigger: number): string;
  2995. }
  2996. }
  2997. declare module BABYLON {
  2998. /**
  2999. * A Condition applied to an Action
  3000. */
  3001. class Condition {
  3002. /**
  3003. * Internal only - manager for action
  3004. * @hidden
  3005. */
  3006. _actionManager: ActionManager;
  3007. /**
  3008. * Internal only
  3009. * @hidden
  3010. */
  3011. _evaluationId: number;
  3012. /**
  3013. * Internal only
  3014. * @hidden
  3015. */
  3016. _currentResult: boolean;
  3017. /**
  3018. * Creates a new Condition
  3019. * @param actionManager the manager of the action the condition is applied to
  3020. */
  3021. constructor(actionManager: ActionManager);
  3022. /**
  3023. * Check if the current condition is valid
  3024. * @returns a boolean
  3025. */
  3026. isValid(): boolean;
  3027. /**
  3028. * Internal only
  3029. * @hidden
  3030. */
  3031. _getProperty(propertyPath: string): string;
  3032. /**
  3033. * Internal only
  3034. * @hidden
  3035. */
  3036. _getEffectiveTarget(target: any, propertyPath: string): any;
  3037. /**
  3038. * Serialize placeholder for child classes
  3039. * @returns the serialized object
  3040. */
  3041. serialize(): any;
  3042. /**
  3043. * Internal only
  3044. * @hidden
  3045. */
  3046. protected _serialize(serializedCondition: any): any;
  3047. }
  3048. /**
  3049. * Defines specific conditional operators as extensions of Condition
  3050. */
  3051. class ValueCondition extends Condition {
  3052. /** path to specify the property of the target the conditional operator uses */
  3053. propertyPath: string;
  3054. /** the value compared by the conditional operator against the current value of the property */
  3055. value: any;
  3056. /** the conditional operator, default ValueCondition.IsEqual */
  3057. operator: number;
  3058. /**
  3059. * Internal only
  3060. * @hidden
  3061. */
  3062. private static _IsEqual;
  3063. /**
  3064. * Internal only
  3065. * @hidden
  3066. */
  3067. private static _IsDifferent;
  3068. /**
  3069. * Internal only
  3070. * @hidden
  3071. */
  3072. private static _IsGreater;
  3073. /**
  3074. * Internal only
  3075. * @hidden
  3076. */
  3077. private static _IsLesser;
  3078. /**
  3079. * returns the number for IsEqual
  3080. */
  3081. static readonly IsEqual: number;
  3082. /**
  3083. * Returns the number for IsDifferent
  3084. */
  3085. static readonly IsDifferent: number;
  3086. /**
  3087. * Returns the number for IsGreater
  3088. */
  3089. static readonly IsGreater: number;
  3090. /**
  3091. * Returns the number for IsLesser
  3092. */
  3093. static readonly IsLesser: number;
  3094. /**
  3095. * Internal only The action manager for the condition
  3096. * @hidden
  3097. */
  3098. _actionManager: ActionManager;
  3099. /**
  3100. * Internal only
  3101. * @hidden
  3102. */
  3103. private _target;
  3104. /**
  3105. * Internal only
  3106. * @hidden
  3107. */
  3108. private _effectiveTarget;
  3109. /**
  3110. * Internal only
  3111. * @hidden
  3112. */
  3113. private _property;
  3114. /**
  3115. * Creates a new ValueCondition
  3116. * @param actionManager manager for the action the condition applies to
  3117. * @param target for the action
  3118. * @param propertyPath path to specify the property of the target the conditional operator uses
  3119. * @param value the value compared by the conditional operator against the current value of the property
  3120. * @param operator the conditional operator, default ValueCondition.IsEqual
  3121. */
  3122. constructor(actionManager: ActionManager, target: any,
  3123. /** path to specify the property of the target the conditional operator uses */
  3124. propertyPath: string,
  3125. /** the value compared by the conditional operator against the current value of the property */
  3126. value: any,
  3127. /** the conditional operator, default ValueCondition.IsEqual */
  3128. operator?: number);
  3129. /**
  3130. * Compares the given value with the property value for the specified conditional operator
  3131. * @returns the result of the comparison
  3132. */
  3133. isValid(): boolean;
  3134. /**
  3135. * Serialize the ValueCondition into a JSON compatible object
  3136. * @returns serialization object
  3137. */
  3138. serialize(): any;
  3139. /**
  3140. * Gets the name of the conditional operator for the ValueCondition
  3141. * @param operator the conditional operator
  3142. * @returns the name
  3143. */
  3144. static GetOperatorName(operator: number): string;
  3145. }
  3146. /**
  3147. * Defines a predicate condition as an extension of Condition
  3148. */
  3149. class PredicateCondition extends Condition {
  3150. /** defines the predicate function used to validate the condition */
  3151. predicate: () => boolean;
  3152. /**
  3153. * Internal only - manager for action
  3154. * @hidden
  3155. */
  3156. _actionManager: ActionManager;
  3157. /**
  3158. * Creates a new PredicateCondition
  3159. * @param actionManager manager for the action the condition applies to
  3160. * @param predicate defines the predicate function used to validate the condition
  3161. */
  3162. constructor(actionManager: ActionManager,
  3163. /** defines the predicate function used to validate the condition */
  3164. predicate: () => boolean);
  3165. /**
  3166. * @returns the validity of the predicate condition
  3167. */
  3168. isValid(): boolean;
  3169. }
  3170. /**
  3171. * Defines a state condition as an extension of Condition
  3172. */
  3173. class StateCondition extends Condition {
  3174. value: string;
  3175. /**
  3176. * Internal only - manager for action
  3177. * @hidden
  3178. */
  3179. _actionManager: ActionManager;
  3180. /**
  3181. * Internal only
  3182. * @hidden
  3183. */
  3184. private _target;
  3185. /**
  3186. * Creates a new StateCondition
  3187. * @param actionManager manager for the action the condition applies to
  3188. * @param target of the condition
  3189. * @param value to compare with target state
  3190. */
  3191. constructor(actionManager: ActionManager, target: any, value: string);
  3192. /**
  3193. * @returns the validity of the state
  3194. */
  3195. isValid(): boolean;
  3196. /**
  3197. * Serialize the StateCondition into a JSON compatible object
  3198. * @returns serialization object
  3199. */
  3200. serialize(): any;
  3201. }
  3202. }
  3203. declare module BABYLON {
  3204. class SwitchBooleanAction extends Action {
  3205. propertyPath: string;
  3206. private _target;
  3207. private _effectiveTarget;
  3208. private _property;
  3209. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3210. _prepare(): void;
  3211. execute(): void;
  3212. serialize(parent: any): any;
  3213. }
  3214. class SetStateAction extends Action {
  3215. value: string;
  3216. private _target;
  3217. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3218. execute(): void;
  3219. serialize(parent: any): any;
  3220. }
  3221. class SetValueAction extends Action {
  3222. propertyPath: string;
  3223. value: any;
  3224. private _target;
  3225. private _effectiveTarget;
  3226. private _property;
  3227. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3228. _prepare(): void;
  3229. execute(): void;
  3230. serialize(parent: any): any;
  3231. }
  3232. class IncrementValueAction extends Action {
  3233. propertyPath: string;
  3234. value: any;
  3235. private _target;
  3236. private _effectiveTarget;
  3237. private _property;
  3238. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3239. _prepare(): void;
  3240. execute(): void;
  3241. serialize(parent: any): any;
  3242. }
  3243. class PlayAnimationAction extends Action {
  3244. from: number;
  3245. to: number;
  3246. loop: boolean | undefined;
  3247. private _target;
  3248. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3249. _prepare(): void;
  3250. execute(): void;
  3251. serialize(parent: any): any;
  3252. }
  3253. class StopAnimationAction extends Action {
  3254. private _target;
  3255. constructor(triggerOptions: any, target: any, condition?: Condition);
  3256. _prepare(): void;
  3257. execute(): void;
  3258. serialize(parent: any): any;
  3259. }
  3260. class DoNothingAction extends Action {
  3261. constructor(triggerOptions?: any, condition?: Condition);
  3262. execute(): void;
  3263. serialize(parent: any): any;
  3264. }
  3265. class CombineAction extends Action {
  3266. children: Action[];
  3267. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3268. _prepare(): void;
  3269. execute(evt: ActionEvent): void;
  3270. serialize(parent: any): any;
  3271. }
  3272. class ExecuteCodeAction extends Action {
  3273. func: (evt: ActionEvent) => void;
  3274. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3275. execute(evt: ActionEvent): void;
  3276. }
  3277. class SetParentAction extends Action {
  3278. private _parent;
  3279. private _target;
  3280. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3281. _prepare(): void;
  3282. execute(): void;
  3283. serialize(parent: any): any;
  3284. }
  3285. class PlaySoundAction extends Action {
  3286. private _sound;
  3287. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3288. _prepare(): void;
  3289. execute(): void;
  3290. serialize(parent: any): any;
  3291. }
  3292. class StopSoundAction extends Action {
  3293. private _sound;
  3294. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3295. _prepare(): void;
  3296. execute(): void;
  3297. serialize(parent: any): any;
  3298. }
  3299. }
  3300. declare module BABYLON {
  3301. class InterpolateValueAction extends Action {
  3302. propertyPath: string;
  3303. value: any;
  3304. duration: number;
  3305. stopOtherAnimations: boolean | undefined;
  3306. onInterpolationDone: (() => void) | undefined;
  3307. private _target;
  3308. private _effectiveTarget;
  3309. private _property;
  3310. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3311. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3312. _prepare(): void;
  3313. execute(): void;
  3314. serialize(parent: any): any;
  3315. }
  3316. }
  3317. declare module BABYLON {
  3318. class Animatable {
  3319. target: any;
  3320. fromFrame: number;
  3321. toFrame: number;
  3322. loopAnimation: boolean;
  3323. onAnimationEnd: (() => void) | null | undefined;
  3324. private _localDelayOffset;
  3325. private _pausedDelay;
  3326. private _runtimeAnimations;
  3327. private _paused;
  3328. private _scene;
  3329. private _speedRatio;
  3330. private _weight;
  3331. private _syncRoot;
  3332. animationStarted: boolean;
  3333. /**
  3334. * Gets the root Animatable used to synchronize and normalize animations
  3335. */
  3336. readonly syncRoot: Animatable;
  3337. /**
  3338. * Gets the current frame of the first RuntimeAnimation
  3339. * Used to synchronize Animatables
  3340. */
  3341. readonly masterFrame: number;
  3342. /**
  3343. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3344. */
  3345. weight: number;
  3346. /**
  3347. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3348. */
  3349. speedRatio: number;
  3350. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  3351. /**
  3352. * Synchronize and normalize current Animatable with a source Animatable
  3353. * This is useful when using animation weights and when animations are not of the same length
  3354. * @param root defines the root Animatable to synchronize with
  3355. * @returns the current Animatable
  3356. */
  3357. syncWith(root: Animatable): Animatable;
  3358. getAnimations(): RuntimeAnimation[];
  3359. appendAnimations(target: any, animations: Animation[]): void;
  3360. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3361. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3362. reset(): void;
  3363. enableBlending(blendingSpeed: number): void;
  3364. disableBlending(): void;
  3365. goToFrame(frame: number): void;
  3366. pause(): void;
  3367. restart(): void;
  3368. stop(animationName?: string): void;
  3369. _animate(delay: number): boolean;
  3370. }
  3371. }
  3372. declare module BABYLON {
  3373. /**
  3374. * Represents the range of an animation
  3375. */
  3376. class AnimationRange {
  3377. /**The name of the animation range**/
  3378. name: string;
  3379. /**The starting frame of the animation */
  3380. from: number;
  3381. /**The ending frame of the animation*/
  3382. to: number;
  3383. /**
  3384. * Initializes the range of an animation
  3385. * @param name The name of the animation range
  3386. * @param from The starting frame of the animation
  3387. * @param to The ending frame of the animation
  3388. */
  3389. constructor(
  3390. /**The name of the animation range**/
  3391. name: string,
  3392. /**The starting frame of the animation */
  3393. from: number,
  3394. /**The ending frame of the animation*/
  3395. to: number);
  3396. /**
  3397. * Makes a copy of the animation range
  3398. * @returns A copy of the animation range
  3399. */
  3400. clone(): AnimationRange;
  3401. }
  3402. /**
  3403. * Composed of a frame, and an action function
  3404. */
  3405. class AnimationEvent {
  3406. /** The frame for which the event is triggered **/
  3407. frame: number;
  3408. /** The event to perform when triggered **/
  3409. action: () => void;
  3410. /** Specifies if the event should be triggered only once**/
  3411. onlyOnce: boolean | undefined;
  3412. /**
  3413. * Specifies if the animation event is done
  3414. */
  3415. isDone: boolean;
  3416. /**
  3417. * Initializes the animation event
  3418. * @param frame The frame for which the event is triggered
  3419. * @param action The event to perform when triggered
  3420. * @param onlyOnce Specifies if the event should be triggered only once
  3421. */
  3422. constructor(
  3423. /** The frame for which the event is triggered **/
  3424. frame: number,
  3425. /** The event to perform when triggered **/
  3426. action: () => void,
  3427. /** Specifies if the event should be triggered only once**/
  3428. onlyOnce?: boolean | undefined);
  3429. /** @hidden */
  3430. _clone(): AnimationEvent;
  3431. }
  3432. /**
  3433. * A cursor which tracks a point on a path
  3434. */
  3435. class PathCursor {
  3436. private path;
  3437. /**
  3438. * Stores path cursor callbacks for when an onchange event is triggered
  3439. */
  3440. private _onchange;
  3441. /**
  3442. * The value of the path cursor
  3443. */
  3444. value: number;
  3445. /**
  3446. * The animation array of the path cursor
  3447. */
  3448. animations: Animation[];
  3449. /**
  3450. * Initializes the path cursor
  3451. * @param path The path to track
  3452. */
  3453. constructor(path: Path2);
  3454. /**
  3455. * Gets the cursor point on the path
  3456. * @returns A point on the path cursor at the cursor location
  3457. */
  3458. getPoint(): Vector3;
  3459. /**
  3460. * Moves the cursor ahead by the step amount
  3461. * @param step The amount to move the cursor forward
  3462. * @returns This path cursor
  3463. */
  3464. moveAhead(step?: number): PathCursor;
  3465. /**
  3466. * Moves the cursor behind by the step amount
  3467. * @param step The amount to move the cursor back
  3468. * @returns This path cursor
  3469. */
  3470. moveBack(step?: number): PathCursor;
  3471. /**
  3472. * Moves the cursor by the step amount
  3473. * If the step amount is greater than one, an exception is thrown
  3474. * @param step The amount to move the cursor
  3475. * @returns This path cursor
  3476. */
  3477. move(step: number): PathCursor;
  3478. /**
  3479. * Ensures that the value is limited between zero and one
  3480. * @returns This path cursor
  3481. */
  3482. private ensureLimits();
  3483. /**
  3484. * Runs onchange callbacks on change (used by the animation engine)
  3485. * @returns This path cursor
  3486. */
  3487. private raiseOnChange();
  3488. /**
  3489. * Executes a function on change
  3490. * @param f A path cursor onchange callback
  3491. * @returns This path cursor
  3492. */
  3493. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3494. }
  3495. /**
  3496. * Defines an interface which represents an animation key frame
  3497. */
  3498. interface IAnimationKey {
  3499. /**
  3500. * Frame of the key frame
  3501. */
  3502. frame: number;
  3503. /**
  3504. * Value at the specifies key frame
  3505. */
  3506. value: any;
  3507. /**
  3508. * The input tangent for the cubic hermite spline
  3509. */
  3510. inTangent?: any;
  3511. /**
  3512. * The output tangent for the cubic hermite spline
  3513. */
  3514. outTangent?: any;
  3515. /**
  3516. * The animation interpolation type
  3517. */
  3518. interpolation?: AnimationKeyInterpolation;
  3519. }
  3520. /**
  3521. * Enum for the animation key frame interpolation type
  3522. */
  3523. enum AnimationKeyInterpolation {
  3524. /**
  3525. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3526. */
  3527. STEP = 1,
  3528. }
  3529. /**
  3530. * Class used to store any kind of animation
  3531. */
  3532. class Animation {
  3533. /**Name of the animation */
  3534. name: string;
  3535. /**Property to animate */
  3536. targetProperty: string;
  3537. /**The frames per second of the animation */
  3538. framePerSecond: number;
  3539. /**The data type of the animation */
  3540. dataType: number;
  3541. /**The loop mode of the animation */
  3542. loopMode: number | undefined;
  3543. /**Specifies if blending should be enabled */
  3544. enableBlending: boolean | undefined;
  3545. /**
  3546. * Use matrix interpolation instead of using direct key value when animating matrices
  3547. */
  3548. static AllowMatricesInterpolation: boolean;
  3549. /**
  3550. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3551. */
  3552. static AllowMatrixDecomposeForInterpolation: boolean;
  3553. /**
  3554. * Stores the key frames of the animation
  3555. */
  3556. private _keys;
  3557. /**
  3558. * Stores the easing function of the animation
  3559. */
  3560. private _easingFunction;
  3561. /**
  3562. * @hidden Internal use only
  3563. */
  3564. _runtimeAnimations: RuntimeAnimation[];
  3565. /**
  3566. * The set of event that will be linked to this animation
  3567. */
  3568. private _events;
  3569. /**
  3570. * Stores an array of target property paths
  3571. */
  3572. targetPropertyPath: string[];
  3573. /**
  3574. * Stores the blending speed of the animation
  3575. */
  3576. blendingSpeed: number;
  3577. /**
  3578. * Stores the animation ranges for the animation
  3579. */
  3580. private _ranges;
  3581. /**
  3582. * @hidden Internal use
  3583. */
  3584. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3585. /**
  3586. * Sets up an animation
  3587. * @param property The property to animate
  3588. * @param animationType The animation type to apply
  3589. * @param framePerSecond The frames per second of the animation
  3590. * @param easingFunction The easing function used in the animation
  3591. * @returns The created animation
  3592. */
  3593. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3594. /**
  3595. * Create and start an animation on a node
  3596. * @param name defines the name of the global animation that will be run on all nodes
  3597. * @param node defines the root node where the animation will take place
  3598. * @param targetProperty defines property to animate
  3599. * @param framePerSecond defines the number of frame per second yo use
  3600. * @param totalFrame defines the number of frames in total
  3601. * @param from defines the initial value
  3602. * @param to defines the final value
  3603. * @param loopMode defines which loop mode you want to use (off by default)
  3604. * @param easingFunction defines the easing function to use (linear by default)
  3605. * @param onAnimationEnd defines the callback to call when animation end
  3606. * @returns the animatable created for this animation
  3607. */
  3608. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3609. /**
  3610. * Create and start an animation on a node and its descendants
  3611. * @param name defines the name of the global animation that will be run on all nodes
  3612. * @param node defines the root node where the animation will take place
  3613. * @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
  3614. * @param targetProperty defines property to animate
  3615. * @param framePerSecond defines the number of frame per second to use
  3616. * @param totalFrame defines the number of frames in total
  3617. * @param from defines the initial value
  3618. * @param to defines the final value
  3619. * @param loopMode defines which loop mode you want to use (off by default)
  3620. * @param easingFunction defines the easing function to use (linear by default)
  3621. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3622. * @returns the list of animatables created for all nodes
  3623. * @example https://www.babylonjs-playground.com/#MH0VLI
  3624. */
  3625. 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[]>;
  3626. /**
  3627. * Creates a new animation, merges it with the existing animations and starts it
  3628. * @param name Name of the animation
  3629. * @param node Node which contains the scene that begins the animations
  3630. * @param targetProperty Specifies which property to animate
  3631. * @param framePerSecond The frames per second of the animation
  3632. * @param totalFrame The total number of frames
  3633. * @param from The frame at the beginning of the animation
  3634. * @param to The frame at the end of the animation
  3635. * @param loopMode Specifies the loop mode of the animation
  3636. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3637. * @param onAnimationEnd Callback to run once the animation is complete
  3638. * @returns Nullable animation
  3639. */
  3640. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3641. /**
  3642. * Transition property of the Camera to the target Value
  3643. * @param property The property to transition
  3644. * @param targetValue The target Value of the property
  3645. * @param host The object where the property to animate belongs
  3646. * @param scene Scene used to run the animation
  3647. * @param frameRate Framerate (in frame/s) to use
  3648. * @param transition The transition type we want to use
  3649. * @param duration The duration of the animation, in milliseconds
  3650. * @param onAnimationEnd Callback trigger at the end of the animation
  3651. * @returns Nullable animation
  3652. */
  3653. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3654. /**
  3655. * Return the array of runtime animations currently using this animation
  3656. */
  3657. readonly runtimeAnimations: RuntimeAnimation[];
  3658. /**
  3659. * Specifies if any of the runtime animations are currently running
  3660. */
  3661. readonly hasRunningRuntimeAnimations: boolean;
  3662. /**
  3663. * Initializes the animation
  3664. * @param name Name of the animation
  3665. * @param targetProperty Property to animate
  3666. * @param framePerSecond The frames per second of the animation
  3667. * @param dataType The data type of the animation
  3668. * @param loopMode The loop mode of the animation
  3669. * @param enableBlendings Specifies if blending should be enabled
  3670. */
  3671. constructor(
  3672. /**Name of the animation */
  3673. name: string,
  3674. /**Property to animate */
  3675. targetProperty: string,
  3676. /**The frames per second of the animation */
  3677. framePerSecond: number,
  3678. /**The data type of the animation */
  3679. dataType: number,
  3680. /**The loop mode of the animation */
  3681. loopMode?: number | undefined,
  3682. /**Specifies if blending should be enabled */
  3683. enableBlending?: boolean | undefined);
  3684. /**
  3685. * Converts the animation to a string
  3686. * @param fullDetails support for multiple levels of logging within scene loading
  3687. * @returns String form of the animation
  3688. */
  3689. toString(fullDetails?: boolean): string;
  3690. /**
  3691. * Add an event to this animation
  3692. * @param event Event to add
  3693. */
  3694. addEvent(event: AnimationEvent): void;
  3695. /**
  3696. * Remove all events found at the given frame
  3697. * @param frame The frame to remove events from
  3698. */
  3699. removeEvents(frame: number): void;
  3700. /**
  3701. * Retrieves all the events from the animation
  3702. * @returns Events from the animation
  3703. */
  3704. getEvents(): AnimationEvent[];
  3705. /**
  3706. * Creates an animation range
  3707. * @param name Name of the animation range
  3708. * @param from Starting frame of the animation range
  3709. * @param to Ending frame of the animation
  3710. */
  3711. createRange(name: string, from: number, to: number): void;
  3712. /**
  3713. * Deletes an animation range by name
  3714. * @param name Name of the animation range to delete
  3715. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3716. */
  3717. deleteRange(name: string, deleteFrames?: boolean): void;
  3718. /**
  3719. * Gets the animation range by name, or null if not defined
  3720. * @param name Name of the animation range
  3721. * @returns Nullable animation range
  3722. */
  3723. getRange(name: string): Nullable<AnimationRange>;
  3724. /**
  3725. * Gets the key frames from the animation
  3726. * @returns The key frames of the animation
  3727. */
  3728. getKeys(): Array<IAnimationKey>;
  3729. /**
  3730. * Gets the highest frame rate of the animation
  3731. * @returns Highest frame rate of the animation
  3732. */
  3733. getHighestFrame(): number;
  3734. /**
  3735. * Gets the easing function of the animation
  3736. * @returns Easing function of the animation
  3737. */
  3738. getEasingFunction(): IEasingFunction;
  3739. /**
  3740. * Sets the easing function of the animation
  3741. * @param easingFunction A custom mathematical formula for animation
  3742. */
  3743. setEasingFunction(easingFunction: EasingFunction): void;
  3744. /**
  3745. * Interpolates a scalar linearly
  3746. * @param startValue Start value of the animation curve
  3747. * @param endValue End value of the animation curve
  3748. * @param gradient Scalar amount to interpolate
  3749. * @returns Interpolated scalar value
  3750. */
  3751. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3752. /**
  3753. * Interpolates a scalar cubically
  3754. * @param startValue Start value of the animation curve
  3755. * @param outTangent End tangent of the animation
  3756. * @param endValue End value of the animation curve
  3757. * @param inTangent Start tangent of the animation curve
  3758. * @param gradient Scalar amount to interpolate
  3759. * @returns Interpolated scalar value
  3760. */
  3761. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3762. /**
  3763. * Interpolates a quaternion using a spherical linear interpolation
  3764. * @param startValue Start value of the animation curve
  3765. * @param endValue End value of the animation curve
  3766. * @param gradient Scalar amount to interpolate
  3767. * @returns Interpolated quaternion value
  3768. */
  3769. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3770. /**
  3771. * Interpolates a quaternion cubically
  3772. * @param startValue Start value of the animation curve
  3773. * @param outTangent End tangent of the animation curve
  3774. * @param endValue End value of the animation curve
  3775. * @param inTangent Start tangent of the animation curve
  3776. * @param gradient Scalar amount to interpolate
  3777. * @returns Interpolated quaternion value
  3778. */
  3779. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3780. /**
  3781. * Interpolates a Vector3 linearl
  3782. * @param startValue Start value of the animation curve
  3783. * @param endValue End value of the animation curve
  3784. * @param gradient Scalar amount to interpolate
  3785. * @returns Interpolated scalar value
  3786. */
  3787. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3788. /**
  3789. * Interpolates a Vector3 cubically
  3790. * @param startValue Start value of the animation curve
  3791. * @param outTangent End tangent of the animation
  3792. * @param endValue End value of the animation curve
  3793. * @param inTangent Start tangent of the animation curve
  3794. * @param gradient Scalar amount to interpolate
  3795. * @returns InterpolatedVector3 value
  3796. */
  3797. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3798. /**
  3799. * Interpolates a Vector2 linearly
  3800. * @param startValue Start value of the animation curve
  3801. * @param endValue End value of the animation curve
  3802. * @param gradient Scalar amount to interpolate
  3803. * @returns Interpolated Vector2 value
  3804. */
  3805. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3806. /**
  3807. * Interpolates a Vector2 cubically
  3808. * @param startValue Start value of the animation curve
  3809. * @param outTangent End tangent of the animation
  3810. * @param endValue End value of the animation curve
  3811. * @param inTangent Start tangent of the animation curve
  3812. * @param gradient Scalar amount to interpolate
  3813. * @returns Interpolated Vector2 value
  3814. */
  3815. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  3816. /**
  3817. * Interpolates a size linearly
  3818. * @param startValue Start value of the animation curve
  3819. * @param endValue End value of the animation curve
  3820. * @param gradient Scalar amount to interpolate
  3821. * @returns Interpolated Size value
  3822. */
  3823. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  3824. /**
  3825. * Interpolates a Color3 linearly
  3826. * @param startValue Start value of the animation curve
  3827. * @param endValue End value of the animation curve
  3828. * @param gradient Scalar amount to interpolate
  3829. * @returns Interpolated Color3 value
  3830. */
  3831. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  3832. /**
  3833. * @hidden Internal use only
  3834. */
  3835. _getKeyValue(value: any): any;
  3836. /**
  3837. * @hidden Internal use only
  3838. */
  3839. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  3840. /**
  3841. * Defines the function to use to interpolate matrices
  3842. * @param startValue defines the start matrix
  3843. * @param endValue defines the end matrix
  3844. * @param gradient defines the gradient between both matrices
  3845. * @param result defines an optional target matrix where to store the interpolation
  3846. * @returns the interpolated matrix
  3847. */
  3848. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  3849. /**
  3850. * Makes a copy of the animation
  3851. * @returns Cloned animation
  3852. */
  3853. clone(): Animation;
  3854. /**
  3855. * Sets the key frames of the animation
  3856. * @param values The animation key frames to set
  3857. */
  3858. setKeys(values: Array<IAnimationKey>): void;
  3859. /**
  3860. * Serializes the animation to an object
  3861. * @returns Serialized object
  3862. */
  3863. serialize(): any;
  3864. /**
  3865. * Float animation type
  3866. */
  3867. private static _ANIMATIONTYPE_FLOAT;
  3868. /**
  3869. * Vector3 animation type
  3870. */
  3871. private static _ANIMATIONTYPE_VECTOR3;
  3872. /**
  3873. * Quaternion animation type
  3874. */
  3875. private static _ANIMATIONTYPE_QUATERNION;
  3876. /**
  3877. * Matrix animation type
  3878. */
  3879. private static _ANIMATIONTYPE_MATRIX;
  3880. /**
  3881. * Color3 animation type
  3882. */
  3883. private static _ANIMATIONTYPE_COLOR3;
  3884. /**
  3885. * Vector2 animation type
  3886. */
  3887. private static _ANIMATIONTYPE_VECTOR2;
  3888. /**
  3889. * Size animation type
  3890. */
  3891. private static _ANIMATIONTYPE_SIZE;
  3892. /**
  3893. * Relative Loop Mode
  3894. */
  3895. private static _ANIMATIONLOOPMODE_RELATIVE;
  3896. /**
  3897. * Cycle Loop Mode
  3898. */
  3899. private static _ANIMATIONLOOPMODE_CYCLE;
  3900. /**
  3901. * Constant Loop Mode
  3902. */
  3903. private static _ANIMATIONLOOPMODE_CONSTANT;
  3904. /**
  3905. * Get the float animation type
  3906. */
  3907. static readonly ANIMATIONTYPE_FLOAT: number;
  3908. /**
  3909. * Get the Vector3 animation type
  3910. */
  3911. static readonly ANIMATIONTYPE_VECTOR3: number;
  3912. /**
  3913. * Get the Vectpr2 animation type
  3914. */
  3915. static readonly ANIMATIONTYPE_VECTOR2: number;
  3916. /**
  3917. * Get the Size animation type
  3918. */
  3919. static readonly ANIMATIONTYPE_SIZE: number;
  3920. /**
  3921. * Get the Quaternion animation type
  3922. */
  3923. static readonly ANIMATIONTYPE_QUATERNION: number;
  3924. /**
  3925. * Get the Matrix animation type
  3926. */
  3927. static readonly ANIMATIONTYPE_MATRIX: number;
  3928. /**
  3929. * Get the Color3 animation type
  3930. */
  3931. static readonly ANIMATIONTYPE_COLOR3: number;
  3932. /**
  3933. * Get the Relative Loop Mode
  3934. */
  3935. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  3936. /**
  3937. * Get the Cycle Loop Mode
  3938. */
  3939. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  3940. /**
  3941. * Get the Constant Loop Mode
  3942. */
  3943. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  3944. /** @hidden */
  3945. static _UniversalLerp(left: any, right: any, amount: number): any;
  3946. /**
  3947. * Parses an animation object and creates an animation
  3948. * @param parsedAnimation Parsed animation object
  3949. * @returns Animation object
  3950. */
  3951. static Parse(parsedAnimation: any): Animation;
  3952. /**
  3953. * Appends the serialized animations from the source animations
  3954. * @param source Source containing the animations
  3955. * @param destination Target to store the animations
  3956. */
  3957. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  3958. }
  3959. }
  3960. declare module BABYLON {
  3961. /**
  3962. * This class defines the direct association between an animation and a target
  3963. */
  3964. class TargetedAnimation {
  3965. animation: Animation;
  3966. target: any;
  3967. }
  3968. /**
  3969. * Use this class to create coordinated animations on multiple targets
  3970. */
  3971. class AnimationGroup implements IDisposable {
  3972. name: string;
  3973. private _scene;
  3974. private _targetedAnimations;
  3975. private _animatables;
  3976. private _from;
  3977. private _to;
  3978. private _isStarted;
  3979. private _speedRatio;
  3980. onAnimationEndObservable: Observable<TargetedAnimation>;
  3981. /**
  3982. * Gets the first frame
  3983. */
  3984. readonly from: number;
  3985. /**
  3986. * Gets the last frame
  3987. */
  3988. readonly to: number;
  3989. /**
  3990. * Define if the animations are started
  3991. */
  3992. readonly isStarted: boolean;
  3993. /**
  3994. * Gets or sets the speed ratio to use for all animations
  3995. */
  3996. /**
  3997. * Gets or sets the speed ratio to use for all animations
  3998. */
  3999. speedRatio: number;
  4000. /**
  4001. * Gets the targeted animations for this animation group
  4002. */
  4003. readonly targetedAnimations: Array<TargetedAnimation>;
  4004. /**
  4005. * returning the list of animatables controlled by this animation group.
  4006. */
  4007. readonly animatables: Array<Animatable>;
  4008. constructor(name: string, scene?: Nullable<Scene>);
  4009. /**
  4010. * Add an animation (with its target) in the group
  4011. * @param animation defines the animation we want to add
  4012. * @param target defines the target of the animation
  4013. * @returns the {BABYLON.TargetedAnimation} object
  4014. */
  4015. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4016. /**
  4017. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4018. * It can add constant keys at begin or end
  4019. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4020. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4021. */
  4022. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4023. /**
  4024. * Start all animations on given targets
  4025. * @param loop defines if animations must loop
  4026. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4027. * @param from defines the from key (optional)
  4028. * @param to defines the to key (optional)
  4029. * @returns the current animation group
  4030. */
  4031. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4032. /**
  4033. * Pause all animations
  4034. */
  4035. pause(): AnimationGroup;
  4036. /**
  4037. * Play all animations to initial state
  4038. * This function will start() the animations if they were not started or will restart() them if they were paused
  4039. * @param loop defines if animations must loop
  4040. */
  4041. play(loop?: boolean): AnimationGroup;
  4042. /**
  4043. * Reset all animations to initial state
  4044. */
  4045. reset(): AnimationGroup;
  4046. /**
  4047. * Restart animations from key 0
  4048. */
  4049. restart(): AnimationGroup;
  4050. /**
  4051. * Stop all animations
  4052. */
  4053. stop(): AnimationGroup;
  4054. /**
  4055. * Set animation weight for all animatables
  4056. * @param weight defines the weight to use
  4057. * @return the animationGroup
  4058. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4059. */
  4060. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4061. /**
  4062. * Synchronize and normalize all animatables with a source animatable
  4063. * @param root defines the root animatable to synchronize with
  4064. * @return the animationGroup
  4065. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4066. */
  4067. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4068. /**
  4069. * Goes to a specific frame in this animation group
  4070. * @param frame the frame number to go to
  4071. * @return the animationGroup
  4072. */
  4073. goToFrame(frame: number): AnimationGroup;
  4074. /**
  4075. * Dispose all associated resources
  4076. */
  4077. dispose(): void;
  4078. }
  4079. }
  4080. declare module BABYLON {
  4081. /**
  4082. * Class used to override all child animations of a given target
  4083. */
  4084. class AnimationPropertiesOverride {
  4085. /**
  4086. * Gets or sets a value indicating if animation blending must be used
  4087. */
  4088. enableBlending: boolean;
  4089. /**
  4090. * Gets or sets the blending speed to use when enableBlending is true
  4091. */
  4092. blendingSpeed: number;
  4093. /**
  4094. * Gets or sets the default loop mode to use
  4095. */
  4096. loopMode: number;
  4097. }
  4098. }
  4099. declare module BABYLON {
  4100. interface IEasingFunction {
  4101. ease(gradient: number): number;
  4102. }
  4103. class EasingFunction implements IEasingFunction {
  4104. private static _EASINGMODE_EASEIN;
  4105. private static _EASINGMODE_EASEOUT;
  4106. private static _EASINGMODE_EASEINOUT;
  4107. static readonly EASINGMODE_EASEIN: number;
  4108. static readonly EASINGMODE_EASEOUT: number;
  4109. static readonly EASINGMODE_EASEINOUT: number;
  4110. private _easingMode;
  4111. setEasingMode(easingMode: number): void;
  4112. getEasingMode(): number;
  4113. easeInCore(gradient: number): number;
  4114. ease(gradient: number): number;
  4115. }
  4116. class CircleEase extends EasingFunction implements IEasingFunction {
  4117. easeInCore(gradient: number): number;
  4118. }
  4119. class BackEase extends EasingFunction implements IEasingFunction {
  4120. amplitude: number;
  4121. constructor(amplitude?: number);
  4122. easeInCore(gradient: number): number;
  4123. }
  4124. class BounceEase extends EasingFunction implements IEasingFunction {
  4125. bounces: number;
  4126. bounciness: number;
  4127. constructor(bounces?: number, bounciness?: number);
  4128. easeInCore(gradient: number): number;
  4129. }
  4130. class CubicEase extends EasingFunction implements IEasingFunction {
  4131. easeInCore(gradient: number): number;
  4132. }
  4133. class ElasticEase extends EasingFunction implements IEasingFunction {
  4134. oscillations: number;
  4135. springiness: number;
  4136. constructor(oscillations?: number, springiness?: number);
  4137. easeInCore(gradient: number): number;
  4138. }
  4139. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4140. exponent: number;
  4141. constructor(exponent?: number);
  4142. easeInCore(gradient: number): number;
  4143. }
  4144. class PowerEase extends EasingFunction implements IEasingFunction {
  4145. power: number;
  4146. constructor(power?: number);
  4147. easeInCore(gradient: number): number;
  4148. }
  4149. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4150. easeInCore(gradient: number): number;
  4151. }
  4152. class QuarticEase extends EasingFunction implements IEasingFunction {
  4153. easeInCore(gradient: number): number;
  4154. }
  4155. class QuinticEase extends EasingFunction implements IEasingFunction {
  4156. easeInCore(gradient: number): number;
  4157. }
  4158. class SineEase extends EasingFunction implements IEasingFunction {
  4159. easeInCore(gradient: number): number;
  4160. }
  4161. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4162. x1: number;
  4163. y1: number;
  4164. x2: number;
  4165. y2: number;
  4166. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4167. easeInCore(gradient: number): number;
  4168. }
  4169. }
  4170. declare module BABYLON {
  4171. /**
  4172. * Defines a runtime animation
  4173. */
  4174. class RuntimeAnimation {
  4175. private _events;
  4176. /**
  4177. * The current frame of the runtime animation
  4178. */
  4179. private _currentFrame;
  4180. /**
  4181. * The animation used by the runtime animation
  4182. */
  4183. private _animation;
  4184. /**
  4185. * The target of the runtime animation
  4186. */
  4187. private _target;
  4188. /**
  4189. * The initiating animatable
  4190. */
  4191. private _host;
  4192. /**
  4193. * The original value of the runtime animation
  4194. */
  4195. private _originalValue;
  4196. /**
  4197. * The original blend value of the runtime animation
  4198. */
  4199. private _originalBlendValue;
  4200. /**
  4201. * The offsets cache of the runtime animation
  4202. */
  4203. private _offsetsCache;
  4204. /**
  4205. * The high limits cache of the runtime animation
  4206. */
  4207. private _highLimitsCache;
  4208. /**
  4209. * Specifies if the runtime animation has been stopped
  4210. */
  4211. private _stopped;
  4212. /**
  4213. * The blending factor of the runtime animation
  4214. */
  4215. private _blendingFactor;
  4216. /**
  4217. * The BabylonJS scene
  4218. */
  4219. private _scene;
  4220. /**
  4221. * The current value of the runtime animation
  4222. */
  4223. private _currentValue;
  4224. /** @hidden */
  4225. _workValue: any;
  4226. /**
  4227. * The active target of the runtime animation
  4228. */
  4229. private _activeTarget;
  4230. /**
  4231. * The target path of the runtime animation
  4232. */
  4233. private _targetPath;
  4234. /**
  4235. * The weight of the runtime animation
  4236. */
  4237. private _weight;
  4238. /**
  4239. * The ratio offset of the runtime animation
  4240. */
  4241. private _ratioOffset;
  4242. /**
  4243. * The previous delay of the runtime animation
  4244. */
  4245. private _previousDelay;
  4246. /**
  4247. * The previous ratio of the runtime animation
  4248. */
  4249. private _previousRatio;
  4250. /**
  4251. * Gets the current frame of the runtime animation
  4252. */
  4253. readonly currentFrame: number;
  4254. /**
  4255. * Gets the weight of the runtime animation
  4256. */
  4257. readonly weight: number;
  4258. /**
  4259. * Gets the current value of the runtime animation
  4260. */
  4261. readonly currentValue: any;
  4262. /**
  4263. * Gets the target path of the runtime animation
  4264. */
  4265. readonly targetPath: string;
  4266. /**
  4267. * Gets the actual target of the runtime animation
  4268. */
  4269. readonly target: any;
  4270. /**
  4271. * Create a new RuntimeAnimation object
  4272. * @param target defines the target of the animation
  4273. * @param animation defines the source animation object
  4274. * @param scene defines the hosting scene
  4275. * @param host defines the initiating Animatable
  4276. */
  4277. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4278. /**
  4279. * Gets the animation from the runtime animation
  4280. */
  4281. readonly animation: Animation;
  4282. /**
  4283. * Resets the runtime animation to the beginning
  4284. * @param restoreOriginal defines whether to restore the target property to the original value
  4285. */
  4286. reset(restoreOriginal?: boolean): void;
  4287. /**
  4288. * Specifies if the runtime animation is stopped
  4289. * @returns Boolean specifying if the runtime animation is stopped
  4290. */
  4291. isStopped(): boolean;
  4292. /**
  4293. * Disposes of the runtime animation
  4294. */
  4295. dispose(): void;
  4296. /**
  4297. * Interpolates the animation from the current frame
  4298. * @param currentFrame The frame to interpolate the animation to
  4299. * @param repeatCount The number of times that the animation should loop
  4300. * @param loopMode The type of looping mode to use
  4301. * @param offsetValue Animation offset value
  4302. * @param highLimitValue The high limit value
  4303. * @returns The interpolated value
  4304. */
  4305. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  4306. /**
  4307. * Apply the interpolated value to the target
  4308. * @param currentValue defines the value computed by the animation
  4309. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4310. */
  4311. setValue(currentValue: any, weight?: number): void;
  4312. private _setValue(target, currentValue, weight, targetIndex?);
  4313. /**
  4314. * Gets the loop pmode of the runtime animation
  4315. * @returns Loop Mode
  4316. */
  4317. private _getCorrectLoopMode();
  4318. /**
  4319. * Move the current animation to a given frame
  4320. * @param frame defines the frame to move to
  4321. */
  4322. goToFrame(frame: number): void;
  4323. /**
  4324. * @hidden Internal use only
  4325. */
  4326. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4327. /**
  4328. * Execute the current animation
  4329. * @param delay defines the delay to add to the current frame
  4330. * @param from defines the lower bound of the animation range
  4331. * @param to defines the upper bound of the animation range
  4332. * @param loop defines if the current animation must loop
  4333. * @param speedRatio defines the current speed ratio
  4334. * @param weight defines the weight of the animation (default is -1 so no weight)
  4335. * @returns a boolean indicating if the animation has ended
  4336. */
  4337. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4338. }
  4339. }
  4340. declare module BABYLON {
  4341. /**
  4342. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4343. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4344. */
  4345. class Analyser {
  4346. /**
  4347. * Gets or sets the smoothing
  4348. * @ignorenaming
  4349. */
  4350. SMOOTHING: number;
  4351. /**
  4352. * Gets or sets the FFT table size
  4353. * @ignorenaming
  4354. */
  4355. FFT_SIZE: number;
  4356. /**
  4357. * Gets or sets the bar graph amplitude
  4358. * @ignorenaming
  4359. */
  4360. BARGRAPHAMPLITUDE: number;
  4361. /**
  4362. * Gets or sets the position of the debug canvas
  4363. * @ignorenaming
  4364. */
  4365. DEBUGCANVASPOS: {
  4366. x: number;
  4367. y: number;
  4368. };
  4369. /**
  4370. * Gets or sets the debug canvas size
  4371. * @ignorenaming
  4372. */
  4373. DEBUGCANVASSIZE: {
  4374. width: number;
  4375. height: number;
  4376. };
  4377. private _byteFreqs;
  4378. private _byteTime;
  4379. private _floatFreqs;
  4380. private _webAudioAnalyser;
  4381. private _debugCanvas;
  4382. private _debugCanvasContext;
  4383. private _scene;
  4384. private _registerFunc;
  4385. private _audioEngine;
  4386. /**
  4387. * Creates a new analyser
  4388. * @param scene defines hosting scene
  4389. */
  4390. constructor(scene: Scene);
  4391. /**
  4392. * Get the number of data values you will have to play with for the visualization
  4393. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4394. * @returns a number
  4395. */
  4396. getFrequencyBinCount(): number;
  4397. /**
  4398. * Gets the current frequency data as a byte array
  4399. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4400. * @returns a Uint8Array
  4401. */
  4402. getByteFrequencyData(): Uint8Array;
  4403. /**
  4404. * Gets the current waveform as a byte array
  4405. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4406. * @returns a Uint8Array
  4407. */
  4408. getByteTimeDomainData(): Uint8Array;
  4409. /**
  4410. * Gets the current frequency data as a float array
  4411. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4412. * @returns a Float32Array
  4413. */
  4414. getFloatFrequencyData(): Float32Array;
  4415. /**
  4416. * Renders the debug canvas
  4417. */
  4418. drawDebugCanvas(): void;
  4419. /**
  4420. * Stops rendering the debug canvas and removes it
  4421. */
  4422. stopDebugCanvas(): void;
  4423. /**
  4424. * Connects two audio nodes
  4425. * @param inputAudioNode defines first node to connect
  4426. * @param outputAudioNode defines second node to connect
  4427. */
  4428. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4429. /**
  4430. * Releases all associated resources
  4431. */
  4432. dispose(): void;
  4433. }
  4434. }
  4435. declare module BABYLON {
  4436. class AudioEngine {
  4437. private _audioContext;
  4438. private _audioContextInitialized;
  4439. canUseWebAudio: boolean;
  4440. masterGain: GainNode;
  4441. private _connectedAnalyser;
  4442. WarnedWebAudioUnsupported: boolean;
  4443. unlocked: boolean;
  4444. onAudioUnlocked: () => any;
  4445. isMP3supported: boolean;
  4446. isOGGsupported: boolean;
  4447. readonly audioContext: Nullable<AudioContext>;
  4448. constructor();
  4449. private _unlockiOSaudio();
  4450. private _initializeAudioContext();
  4451. dispose(): void;
  4452. getGlobalVolume(): number;
  4453. setGlobalVolume(newVolume: number): void;
  4454. connectToAnalyser(analyser: Analyser): void;
  4455. }
  4456. }
  4457. declare module BABYLON {
  4458. class Sound {
  4459. name: string;
  4460. autoplay: boolean;
  4461. loop: boolean;
  4462. useCustomAttenuation: boolean;
  4463. soundTrackId: number;
  4464. spatialSound: boolean;
  4465. refDistance: number;
  4466. rolloffFactor: number;
  4467. maxDistance: number;
  4468. distanceModel: string;
  4469. private _panningModel;
  4470. onended: () => any;
  4471. private _playbackRate;
  4472. private _streaming;
  4473. private _startTime;
  4474. private _startOffset;
  4475. private _position;
  4476. private _localDirection;
  4477. private _volume;
  4478. private _isReadyToPlay;
  4479. isPlaying: boolean;
  4480. isPaused: boolean;
  4481. private _isDirectional;
  4482. private _readyToPlayCallback;
  4483. private _audioBuffer;
  4484. private _soundSource;
  4485. private _streamingSource;
  4486. private _soundPanner;
  4487. private _soundGain;
  4488. private _inputAudioNode;
  4489. private _ouputAudioNode;
  4490. private _coneInnerAngle;
  4491. private _coneOuterAngle;
  4492. private _coneOuterGain;
  4493. private _scene;
  4494. private _connectedMesh;
  4495. private _customAttenuationFunction;
  4496. private _registerFunc;
  4497. private _isOutputConnected;
  4498. private _htmlAudioElement;
  4499. private _urlType;
  4500. /**
  4501. * Create a sound and attach it to a scene
  4502. * @param name Name of your sound
  4503. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  4504. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4505. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4506. */
  4507. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4508. dispose(): void;
  4509. isReady(): boolean;
  4510. private _soundLoaded(audioData);
  4511. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4512. updateOptions(options: any): void;
  4513. private _createSpatialParameters();
  4514. private _updateSpatialParameters();
  4515. switchPanningModelToHRTF(): void;
  4516. switchPanningModelToEqualPower(): void;
  4517. private _switchPanningModel();
  4518. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4519. /**
  4520. * Transform this sound into a directional source
  4521. * @param coneInnerAngle Size of the inner cone in degree
  4522. * @param coneOuterAngle Size of the outer cone in degree
  4523. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4524. */
  4525. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4526. setPosition(newPosition: Vector3): void;
  4527. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4528. private _updateDirection();
  4529. updateDistanceFromListener(): void;
  4530. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4531. /**
  4532. * Play the sound
  4533. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4534. * @param offset (optional) Start the sound setting it at a specific time
  4535. */
  4536. play(time?: number, offset?: number): void;
  4537. private _onended();
  4538. /**
  4539. * Stop the sound
  4540. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4541. */
  4542. stop(time?: number): void;
  4543. pause(): void;
  4544. setVolume(newVolume: number, time?: number): void;
  4545. setPlaybackRate(newPlaybackRate: number): void;
  4546. getVolume(): number;
  4547. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4548. detachFromMesh(): void;
  4549. private _onRegisterAfterWorldMatrixUpdate(node);
  4550. clone(): Nullable<Sound>;
  4551. getAudioBuffer(): AudioBuffer | null;
  4552. serialize(): any;
  4553. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4554. }
  4555. }
  4556. declare module BABYLON {
  4557. class SoundTrack {
  4558. private _outputAudioNode;
  4559. private _scene;
  4560. id: number;
  4561. soundCollection: Array<Sound>;
  4562. private _isMainTrack;
  4563. private _connectedAnalyser;
  4564. private _options;
  4565. private _isInitialized;
  4566. constructor(scene: Scene, options?: any);
  4567. private _initializeSoundTrackAudioGraph();
  4568. dispose(): void;
  4569. AddSound(sound: Sound): void;
  4570. RemoveSound(sound: Sound): void;
  4571. setVolume(newVolume: number): void;
  4572. switchPanningModelToHRTF(): void;
  4573. switchPanningModelToEqualPower(): void;
  4574. connectToAnalyser(analyser: Analyser): void;
  4575. }
  4576. }
  4577. declare module BABYLON {
  4578. interface Behavior<T extends Node> {
  4579. name: string;
  4580. init(): void;
  4581. attach(node: T): void;
  4582. detach(): void;
  4583. }
  4584. }
  4585. declare module BABYLON {
  4586. /**
  4587. * Class used to store bone information
  4588. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4589. */
  4590. class Bone extends Node {
  4591. /**
  4592. * defines the bone name
  4593. */
  4594. name: string;
  4595. private static _tmpVecs;
  4596. private static _tmpQuat;
  4597. private static _tmpMats;
  4598. /**
  4599. * Gets the list of child bones
  4600. */
  4601. children: Bone[];
  4602. /** Gets the animations associated with this bone */
  4603. animations: Animation[];
  4604. /**
  4605. * Gets or sets bone length
  4606. */
  4607. length: number;
  4608. /**
  4609. * @hidden Internal only
  4610. * Set this value to map this bone to a different index in the transform matrices
  4611. * Set this value to -1 to exclude the bone from the transform matrices
  4612. */
  4613. _index: Nullable<number>;
  4614. private _skeleton;
  4615. private _localMatrix;
  4616. private _restPose;
  4617. private _baseMatrix;
  4618. private _absoluteTransform;
  4619. private _invertedAbsoluteTransform;
  4620. private _parent;
  4621. private _scalingDeterminant;
  4622. private _worldTransform;
  4623. private _localScaling;
  4624. private _localRotation;
  4625. private _localPosition;
  4626. private _needToDecompose;
  4627. private _needToCompose;
  4628. /** @hidden */
  4629. /** @hidden */
  4630. _matrix: Matrix;
  4631. /**
  4632. * Create a new bone
  4633. * @param name defines the bone name
  4634. * @param skeleton defines the parent skeleton
  4635. * @param parentBone defines the parent (can be null if the bone is the root)
  4636. * @param localMatrix defines the local matrix
  4637. * @param restPose defines the rest pose matrix
  4638. * @param baseMatrix defines the base matrix
  4639. * @param index defines index of the bone in the hiearchy
  4640. */
  4641. constructor(
  4642. /**
  4643. * defines the bone name
  4644. */
  4645. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4646. /**
  4647. * Gets the parent skeleton
  4648. * @returns a skeleton
  4649. */
  4650. getSkeleton(): Skeleton;
  4651. /**
  4652. * Gets parent bone
  4653. * @returns a bone or null if the bone is the root of the bone hierarchy
  4654. */
  4655. getParent(): Nullable<Bone>;
  4656. /**
  4657. * Sets the parent bone
  4658. * @param parent defines the parent (can be null if the bone is the root)
  4659. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4660. */
  4661. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4662. /**
  4663. * Gets the local matrix
  4664. * @returns a matrix
  4665. */
  4666. getLocalMatrix(): Matrix;
  4667. /**
  4668. * Gets the base matrix (initial matrix which remains unchanged)
  4669. * @returns a matrix
  4670. */
  4671. getBaseMatrix(): Matrix;
  4672. /**
  4673. * Gets the rest pose matrix
  4674. * @returns a matrix
  4675. */
  4676. getRestPose(): Matrix;
  4677. /**
  4678. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  4679. */
  4680. getWorldMatrix(): Matrix;
  4681. /**
  4682. * Sets the local matrix to rest pose matrix
  4683. */
  4684. returnToRest(): void;
  4685. /**
  4686. * Gets the inverse of the absolute transform matrix.
  4687. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  4688. * @returns a matrix
  4689. */
  4690. getInvertedAbsoluteTransform(): Matrix;
  4691. /**
  4692. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  4693. * @returns a matrix
  4694. */
  4695. getAbsoluteTransform(): Matrix;
  4696. /** Gets or sets current position (in local space) */
  4697. position: Vector3;
  4698. /** Gets or sets current rotation (in local space) */
  4699. rotation: Vector3;
  4700. /** Gets or sets current rotation quaternion (in local space) */
  4701. rotationQuaternion: Quaternion;
  4702. /** Gets or sets current scaling (in local space) */
  4703. scaling: Vector3;
  4704. /**
  4705. * Gets the animation properties override
  4706. */
  4707. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4708. private _decompose();
  4709. private _compose();
  4710. /**
  4711. * Update the base and local matrices
  4712. * @param matrix defines the new base or local matrix
  4713. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4714. * @param updateLocalMatrix defines if the local matrix should be updated
  4715. */
  4716. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  4717. /** @hidden */
  4718. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  4719. /**
  4720. * Flag the bone as dirty (Forcing it to update everything)
  4721. */
  4722. markAsDirty(): void;
  4723. private _markAsDirtyAndCompose();
  4724. private _markAsDirtyAndDecompose();
  4725. /**
  4726. * Copy an animation range from another bone
  4727. * @param source defines the source bone
  4728. * @param rangeName defines the range name to copy
  4729. * @param frameOffset defines the frame offset
  4730. * @param rescaleAsRequired defines if rescaling must be applied if required
  4731. * @param skelDimensionsRatio defines the scaling ratio
  4732. * @returns true if operation was successful
  4733. */
  4734. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  4735. /**
  4736. * Translate the bone in local or world space
  4737. * @param vec The amount to translate the bone
  4738. * @param space The space that the translation is in
  4739. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4740. */
  4741. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4742. /**
  4743. * Set the postion of the bone in local or world space
  4744. * @param position The position to set the bone
  4745. * @param space The space that the position is in
  4746. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4747. */
  4748. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4749. /**
  4750. * Set the absolute position of the bone (world space)
  4751. * @param position The position to set the bone
  4752. * @param mesh The mesh that this bone is attached to
  4753. */
  4754. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  4755. /**
  4756. * Scale the bone on the x, y and z axes (in local space)
  4757. * @param x The amount to scale the bone on the x axis
  4758. * @param y The amount to scale the bone on the y axis
  4759. * @param z The amount to scale the bone on the z axis
  4760. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  4761. */
  4762. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  4763. /**
  4764. * Set the bone scaling in local space
  4765. * @param scale defines the scaling vector
  4766. */
  4767. setScale(scale: Vector3): void;
  4768. /**
  4769. * Gets the current scaling in local space
  4770. * @returns the current scaling vector
  4771. */
  4772. getScale(): Vector3;
  4773. /**
  4774. * Gets the current scaling in local space and stores it in a target vector
  4775. * @param result defines the target vector
  4776. */
  4777. getScaleToRef(result: Vector3): void;
  4778. /**
  4779. * Set the yaw, pitch, and roll of the bone in local or world space
  4780. * @param yaw The rotation of the bone on the y axis
  4781. * @param pitch The rotation of the bone on the x axis
  4782. * @param roll The rotation of the bone on the z axis
  4783. * @param space The space that the axes of rotation are in
  4784. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4785. */
  4786. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  4787. /**
  4788. * Add a rotation to the bone on an axis in local or world space
  4789. * @param axis The axis to rotate the bone on
  4790. * @param amount The amount to rotate the bone
  4791. * @param space The space that the axis is in
  4792. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4793. */
  4794. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  4795. /**
  4796. * Set the rotation of the bone to a particular axis angle in local or world space
  4797. * @param axis The axis to rotate the bone on
  4798. * @param angle The angle that the bone should be rotated to
  4799. * @param space The space that the axis is in
  4800. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4801. */
  4802. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  4803. /**
  4804. * Set the euler rotation of the bone in local of world space
  4805. * @param rotation The euler rotation that the bone should be set to
  4806. * @param space The space that the rotation is in
  4807. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4808. */
  4809. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4810. /**
  4811. * Set the quaternion rotation of the bone in local of world space
  4812. * @param quat The quaternion rotation that the bone should be set to
  4813. * @param space The space that the rotation is in
  4814. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4815. */
  4816. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  4817. /**
  4818. * Set the rotation matrix of the bone in local of world space
  4819. * @param rotMat The rotation matrix that the bone should be set to
  4820. * @param space The space that the rotation is in
  4821. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4822. */
  4823. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  4824. private _rotateWithMatrix(rmat, space?, mesh?);
  4825. private _getNegativeRotationToRef(rotMatInv, mesh?);
  4826. /**
  4827. * Get the position of the bone in local or world space
  4828. * @param space The space that the returned position is in
  4829. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4830. * @returns The position of the bone
  4831. */
  4832. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4833. /**
  4834. * Copy the position of the bone to a vector3 in local or world space
  4835. * @param space The space that the returned position is in
  4836. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4837. * @param result The vector3 to copy the position to
  4838. */
  4839. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  4840. /**
  4841. * Get the absolute position of the bone (world space)
  4842. * @param mesh The mesh that this bone is attached to
  4843. * @returns The absolute position of the bone
  4844. */
  4845. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  4846. /**
  4847. * Copy the absolute position of the bone (world space) to the result param
  4848. * @param mesh The mesh that this bone is attached to
  4849. * @param result The vector3 to copy the absolute position to
  4850. */
  4851. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  4852. /**
  4853. * Compute the absolute transforms of this bone and its children
  4854. */
  4855. computeAbsoluteTransforms(): void;
  4856. /**
  4857. * Get the world direction from an axis that is in the local space of the bone
  4858. * @param localAxis The local direction that is used to compute the world direction
  4859. * @param mesh The mesh that this bone is attached to
  4860. * @returns The world direction
  4861. */
  4862. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4863. /**
  4864. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  4865. * @param localAxis The local direction that is used to compute the world direction
  4866. * @param mesh The mesh that this bone is attached to
  4867. * @param result The vector3 that the world direction will be copied to
  4868. */
  4869. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4870. /**
  4871. * Get the euler rotation of the bone in local or world space
  4872. * @param space The space that the rotation should be in
  4873. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4874. * @returns The euler rotation
  4875. */
  4876. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4877. /**
  4878. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  4879. * @param space The space that the rotation should be in
  4880. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4881. * @param result The vector3 that the rotation should be copied to
  4882. */
  4883. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4884. /**
  4885. * Get the quaternion rotation of the bone in either local or world space
  4886. * @param space The space that the rotation should be in
  4887. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4888. * @returns The quaternion rotation
  4889. */
  4890. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  4891. /**
  4892. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  4893. * @param space The space that the rotation should be in
  4894. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4895. * @param result The quaternion that the rotation should be copied to
  4896. */
  4897. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  4898. /**
  4899. * Get the rotation matrix of the bone in local or world space
  4900. * @param space The space that the rotation should be in
  4901. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4902. * @returns The rotation matrix
  4903. */
  4904. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  4905. /**
  4906. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  4907. * @param space The space that the rotation should be in
  4908. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4909. * @param result The quaternion that the rotation should be copied to
  4910. */
  4911. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  4912. /**
  4913. * Get the world position of a point that is in the local space of the bone
  4914. * @param position The local position
  4915. * @param mesh The mesh that this bone is attached to
  4916. * @returns The world position
  4917. */
  4918. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4919. /**
  4920. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  4921. * @param position The local position
  4922. * @param mesh The mesh that this bone is attached to
  4923. * @param result The vector3 that the world position should be copied to
  4924. */
  4925. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4926. /**
  4927. * Get the local position of a point that is in world space
  4928. * @param position The world position
  4929. * @param mesh The mesh that this bone is attached to
  4930. * @returns The local position
  4931. */
  4932. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4933. /**
  4934. * Get the local position of a point that is in world space and copy it to the result param
  4935. * @param position The world position
  4936. * @param mesh The mesh that this bone is attached to
  4937. * @param result The vector3 that the local position should be copied to
  4938. */
  4939. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4940. }
  4941. }
  4942. declare module BABYLON {
  4943. /**
  4944. * Class used to apply inverse kinematics to bones
  4945. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  4946. */
  4947. class BoneIKController {
  4948. private static _tmpVecs;
  4949. private static _tmpQuat;
  4950. private static _tmpMats;
  4951. /**
  4952. * Gets or sets the target mesh
  4953. */
  4954. targetMesh: AbstractMesh;
  4955. /** Gets or sets the mesh used as pole */
  4956. poleTargetMesh: AbstractMesh;
  4957. /**
  4958. * Gets or sets the bone used as pole
  4959. */
  4960. poleTargetBone: Nullable<Bone>;
  4961. /**
  4962. * Gets or sets the target position
  4963. */
  4964. targetPosition: Vector3;
  4965. /**
  4966. * Gets or sets the pole target position
  4967. */
  4968. poleTargetPosition: Vector3;
  4969. /**
  4970. * Gets or sets the pole target local offset
  4971. */
  4972. poleTargetLocalOffset: Vector3;
  4973. /**
  4974. * Gets or sets the pole angle
  4975. */
  4976. poleAngle: number;
  4977. /**
  4978. * Gets or sets the mesh associated with the controller
  4979. */
  4980. mesh: AbstractMesh;
  4981. /**
  4982. * 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)
  4983. */
  4984. slerpAmount: number;
  4985. private _bone1Quat;
  4986. private _bone1Mat;
  4987. private _bone2Ang;
  4988. private _bone1;
  4989. private _bone2;
  4990. private _bone1Length;
  4991. private _bone2Length;
  4992. private _maxAngle;
  4993. private _maxReach;
  4994. private _rightHandedSystem;
  4995. private _bendAxis;
  4996. private _slerping;
  4997. private _adjustRoll;
  4998. /**
  4999. * Gets or sets maximum allowed angle
  5000. */
  5001. maxAngle: number;
  5002. /**
  5003. * Creates a new BoneIKController
  5004. * @param mesh defines the mesh to control
  5005. * @param bone defines the bone to control
  5006. * @param options defines options to set up the controller
  5007. */
  5008. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5009. targetMesh?: AbstractMesh;
  5010. poleTargetMesh?: AbstractMesh;
  5011. poleTargetBone?: Bone;
  5012. poleTargetLocalOffset?: Vector3;
  5013. poleAngle?: number;
  5014. bendAxis?: Vector3;
  5015. maxAngle?: number;
  5016. slerpAmount?: number;
  5017. });
  5018. private _setMaxAngle(ang);
  5019. /**
  5020. * Force the controller to update the bones
  5021. */
  5022. update(): void;
  5023. }
  5024. }
  5025. declare module BABYLON {
  5026. /**
  5027. * Class used to make a bone look toward a point in space
  5028. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5029. */
  5030. class BoneLookController {
  5031. private static _tmpVecs;
  5032. private static _tmpQuat;
  5033. private static _tmpMats;
  5034. /**
  5035. * The target Vector3 that the bone will look at
  5036. */
  5037. target: Vector3;
  5038. /**
  5039. * The mesh that the bone is attached to
  5040. */
  5041. mesh: AbstractMesh;
  5042. /**
  5043. * The bone that will be looking to the target
  5044. */
  5045. bone: Bone;
  5046. /**
  5047. * The up axis of the coordinate system that is used when the bone is rotated
  5048. */
  5049. upAxis: Vector3;
  5050. /**
  5051. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5052. */
  5053. upAxisSpace: Space;
  5054. /**
  5055. * Used to make an adjustment to the yaw of the bone
  5056. */
  5057. adjustYaw: number;
  5058. /**
  5059. * Used to make an adjustment to the pitch of the bone
  5060. */
  5061. adjustPitch: number;
  5062. /**
  5063. * Used to make an adjustment to the roll of the bone
  5064. */
  5065. adjustRoll: number;
  5066. /**
  5067. * 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)
  5068. */
  5069. slerpAmount: number;
  5070. private _minYaw;
  5071. private _maxYaw;
  5072. private _minPitch;
  5073. private _maxPitch;
  5074. private _minYawSin;
  5075. private _minYawCos;
  5076. private _maxYawSin;
  5077. private _maxYawCos;
  5078. private _midYawConstraint;
  5079. private _minPitchTan;
  5080. private _maxPitchTan;
  5081. private _boneQuat;
  5082. private _slerping;
  5083. private _transformYawPitch;
  5084. private _transformYawPitchInv;
  5085. private _firstFrameSkipped;
  5086. private _yawRange;
  5087. private _fowardAxis;
  5088. /**
  5089. * Gets or sets the minimum yaw angle that the bone can look to
  5090. */
  5091. minYaw: number;
  5092. /**
  5093. * Gets or sets the maximum yaw angle that the bone can look to
  5094. */
  5095. maxYaw: number;
  5096. /**
  5097. * Gets or sets the minimum pitch angle that the bone can look to
  5098. */
  5099. minPitch: number;
  5100. /**
  5101. * Gets or sets the maximum pitch angle that the bone can look to
  5102. */
  5103. maxPitch: number;
  5104. /**
  5105. * Create a BoneLookController
  5106. * @param mesh the mesh that the bone belongs to
  5107. * @param bone the bone that will be looking to the target
  5108. * @param target the target Vector3 to look at
  5109. * @param settings optional settings:
  5110. * * maxYaw: the maximum angle the bone will yaw to
  5111. * * minYaw: the minimum angle the bone will yaw to
  5112. * * maxPitch: the maximum angle the bone will pitch to
  5113. * * minPitch: the minimum angle the bone will yaw to
  5114. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5115. * * upAxis: the up axis of the coordinate system
  5116. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5117. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5118. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5119. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5120. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5121. * * adjustRoll: used to make an adjustment to the roll of the bone
  5122. **/
  5123. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5124. maxYaw?: number;
  5125. minYaw?: number;
  5126. maxPitch?: number;
  5127. minPitch?: number;
  5128. slerpAmount?: number;
  5129. upAxis?: Vector3;
  5130. upAxisSpace?: Space;
  5131. yawAxis?: Vector3;
  5132. pitchAxis?: Vector3;
  5133. adjustYaw?: number;
  5134. adjustPitch?: number;
  5135. adjustRoll?: number;
  5136. });
  5137. /**
  5138. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5139. */
  5140. update(): void;
  5141. private _getAngleDiff(ang1, ang2);
  5142. private _getAngleBetween(ang1, ang2);
  5143. private _isAngleBetween(ang, ang1, ang2);
  5144. }
  5145. }
  5146. declare module BABYLON {
  5147. /**
  5148. * Class used to handle skinning animations
  5149. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5150. */
  5151. class Skeleton implements IAnimatable {
  5152. /** defines the skeleton name */
  5153. name: string;
  5154. /** defines the skeleton Id */
  5155. id: string;
  5156. /**
  5157. * Gets the list of child bones
  5158. */
  5159. bones: Bone[];
  5160. /**
  5161. * Gets an estimate of the dimension of the skeleton at rest
  5162. */
  5163. dimensionsAtRest: Vector3;
  5164. /**
  5165. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5166. */
  5167. needInitialSkinMatrix: boolean;
  5168. /**
  5169. * Gets the list of animations attached to this skeleton
  5170. */
  5171. animations: Array<Animation>;
  5172. private _scene;
  5173. private _isDirty;
  5174. private _transformMatrices;
  5175. private _meshesWithPoseMatrix;
  5176. private _animatables;
  5177. private _identity;
  5178. private _synchronizedWithMesh;
  5179. private _ranges;
  5180. private _lastAbsoluteTransformsUpdateId;
  5181. /**
  5182. * Specifies if the skeleton should be serialized
  5183. */
  5184. doNotSerialize: boolean;
  5185. private _animationPropertiesOverride;
  5186. /**
  5187. * Gets or sets the animation properties override
  5188. */
  5189. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5190. /**
  5191. * An observable triggered before computing the skeleton's matrices
  5192. */
  5193. onBeforeComputeObservable: Observable<Skeleton>;
  5194. /**
  5195. * Creates a new skeleton
  5196. * @param name defines the skeleton name
  5197. * @param id defines the skeleton Id
  5198. * @param scene defines the hosting scene
  5199. */
  5200. constructor(
  5201. /** defines the skeleton name */
  5202. name: string,
  5203. /** defines the skeleton Id */
  5204. id: string, scene: Scene);
  5205. /**
  5206. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5207. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5208. * @returns a Float32Array containing matrices data
  5209. */
  5210. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5211. /**
  5212. * Gets the current hosting scene
  5213. * @returns a scene object
  5214. */
  5215. getScene(): Scene;
  5216. /**
  5217. * Gets a string representing the current skeleton data
  5218. * @param fullDetails defines a boolean indicating if we want a verbose version
  5219. * @returns a string representing the current skeleton data
  5220. */
  5221. toString(fullDetails?: boolean): string;
  5222. /**
  5223. * Get bone's index searching by name
  5224. * @param name defines bone's name to search for
  5225. * @return the indice of the bone. Returns -1 if not found
  5226. */
  5227. getBoneIndexByName(name: string): number;
  5228. /**
  5229. * Creater a new animation range
  5230. * @param name defines the name of the range
  5231. * @param from defines the start key
  5232. * @param to defines the end key
  5233. */
  5234. createAnimationRange(name: string, from: number, to: number): void;
  5235. /**
  5236. * Delete a specific animation range
  5237. * @param name defines the name of the range
  5238. * @param deleteFrames defines if frames must be removed as well
  5239. */
  5240. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5241. /**
  5242. * Gets a specific animation range
  5243. * @param name defines the name of the range to look for
  5244. * @returns the requested animation range or null if not found
  5245. */
  5246. getAnimationRange(name: string): Nullable<AnimationRange>;
  5247. /**
  5248. * Gets the list of all animation ranges defined on this skeleton
  5249. * @returns an array
  5250. */
  5251. getAnimationRanges(): Nullable<AnimationRange>[];
  5252. /**
  5253. * Copy animation range from a source skeleton.
  5254. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5255. * @param source defines the source skeleton
  5256. * @param name defines the name of the range to copy
  5257. * @param rescaleAsRequired defines if rescaling must be applied if required
  5258. * @returns true if operation was successful
  5259. */
  5260. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5261. /**
  5262. * Forces the skeleton to go to rest pose
  5263. */
  5264. returnToRest(): void;
  5265. private _getHighestAnimationFrame();
  5266. /**
  5267. * Begin a specific animation range
  5268. * @param name defines the name of the range to start
  5269. * @param loop defines if looping must be turned on (false by default)
  5270. * @param speedRatio defines the speed ratio to apply (1 by default)
  5271. * @param onAnimationEnd defines a callback which will be called when animation will end
  5272. * @returns a new animatable
  5273. */
  5274. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5275. /** @hidden */
  5276. _markAsDirty(): void;
  5277. /** @hidden */
  5278. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5279. /** @hidden */
  5280. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5281. /** @hidden */
  5282. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5283. /**
  5284. * Build all resources required to render a skeleton
  5285. */
  5286. prepare(): void;
  5287. /**
  5288. * Gets the list of animatables currently running for this skeleton
  5289. * @returns an array of animatables
  5290. */
  5291. getAnimatables(): IAnimatable[];
  5292. /**
  5293. * Clone the current skeleton
  5294. * @param name defines the name of the new skeleton
  5295. * @param id defines the id of the enw skeleton
  5296. * @returns the new skeleton
  5297. */
  5298. clone(name: string, id: string): Skeleton;
  5299. /**
  5300. * Enable animation blending for this skeleton
  5301. * @param blendingSpeed defines the blending speed to apply
  5302. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5303. */
  5304. enableBlending(blendingSpeed?: number): void;
  5305. /**
  5306. * Releases all resources associated with the current skeleton
  5307. */
  5308. dispose(): void;
  5309. /**
  5310. * Serialize the skeleton in a JSON object
  5311. * @returns a JSON object
  5312. */
  5313. serialize(): any;
  5314. /**
  5315. * Creates a new skeleton from serialized data
  5316. * @param parsedSkeleton defines the serialized data
  5317. * @param scene defines the hosting scene
  5318. * @returns a new skeleton
  5319. */
  5320. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5321. /**
  5322. * Compute all node absolute transforms
  5323. * @param forceUpdate defines if computation must be done even if cache is up to date
  5324. */
  5325. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5326. /**
  5327. * Gets the root pose matrix
  5328. * @returns a matrix
  5329. */
  5330. getPoseMatrix(): Nullable<Matrix>;
  5331. /**
  5332. * Sorts bones per internal index
  5333. */
  5334. sortBones(): void;
  5335. private _sortBones(index, bones, visited);
  5336. }
  5337. }
  5338. declare module BABYLON {
  5339. class Collider {
  5340. /** Define if a collision was found */
  5341. collisionFound: boolean;
  5342. /**
  5343. * Define last intersection point in local space
  5344. */
  5345. intersectionPoint: Vector3;
  5346. /**
  5347. * Define last collided mesh
  5348. */
  5349. collidedMesh: Nullable<AbstractMesh>;
  5350. private _collisionPoint;
  5351. private _planeIntersectionPoint;
  5352. private _tempVector;
  5353. private _tempVector2;
  5354. private _tempVector3;
  5355. private _tempVector4;
  5356. private _edge;
  5357. private _baseToVertex;
  5358. private _destinationPoint;
  5359. private _slidePlaneNormal;
  5360. private _displacementVector;
  5361. _radius: Vector3;
  5362. _retry: number;
  5363. private _velocity;
  5364. private _basePoint;
  5365. private _epsilon;
  5366. _velocityWorldLength: number;
  5367. _basePointWorld: Vector3;
  5368. private _velocityWorld;
  5369. private _normalizedVelocity;
  5370. _initialVelocity: Vector3;
  5371. _initialPosition: Vector3;
  5372. private _nearestDistance;
  5373. private _collisionMask;
  5374. collisionMask: number;
  5375. /**
  5376. * Gets the plane normal used to compute the sliding response (in local space)
  5377. */
  5378. readonly slidePlaneNormal: Vector3;
  5379. _initialize(source: Vector3, dir: Vector3, e: number): void;
  5380. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  5381. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  5382. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  5383. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  5384. _getResponse(pos: Vector3, vel: Vector3): void;
  5385. }
  5386. }
  5387. declare module BABYLON {
  5388. var CollisionWorker: string;
  5389. interface ICollisionCoordinator {
  5390. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5391. init(scene: Scene): void;
  5392. destroy(): void;
  5393. onMeshAdded(mesh: AbstractMesh): void;
  5394. onMeshUpdated(mesh: AbstractMesh): void;
  5395. onMeshRemoved(mesh: AbstractMesh): void;
  5396. onGeometryAdded(geometry: Geometry): void;
  5397. onGeometryUpdated(geometry: Geometry): void;
  5398. onGeometryDeleted(geometry: Geometry): void;
  5399. }
  5400. interface SerializedMesh {
  5401. id: string;
  5402. name: string;
  5403. uniqueId: number;
  5404. geometryId: Nullable<string>;
  5405. sphereCenter: Array<number>;
  5406. sphereRadius: number;
  5407. boxMinimum: Array<number>;
  5408. boxMaximum: Array<number>;
  5409. worldMatrixFromCache: any;
  5410. subMeshes: Array<SerializedSubMesh>;
  5411. checkCollisions: boolean;
  5412. }
  5413. interface SerializedSubMesh {
  5414. position: number;
  5415. verticesStart: number;
  5416. verticesCount: number;
  5417. indexStart: number;
  5418. indexCount: number;
  5419. hasMaterial: boolean;
  5420. sphereCenter: Array<number>;
  5421. sphereRadius: number;
  5422. boxMinimum: Array<number>;
  5423. boxMaximum: Array<number>;
  5424. }
  5425. /**
  5426. * Interface describing the value associated with a geometry
  5427. */
  5428. interface SerializedGeometry {
  5429. /**
  5430. * Defines the unique ID of the geometry
  5431. */
  5432. id: string;
  5433. /**
  5434. * Defines the array containing the positions
  5435. */
  5436. positions: Float32Array;
  5437. /**
  5438. * Defines the array containing the indices
  5439. */
  5440. indices: Uint32Array;
  5441. /**
  5442. * Defines the array containing the normals
  5443. */
  5444. normals: Float32Array;
  5445. }
  5446. interface BabylonMessage {
  5447. taskType: WorkerTaskType;
  5448. payload: InitPayload | CollidePayload | UpdatePayload;
  5449. }
  5450. interface SerializedColliderToWorker {
  5451. position: Array<number>;
  5452. velocity: Array<number>;
  5453. radius: Array<number>;
  5454. }
  5455. /** Defines supported task for worker process */
  5456. enum WorkerTaskType {
  5457. /** Initialization */
  5458. INIT = 0,
  5459. /** Update of geometry */
  5460. UPDATE = 1,
  5461. /** Evaluate collision */
  5462. COLLIDE = 2,
  5463. }
  5464. interface WorkerReply {
  5465. error: WorkerReplyType;
  5466. taskType: WorkerTaskType;
  5467. payload?: any;
  5468. }
  5469. interface CollisionReplyPayload {
  5470. newPosition: Array<number>;
  5471. collisionId: number;
  5472. collidedMeshUniqueId: number;
  5473. }
  5474. interface InitPayload {
  5475. }
  5476. interface CollidePayload {
  5477. collisionId: number;
  5478. collider: SerializedColliderToWorker;
  5479. maximumRetry: number;
  5480. excludedMeshUniqueId: Nullable<number>;
  5481. }
  5482. interface UpdatePayload {
  5483. updatedMeshes: {
  5484. [n: number]: SerializedMesh;
  5485. };
  5486. updatedGeometries: {
  5487. [s: string]: SerializedGeometry;
  5488. };
  5489. removedMeshes: Array<number>;
  5490. removedGeometries: Array<string>;
  5491. }
  5492. /** Defines kind of replies returned by worker */
  5493. enum WorkerReplyType {
  5494. /** Success */
  5495. SUCCESS = 0,
  5496. /** Unkown error */
  5497. UNKNOWN_ERROR = 1,
  5498. }
  5499. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  5500. private _scene;
  5501. private _scaledPosition;
  5502. private _scaledVelocity;
  5503. private _collisionsCallbackArray;
  5504. private _init;
  5505. private _runningUpdated;
  5506. private _worker;
  5507. private _addUpdateMeshesList;
  5508. private _addUpdateGeometriesList;
  5509. private _toRemoveMeshesArray;
  5510. private _toRemoveGeometryArray;
  5511. constructor();
  5512. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  5513. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  5514. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5515. init(scene: Scene): void;
  5516. destroy(): void;
  5517. onMeshAdded(mesh: AbstractMesh): void;
  5518. onMeshUpdated: (transformNode: TransformNode) => void;
  5519. onMeshRemoved(mesh: AbstractMesh): void;
  5520. onGeometryAdded(geometry: Geometry): void;
  5521. onGeometryUpdated: (geometry: Geometry) => void;
  5522. onGeometryDeleted(geometry: Geometry): void;
  5523. private _afterRender;
  5524. private _onMessageFromWorker;
  5525. }
  5526. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  5527. private _scene;
  5528. private _scaledPosition;
  5529. private _scaledVelocity;
  5530. private _finalPosition;
  5531. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5532. init(scene: Scene): void;
  5533. destroy(): void;
  5534. onMeshAdded(mesh: AbstractMesh): void;
  5535. onMeshUpdated(mesh: AbstractMesh): void;
  5536. onMeshRemoved(mesh: AbstractMesh): void;
  5537. onGeometryAdded(geometry: Geometry): void;
  5538. onGeometryUpdated(geometry: Geometry): void;
  5539. onGeometryDeleted(geometry: Geometry): void;
  5540. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  5541. }
  5542. }
  5543. declare function importScripts(...urls: string[]): void;
  5544. declare const safePostMessage: any;
  5545. declare module BABYLON {
  5546. var WorkerIncluded: boolean;
  5547. class CollisionCache {
  5548. private _meshes;
  5549. private _geometries;
  5550. getMeshes(): {
  5551. [n: number]: SerializedMesh;
  5552. };
  5553. getGeometries(): {
  5554. [s: number]: SerializedGeometry;
  5555. };
  5556. getMesh(id: any): SerializedMesh;
  5557. addMesh(mesh: SerializedMesh): void;
  5558. removeMesh(uniqueId: number): void;
  5559. getGeometry(id: string): SerializedGeometry;
  5560. addGeometry(geometry: SerializedGeometry): void;
  5561. removeGeometry(id: string): void;
  5562. }
  5563. class CollideWorker {
  5564. collider: Collider;
  5565. private _collisionCache;
  5566. private finalPosition;
  5567. private collisionsScalingMatrix;
  5568. private collisionTranformationMatrix;
  5569. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5570. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  5571. private checkCollision(mesh);
  5572. private processCollisionsForSubMeshes(transformMatrix, mesh);
  5573. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  5574. private checkSubmeshCollision(subMesh);
  5575. }
  5576. interface ICollisionDetector {
  5577. onInit(payload: InitPayload): void;
  5578. onUpdate(payload: UpdatePayload): void;
  5579. onCollision(payload: CollidePayload): void;
  5580. }
  5581. class CollisionDetectorTransferable implements ICollisionDetector {
  5582. private _collisionCache;
  5583. onInit(payload: InitPayload): void;
  5584. onUpdate(payload: UpdatePayload): void;
  5585. onCollision(payload: CollidePayload): void;
  5586. }
  5587. }
  5588. declare module BABYLON {
  5589. class IntersectionInfo {
  5590. bu: Nullable<number>;
  5591. bv: Nullable<number>;
  5592. distance: number;
  5593. faceId: number;
  5594. subMeshId: number;
  5595. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  5596. }
  5597. class PickingInfo {
  5598. hit: boolean;
  5599. distance: number;
  5600. pickedPoint: Nullable<Vector3>;
  5601. pickedMesh: Nullable<AbstractMesh>;
  5602. bu: number;
  5603. bv: number;
  5604. faceId: number;
  5605. subMeshId: number;
  5606. pickedSprite: Nullable<Sprite>;
  5607. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  5608. getTextureCoordinates(): Nullable<Vector2>;
  5609. }
  5610. }
  5611. declare module BABYLON {
  5612. class ArcRotateCamera extends TargetCamera {
  5613. alpha: number;
  5614. beta: number;
  5615. radius: number;
  5616. protected _target: Vector3;
  5617. protected _targetHost: Nullable<AbstractMesh>;
  5618. target: Vector3;
  5619. inertialAlphaOffset: number;
  5620. inertialBetaOffset: number;
  5621. inertialRadiusOffset: number;
  5622. lowerAlphaLimit: Nullable<number>;
  5623. upperAlphaLimit: Nullable<number>;
  5624. lowerBetaLimit: number;
  5625. upperBetaLimit: number;
  5626. lowerRadiusLimit: Nullable<number>;
  5627. upperRadiusLimit: Nullable<number>;
  5628. inertialPanningX: number;
  5629. inertialPanningY: number;
  5630. pinchToPanMaxDistance: number;
  5631. panningDistanceLimit: Nullable<number>;
  5632. panningOriginTarget: Vector3;
  5633. panningInertia: number;
  5634. angularSensibilityX: number;
  5635. angularSensibilityY: number;
  5636. pinchPrecision: number;
  5637. pinchDeltaPercentage: number;
  5638. panningSensibility: number;
  5639. keysUp: number[];
  5640. keysDown: number[];
  5641. keysLeft: number[];
  5642. keysRight: number[];
  5643. wheelPrecision: number;
  5644. wheelDeltaPercentage: number;
  5645. zoomOnFactor: number;
  5646. targetScreenOffset: Vector2;
  5647. allowUpsideDown: boolean;
  5648. _viewMatrix: Matrix;
  5649. _useCtrlForPanning: boolean;
  5650. _panningMouseButton: number;
  5651. inputs: ArcRotateCameraInputsManager;
  5652. _reset: () => void;
  5653. panningAxis: Vector3;
  5654. protected _localDirection: Vector3;
  5655. protected _transformedDirection: Vector3;
  5656. private _bouncingBehavior;
  5657. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  5658. useBouncingBehavior: boolean;
  5659. private _framingBehavior;
  5660. readonly framingBehavior: Nullable<FramingBehavior>;
  5661. useFramingBehavior: boolean;
  5662. private _autoRotationBehavior;
  5663. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  5664. useAutoRotationBehavior: boolean;
  5665. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  5666. onCollide: (collidedMesh: AbstractMesh) => void;
  5667. checkCollisions: boolean;
  5668. collisionRadius: Vector3;
  5669. protected _collider: Collider;
  5670. protected _previousPosition: Vector3;
  5671. protected _collisionVelocity: Vector3;
  5672. protected _newPosition: Vector3;
  5673. protected _previousAlpha: number;
  5674. protected _previousBeta: number;
  5675. protected _previousRadius: number;
  5676. protected _collisionTriggered: boolean;
  5677. protected _targetBoundingCenter: Nullable<Vector3>;
  5678. private _computationVector;
  5679. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5680. _initCache(): void;
  5681. _updateCache(ignoreParentClass?: boolean): void;
  5682. protected _getTargetPosition(): Vector3;
  5683. /**
  5684. * Store current camera state (fov, position, etc..)
  5685. */
  5686. private _storedAlpha;
  5687. private _storedBeta;
  5688. private _storedRadius;
  5689. private _storedTarget;
  5690. storeState(): Camera;
  5691. /**
  5692. * Restored camera state. You must call storeState() first
  5693. */
  5694. _restoreStateValues(): boolean;
  5695. _isSynchronizedViewMatrix(): boolean;
  5696. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5697. detachControl(element: HTMLElement): void;
  5698. _checkInputs(): void;
  5699. protected _checkLimits(): void;
  5700. rebuildAnglesAndRadius(): void;
  5701. setPosition(position: Vector3): void;
  5702. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5703. _getViewMatrix(): Matrix;
  5704. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5705. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5706. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5707. min: Vector3;
  5708. max: Vector3;
  5709. distance: number;
  5710. }, doNotUpdateMaxZ?: boolean): void;
  5711. /**
  5712. * @override
  5713. * Override Camera.createRigCamera
  5714. */
  5715. createRigCamera(name: string, cameraIndex: number): Camera;
  5716. /**
  5717. * @override
  5718. * Override Camera._updateRigCameras
  5719. */
  5720. _updateRigCameras(): void;
  5721. dispose(): void;
  5722. getClassName(): string;
  5723. }
  5724. }
  5725. declare module BABYLON {
  5726. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5727. constructor(camera: ArcRotateCamera);
  5728. addMouseWheel(): ArcRotateCameraInputsManager;
  5729. addPointers(): ArcRotateCameraInputsManager;
  5730. addKeyboard(): ArcRotateCameraInputsManager;
  5731. addGamepad(): ArcRotateCameraInputsManager;
  5732. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  5733. }
  5734. }
  5735. declare module BABYLON {
  5736. class Camera extends Node {
  5737. inputs: CameraInputsManager<Camera>;
  5738. private static _PERSPECTIVE_CAMERA;
  5739. private static _ORTHOGRAPHIC_CAMERA;
  5740. private static _FOVMODE_VERTICAL_FIXED;
  5741. private static _FOVMODE_HORIZONTAL_FIXED;
  5742. private static _RIG_MODE_NONE;
  5743. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  5744. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  5745. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  5746. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  5747. private static _RIG_MODE_VR;
  5748. private static _RIG_MODE_WEBVR;
  5749. static readonly PERSPECTIVE_CAMERA: number;
  5750. static readonly ORTHOGRAPHIC_CAMERA: number;
  5751. /**
  5752. * This is the default FOV mode for perspective cameras.
  5753. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  5754. *
  5755. */
  5756. static readonly FOVMODE_VERTICAL_FIXED: number;
  5757. /**
  5758. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  5759. *
  5760. */
  5761. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  5762. static readonly RIG_MODE_NONE: number;
  5763. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  5764. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  5765. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  5766. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  5767. static readonly RIG_MODE_VR: number;
  5768. static readonly RIG_MODE_WEBVR: number;
  5769. static ForceAttachControlToAlwaysPreventDefault: boolean;
  5770. static UseAlternateWebVRRendering: boolean;
  5771. position: Vector3;
  5772. /**
  5773. * The vector the camera should consider as up.
  5774. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  5775. */
  5776. upVector: Vector3;
  5777. orthoLeft: Nullable<number>;
  5778. orthoRight: Nullable<number>;
  5779. orthoBottom: Nullable<number>;
  5780. orthoTop: Nullable<number>;
  5781. /**
  5782. * FOV is set in Radians. (default is 0.8)
  5783. */
  5784. fov: number;
  5785. minZ: number;
  5786. maxZ: number;
  5787. inertia: number;
  5788. mode: number;
  5789. isIntermediate: boolean;
  5790. viewport: Viewport;
  5791. /**
  5792. * Restricts the camera to viewing objects with the same layerMask.
  5793. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  5794. */
  5795. layerMask: number;
  5796. /**
  5797. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  5798. */
  5799. fovMode: number;
  5800. cameraRigMode: number;
  5801. interaxialDistance: number;
  5802. isStereoscopicSideBySide: boolean;
  5803. _cameraRigParams: any;
  5804. _rigCameras: Camera[];
  5805. _rigPostProcess: Nullable<PostProcess>;
  5806. protected _webvrViewMatrix: Matrix;
  5807. _skipRendering: boolean;
  5808. _alternateCamera: Camera;
  5809. customRenderTargets: RenderTargetTexture[];
  5810. onViewMatrixChangedObservable: Observable<Camera>;
  5811. onProjectionMatrixChangedObservable: Observable<Camera>;
  5812. onAfterCheckInputsObservable: Observable<Camera>;
  5813. onRestoreStateObservable: Observable<Camera>;
  5814. private _computedViewMatrix;
  5815. _projectionMatrix: Matrix;
  5816. private _doNotComputeProjectionMatrix;
  5817. private _worldMatrix;
  5818. _postProcesses: Nullable<PostProcess>[];
  5819. private _transformMatrix;
  5820. _activeMeshes: SmartArray<AbstractMesh>;
  5821. protected _globalPosition: Vector3;
  5822. private _frustumPlanes;
  5823. private _refreshFrustumPlanes;
  5824. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5825. private _storedFov;
  5826. private _stateStored;
  5827. /**
  5828. * Store current camera state (fov, position, etc..)
  5829. */
  5830. storeState(): Camera;
  5831. /**
  5832. * Restores the camera state values if it has been stored. You must call storeState() first
  5833. */
  5834. protected _restoreStateValues(): boolean;
  5835. /**
  5836. * Restored camera state. You must call storeState() first
  5837. */
  5838. restoreState(): boolean;
  5839. getClassName(): string;
  5840. /**
  5841. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  5842. */
  5843. toString(fullDetails?: boolean): string;
  5844. readonly globalPosition: Vector3;
  5845. getActiveMeshes(): SmartArray<AbstractMesh>;
  5846. isActiveMesh(mesh: Mesh): boolean;
  5847. /**
  5848. * Is this camera ready to be used/rendered
  5849. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  5850. * @return true if the camera is ready
  5851. */
  5852. isReady(completeCheck?: boolean): boolean;
  5853. _initCache(): void;
  5854. _updateCache(ignoreParentClass?: boolean): void;
  5855. _isSynchronized(): boolean;
  5856. _isSynchronizedViewMatrix(): boolean;
  5857. _isSynchronizedProjectionMatrix(): boolean;
  5858. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5859. detachControl(element: HTMLElement): void;
  5860. update(): void;
  5861. _checkInputs(): void;
  5862. readonly rigCameras: Camera[];
  5863. readonly rigPostProcess: Nullable<PostProcess>;
  5864. /**
  5865. * Internal, gets the first post proces.
  5866. * @returns the first post process to be run on this camera.
  5867. */
  5868. _getFirstPostProcess(): Nullable<PostProcess>;
  5869. private _cascadePostProcessesToRigCams();
  5870. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  5871. detachPostProcess(postProcess: PostProcess): void;
  5872. getWorldMatrix(): Matrix;
  5873. _getViewMatrix(): Matrix;
  5874. getViewMatrix(force?: boolean): Matrix;
  5875. freezeProjectionMatrix(projection?: Matrix): void;
  5876. unfreezeProjectionMatrix(): void;
  5877. getProjectionMatrix(force?: boolean): Matrix;
  5878. getTranformationMatrix(): Matrix;
  5879. private updateFrustumPlanes();
  5880. isInFrustum(target: ICullable): boolean;
  5881. isCompletelyInFrustum(target: ICullable): boolean;
  5882. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  5883. /**
  5884. * Releases resources associated with this node.
  5885. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  5886. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  5887. */
  5888. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  5889. readonly leftCamera: Nullable<FreeCamera>;
  5890. readonly rightCamera: Nullable<FreeCamera>;
  5891. getLeftTarget(): Nullable<Vector3>;
  5892. getRightTarget(): Nullable<Vector3>;
  5893. setCameraRigMode(mode: number, rigParams: any): void;
  5894. private _getVRProjectionMatrix();
  5895. protected _updateCameraRotationMatrix(): void;
  5896. protected _updateWebVRCameraRotationMatrix(): void;
  5897. /**
  5898. * This function MUST be overwritten by the different WebVR cameras available.
  5899. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5900. */
  5901. protected _getWebVRProjectionMatrix(): Matrix;
  5902. /**
  5903. * This function MUST be overwritten by the different WebVR cameras available.
  5904. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  5905. */
  5906. protected _getWebVRViewMatrix(): Matrix;
  5907. setCameraRigParameter(name: string, value: any): void;
  5908. /**
  5909. * needs to be overridden by children so sub has required properties to be copied
  5910. */
  5911. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  5912. /**
  5913. * May need to be overridden by children
  5914. */
  5915. _updateRigCameras(): void;
  5916. _setupInputs(): void;
  5917. serialize(): any;
  5918. clone(name: string): Camera;
  5919. getDirection(localAxis: Vector3): Vector3;
  5920. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  5921. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  5922. computeWorldMatrix(): Matrix;
  5923. static Parse(parsedCamera: any, scene: Scene): Camera;
  5924. }
  5925. }
  5926. declare module BABYLON {
  5927. var CameraInputTypes: {};
  5928. interface ICameraInput<TCamera extends Camera> {
  5929. camera: Nullable<TCamera>;
  5930. getClassName(): string;
  5931. getSimpleName(): string;
  5932. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  5933. detachControl: (element: Nullable<HTMLElement>) => void;
  5934. checkInputs?: () => void;
  5935. }
  5936. interface CameraInputsMap<TCamera extends Camera> {
  5937. [name: string]: ICameraInput<TCamera>;
  5938. [idx: number]: ICameraInput<TCamera>;
  5939. }
  5940. class CameraInputsManager<TCamera extends Camera> {
  5941. attached: CameraInputsMap<TCamera>;
  5942. attachedElement: Nullable<HTMLElement>;
  5943. noPreventDefault: boolean;
  5944. camera: TCamera;
  5945. checkInputs: () => void;
  5946. constructor(camera: TCamera);
  5947. /**
  5948. * Add an input method to a camera.
  5949. * builtin inputs example: camera.inputs.addGamepad();
  5950. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  5951. * @param input camera input method
  5952. */
  5953. add(input: ICameraInput<TCamera>): void;
  5954. /**
  5955. * Remove a specific input method from a camera
  5956. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  5957. * @param inputToRemove camera input method
  5958. */
  5959. remove(inputToRemove: ICameraInput<TCamera>): void;
  5960. removeByType(inputType: string): void;
  5961. private _addCheckInputs(fn);
  5962. attachInput(input: ICameraInput<TCamera>): void;
  5963. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  5964. detachElement(element: HTMLElement, disconnect?: boolean): void;
  5965. rebuildInputCheck(): void;
  5966. /**
  5967. * Remove all attached input methods from a camera
  5968. */
  5969. clear(): void;
  5970. serialize(serializedCamera: any): void;
  5971. parse(parsedCamera: any): void;
  5972. }
  5973. }
  5974. declare module BABYLON {
  5975. /**
  5976. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  5977. * being tilted forward or back and left or right.
  5978. */
  5979. class DeviceOrientationCamera extends FreeCamera {
  5980. private _initialQuaternion;
  5981. private _quaternionCache;
  5982. /**
  5983. * Creates a new device orientation camera
  5984. * @param name The name of the camera
  5985. * @param position The start position camera
  5986. * @param scene The scene the camera belongs to
  5987. */
  5988. constructor(name: string, position: Vector3, scene: Scene);
  5989. /**
  5990. * Gets the current instance class name ("DeviceOrientationCamera").
  5991. * This helps avoiding instanceof at run time.
  5992. * @returns the class name
  5993. */
  5994. getClassName(): string;
  5995. /**
  5996. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  5997. */
  5998. _checkInputs(): void;
  5999. /**
  6000. * Reset the camera to its default orientation on the specified axis only.
  6001. * @param axis The axis to reset
  6002. */
  6003. resetToCurrentRotation(axis?: Axis): void;
  6004. }
  6005. }
  6006. declare module BABYLON {
  6007. class FollowCamera extends TargetCamera {
  6008. radius: number;
  6009. rotationOffset: number;
  6010. heightOffset: number;
  6011. cameraAcceleration: number;
  6012. maxCameraSpeed: number;
  6013. lockedTarget: Nullable<AbstractMesh>;
  6014. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  6015. private getRadians(degrees);
  6016. private follow(cameraTarget);
  6017. _checkInputs(): void;
  6018. getClassName(): string;
  6019. }
  6020. class ArcFollowCamera extends TargetCamera {
  6021. alpha: number;
  6022. beta: number;
  6023. radius: number;
  6024. target: Nullable<AbstractMesh>;
  6025. private _cartesianCoordinates;
  6026. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  6027. private follow();
  6028. _checkInputs(): void;
  6029. getClassName(): string;
  6030. }
  6031. }
  6032. declare module BABYLON {
  6033. class FreeCamera extends TargetCamera {
  6034. ellipsoid: Vector3;
  6035. ellipsoidOffset: Vector3;
  6036. checkCollisions: boolean;
  6037. applyGravity: boolean;
  6038. inputs: FreeCameraInputsManager;
  6039. /**
  6040. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6041. * Higher values reduce sensitivity.
  6042. */
  6043. /**
  6044. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6045. * Higher values reduce sensitivity.
  6046. */
  6047. angularSensibility: number;
  6048. keysUp: number[];
  6049. keysDown: number[];
  6050. keysLeft: number[];
  6051. keysRight: number[];
  6052. onCollide: (collidedMesh: AbstractMesh) => void;
  6053. private _collider;
  6054. private _needMoveForGravity;
  6055. private _oldPosition;
  6056. private _diffPosition;
  6057. private _newPosition;
  6058. _localDirection: Vector3;
  6059. _transformedDirection: Vector3;
  6060. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6061. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6062. detachControl(element: HTMLElement): void;
  6063. private _collisionMask;
  6064. collisionMask: number;
  6065. _collideWithWorld(displacement: Vector3): void;
  6066. private _onCollisionPositionChange;
  6067. _checkInputs(): void;
  6068. _decideIfNeedsToMove(): boolean;
  6069. _updatePosition(): void;
  6070. dispose(): void;
  6071. getClassName(): string;
  6072. }
  6073. }
  6074. declare module BABYLON {
  6075. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6076. constructor(camera: FreeCamera);
  6077. addKeyboard(): FreeCameraInputsManager;
  6078. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6079. addGamepad(): FreeCameraInputsManager;
  6080. addDeviceOrientation(): FreeCameraInputsManager;
  6081. addTouch(): FreeCameraInputsManager;
  6082. addVirtualJoystick(): FreeCameraInputsManager;
  6083. }
  6084. }
  6085. declare module BABYLON {
  6086. class GamepadCamera extends UniversalCamera {
  6087. gamepadAngularSensibility: number;
  6088. gamepadMoveSensibility: number;
  6089. constructor(name: string, position: Vector3, scene: Scene);
  6090. getClassName(): string;
  6091. }
  6092. }
  6093. declare module BABYLON {
  6094. /**
  6095. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  6096. */
  6097. class AnaglyphFreeCamera extends FreeCamera {
  6098. /**
  6099. * Creates a new AnaglyphFreeCamera
  6100. * @param name defines camera name
  6101. * @param position defines initial position
  6102. * @param interaxialDistance defines distance between each color axis
  6103. * @param scene defines the hosting scene
  6104. */
  6105. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6106. /**
  6107. * Gets camera class name
  6108. * @returns AnaglyphFreeCamera
  6109. */
  6110. getClassName(): string;
  6111. }
  6112. /**
  6113. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  6114. */
  6115. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  6116. /**
  6117. * Creates a new AnaglyphArcRotateCamera
  6118. * @param name defines camera name
  6119. * @param alpha defines alpha angle (in radians)
  6120. * @param beta defines beta angle (in radians)
  6121. * @param radius defines radius
  6122. * @param target defines camera target
  6123. * @param interaxialDistance defines distance between each color axis
  6124. * @param scene defines the hosting scene
  6125. */
  6126. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  6127. /**
  6128. * Gets camera class name
  6129. * @returns AnaglyphArcRotateCamera
  6130. */
  6131. getClassName(): string;
  6132. }
  6133. /**
  6134. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  6135. */
  6136. class AnaglyphGamepadCamera extends GamepadCamera {
  6137. /**
  6138. * Creates a new AnaglyphGamepadCamera
  6139. * @param name defines camera name
  6140. * @param position defines initial position
  6141. * @param interaxialDistance defines distance between each color axis
  6142. * @param scene defines the hosting scene
  6143. */
  6144. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6145. /**
  6146. * Gets camera class name
  6147. * @returns AnaglyphGamepadCamera
  6148. */
  6149. getClassName(): string;
  6150. }
  6151. /**
  6152. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  6153. */
  6154. class AnaglyphUniversalCamera extends UniversalCamera {
  6155. /**
  6156. * Creates a new AnaglyphUniversalCamera
  6157. * @param name defines camera name
  6158. * @param position defines initial position
  6159. * @param interaxialDistance defines distance between each color axis
  6160. * @param scene defines the hosting scene
  6161. */
  6162. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6163. /**
  6164. * Gets camera class name
  6165. * @returns AnaglyphUniversalCamera
  6166. */
  6167. getClassName(): string;
  6168. }
  6169. /**
  6170. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  6171. */
  6172. class StereoscopicFreeCamera extends FreeCamera {
  6173. /**
  6174. * Creates a new StereoscopicFreeCamera
  6175. * @param name defines camera name
  6176. * @param position defines initial position
  6177. * @param interaxialDistance defines distance between each color axis
  6178. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6179. * @param scene defines the hosting scene
  6180. */
  6181. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6182. /**
  6183. * Gets camera class name
  6184. * @returns StereoscopicFreeCamera
  6185. */
  6186. getClassName(): string;
  6187. }
  6188. /**
  6189. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  6190. */
  6191. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  6192. /**
  6193. * Creates a new StereoscopicArcRotateCamera
  6194. * @param name defines camera name
  6195. * @param alpha defines alpha angle (in radians)
  6196. * @param beta defines beta angle (in radians)
  6197. * @param radius defines radius
  6198. * @param target defines camera target
  6199. * @param interaxialDistance defines distance between each color axis
  6200. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6201. * @param scene defines the hosting scene
  6202. */
  6203. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6204. /**
  6205. * Gets camera class name
  6206. * @returns StereoscopicArcRotateCamera
  6207. */
  6208. getClassName(): string;
  6209. }
  6210. /**
  6211. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  6212. */
  6213. class StereoscopicGamepadCamera extends GamepadCamera {
  6214. /**
  6215. * Creates a new StereoscopicGamepadCamera
  6216. * @param name defines camera name
  6217. * @param position defines initial position
  6218. * @param interaxialDistance defines distance between each color axis
  6219. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6220. * @param scene defines the hosting scene
  6221. */
  6222. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6223. /**
  6224. * Gets camera class name
  6225. * @returns StereoscopicGamepadCamera
  6226. */
  6227. getClassName(): string;
  6228. }
  6229. /**
  6230. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  6231. */
  6232. class StereoscopicUniversalCamera extends UniversalCamera {
  6233. /**
  6234. * Creates a new StereoscopicUniversalCamera
  6235. * @param name defines camera name
  6236. * @param position defines initial position
  6237. * @param interaxialDistance defines distance between each color axis
  6238. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6239. * @param scene defines the hosting scene
  6240. */
  6241. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6242. /**
  6243. * Gets camera class name
  6244. * @returns StereoscopicUniversalCamera
  6245. */
  6246. getClassName(): string;
  6247. }
  6248. }
  6249. declare module BABYLON {
  6250. class TargetCamera extends Camera {
  6251. cameraDirection: Vector3;
  6252. cameraRotation: Vector2;
  6253. rotation: Vector3;
  6254. rotationQuaternion: Quaternion;
  6255. speed: number;
  6256. noRotationConstraint: boolean;
  6257. lockedTarget: any;
  6258. _currentTarget: Vector3;
  6259. _viewMatrix: Matrix;
  6260. _camMatrix: Matrix;
  6261. _cameraTransformMatrix: Matrix;
  6262. _cameraRotationMatrix: Matrix;
  6263. private _rigCamTransformMatrix;
  6264. _referencePoint: Vector3;
  6265. private _currentUpVector;
  6266. _transformedReferencePoint: Vector3;
  6267. protected _globalCurrentTarget: Vector3;
  6268. protected _globalCurrentUpVector: Vector3;
  6269. _reset: () => void;
  6270. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6271. getFrontPosition(distance: number): Vector3;
  6272. _getLockedTargetPosition(): Nullable<Vector3>;
  6273. /**
  6274. * Store current camera state (fov, position, etc..)
  6275. */
  6276. private _storedPosition;
  6277. private _storedRotation;
  6278. private _storedRotationQuaternion;
  6279. storeState(): Camera;
  6280. /**
  6281. * Restored camera state. You must call storeState() first
  6282. */
  6283. _restoreStateValues(): boolean;
  6284. _initCache(): void;
  6285. _updateCache(ignoreParentClass?: boolean): void;
  6286. _isSynchronizedViewMatrix(): boolean;
  6287. _computeLocalCameraSpeed(): number;
  6288. setTarget(target: Vector3): void;
  6289. /**
  6290. * Return the current target position of the camera. This value is expressed in local space.
  6291. */
  6292. getTarget(): Vector3;
  6293. _decideIfNeedsToMove(): boolean;
  6294. _updatePosition(): void;
  6295. _checkInputs(): void;
  6296. protected _updateCameraRotationMatrix(): void;
  6297. _getViewMatrix(): Matrix;
  6298. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6299. /**
  6300. * @override
  6301. * Override Camera.createRigCamera
  6302. */
  6303. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6304. /**
  6305. * @override
  6306. * Override Camera._updateRigCameras
  6307. */
  6308. _updateRigCameras(): void;
  6309. private _getRigCamPosition(halfSpace, result);
  6310. getClassName(): string;
  6311. }
  6312. }
  6313. declare module BABYLON {
  6314. class TouchCamera extends FreeCamera {
  6315. touchAngularSensibility: number;
  6316. touchMoveSensibility: number;
  6317. constructor(name: string, position: Vector3, scene: Scene);
  6318. getClassName(): string;
  6319. _setupInputs(): void;
  6320. }
  6321. }
  6322. declare module BABYLON {
  6323. class UniversalCamera extends TouchCamera {
  6324. gamepadAngularSensibility: number;
  6325. gamepadMoveSensibility: number;
  6326. constructor(name: string, position: Vector3, scene: Scene);
  6327. getClassName(): string;
  6328. }
  6329. }
  6330. declare module BABYLON {
  6331. class VirtualJoysticksCamera extends FreeCamera {
  6332. constructor(name: string, position: Vector3, scene: Scene);
  6333. getClassName(): string;
  6334. }
  6335. }
  6336. interface VRDisplay extends EventTarget {
  6337. /**
  6338. * Dictionary of capabilities describing the VRDisplay.
  6339. */
  6340. readonly capabilities: VRDisplayCapabilities;
  6341. /**
  6342. * z-depth defining the far plane of the eye view frustum
  6343. * enables mapping of values in the render target depth
  6344. * attachment to scene coordinates. Initially set to 10000.0.
  6345. */
  6346. depthFar: number;
  6347. /**
  6348. * z-depth defining the near plane of the eye view frustum
  6349. * enables mapping of values in the render target depth
  6350. * attachment to scene coordinates. Initially set to 0.01.
  6351. */
  6352. depthNear: number;
  6353. /**
  6354. * An identifier for this distinct VRDisplay. Used as an
  6355. * association point in the Gamepad API.
  6356. */
  6357. readonly displayId: number;
  6358. /**
  6359. * A display name, a user-readable name identifying it.
  6360. */
  6361. readonly displayName: string;
  6362. readonly isConnected: boolean;
  6363. readonly isPresenting: boolean;
  6364. /**
  6365. * If this VRDisplay supports room-scale experiences, the optional
  6366. * stage attribute contains details on the room-scale parameters.
  6367. */
  6368. readonly stageParameters: VRStageParameters | null;
  6369. /**
  6370. * Passing the value returned by `requestAnimationFrame` to
  6371. * `cancelAnimationFrame` will unregister the callback.
  6372. */
  6373. cancelAnimationFrame(handle: number): void;
  6374. /**
  6375. * Stops presenting to the VRDisplay.
  6376. */
  6377. exitPresent(): Promise<void>;
  6378. getEyeParameters(whichEye: string): VREyeParameters;
  6379. /**
  6380. * Populates the passed VRFrameData with the information required to render
  6381. * the current frame.
  6382. */
  6383. getFrameData(frameData: VRFrameData): boolean;
  6384. /**
  6385. * Get the layers currently being presented.
  6386. */
  6387. getLayers(): VRLayer[];
  6388. /**
  6389. * Return a VRPose containing the future predicted pose of the VRDisplay
  6390. * when the current frame will be presented. The value returned will not
  6391. * change until JavaScript has returned control to the browser.
  6392. *
  6393. * The VRPose will contain the position, orientation, velocity,
  6394. * and acceleration of each of these properties.
  6395. */
  6396. getPose(): VRPose;
  6397. /**
  6398. * Return the current instantaneous pose of the VRDisplay, with no
  6399. * prediction applied.
  6400. */
  6401. getImmediatePose(): VRPose;
  6402. /**
  6403. * The callback passed to `requestAnimationFrame` will be called
  6404. * any time a new frame should be rendered. When the VRDisplay is
  6405. * presenting the callback will be called at the native refresh
  6406. * rate of the HMD. When not presenting this function acts
  6407. * identically to how window.requestAnimationFrame acts. Content should
  6408. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6409. * asynchronously from other displays and at differing refresh rates.
  6410. */
  6411. requestAnimationFrame(callback: FrameRequestCallback): number;
  6412. /**
  6413. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6414. * Repeat calls while already presenting will update the VRLayers being displayed.
  6415. */
  6416. requestPresent(layers: VRLayer[]): Promise<void>;
  6417. /**
  6418. * Reset the pose for this display, treating its current position and
  6419. * orientation as the "origin/zero" values. VRPose.position,
  6420. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6421. * updated when calling resetPose(). This should be called in only
  6422. * sitting-space experiences.
  6423. */
  6424. resetPose(): void;
  6425. /**
  6426. * The VRLayer provided to the VRDisplay will be captured and presented
  6427. * in the HMD. Calling this function has the same effect on the source
  6428. * canvas as any other operation that uses its source image, and canvases
  6429. * created without preserveDrawingBuffer set to true will be cleared.
  6430. */
  6431. submitFrame(pose?: VRPose): void;
  6432. }
  6433. declare var VRDisplay: {
  6434. prototype: VRDisplay;
  6435. new (): VRDisplay;
  6436. };
  6437. interface VRLayer {
  6438. leftBounds?: number[] | null;
  6439. rightBounds?: number[] | null;
  6440. source?: HTMLCanvasElement | null;
  6441. }
  6442. interface VRDisplayCapabilities {
  6443. readonly canPresent: boolean;
  6444. readonly hasExternalDisplay: boolean;
  6445. readonly hasOrientation: boolean;
  6446. readonly hasPosition: boolean;
  6447. readonly maxLayers: number;
  6448. }
  6449. interface VREyeParameters {
  6450. /** @deprecated */
  6451. readonly fieldOfView: VRFieldOfView;
  6452. readonly offset: Float32Array;
  6453. readonly renderHeight: number;
  6454. readonly renderWidth: number;
  6455. }
  6456. interface VRFieldOfView {
  6457. readonly downDegrees: number;
  6458. readonly leftDegrees: number;
  6459. readonly rightDegrees: number;
  6460. readonly upDegrees: number;
  6461. }
  6462. interface VRFrameData {
  6463. readonly leftProjectionMatrix: Float32Array;
  6464. readonly leftViewMatrix: Float32Array;
  6465. readonly pose: VRPose;
  6466. readonly rightProjectionMatrix: Float32Array;
  6467. readonly rightViewMatrix: Float32Array;
  6468. readonly timestamp: number;
  6469. }
  6470. interface VRPose {
  6471. readonly angularAcceleration: Float32Array | null;
  6472. readonly angularVelocity: Float32Array | null;
  6473. readonly linearAcceleration: Float32Array | null;
  6474. readonly linearVelocity: Float32Array | null;
  6475. readonly orientation: Float32Array | null;
  6476. readonly position: Float32Array | null;
  6477. readonly timestamp: number;
  6478. }
  6479. interface VRStageParameters {
  6480. sittingToStandingTransform?: Float32Array;
  6481. sizeX?: number;
  6482. sizeY?: number;
  6483. }
  6484. interface Navigator {
  6485. getVRDisplays(): Promise<VRDisplay[]>;
  6486. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6487. }
  6488. interface Window {
  6489. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6490. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6491. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6492. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6493. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6494. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6495. }
  6496. interface Gamepad {
  6497. readonly displayId: number;
  6498. }
  6499. declare module BABYLON {
  6500. class BoundingBox implements ICullable {
  6501. vectors: Vector3[];
  6502. center: Vector3;
  6503. centerWorld: Vector3;
  6504. extendSize: Vector3;
  6505. extendSizeWorld: Vector3;
  6506. directions: Vector3[];
  6507. vectorsWorld: Vector3[];
  6508. minimumWorld: Vector3;
  6509. maximumWorld: Vector3;
  6510. minimum: Vector3;
  6511. maximum: Vector3;
  6512. private _worldMatrix;
  6513. /**
  6514. * Creates a new bounding box
  6515. * @param min defines the minimum vector (in local space)
  6516. * @param max defines the maximum vector (in local space)
  6517. */
  6518. constructor(min: Vector3, max: Vector3);
  6519. /**
  6520. * Recreates the entire bounding box from scratch
  6521. * @param min defines the new minimum vector (in local space)
  6522. * @param max defines the new maximum vector (in local space)
  6523. */
  6524. reConstruct(min: Vector3, max: Vector3): void;
  6525. getWorldMatrix(): Matrix;
  6526. setWorldMatrix(matrix: Matrix): BoundingBox;
  6527. _update(world: Matrix): void;
  6528. isInFrustum(frustumPlanes: Plane[]): boolean;
  6529. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6530. intersectsPoint(point: Vector3): boolean;
  6531. intersectsSphere(sphere: BoundingSphere): boolean;
  6532. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  6533. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  6534. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  6535. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6536. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  6537. }
  6538. }
  6539. declare module BABYLON {
  6540. interface ICullable {
  6541. isInFrustum(frustumPlanes: Plane[]): boolean;
  6542. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6543. }
  6544. class BoundingInfo implements ICullable {
  6545. minimum: Vector3;
  6546. maximum: Vector3;
  6547. boundingBox: BoundingBox;
  6548. boundingSphere: BoundingSphere;
  6549. private _isLocked;
  6550. constructor(minimum: Vector3, maximum: Vector3);
  6551. isLocked: boolean;
  6552. update(world: Matrix): void;
  6553. /**
  6554. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6555. * @param center New center of the bounding info
  6556. * @param extend New extend of the bounding info
  6557. */
  6558. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  6559. isInFrustum(frustumPlanes: Plane[]): boolean;
  6560. /**
  6561. * Gets the world distance between the min and max points of the bounding box
  6562. */
  6563. readonly diagonalLength: number;
  6564. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6565. _checkCollision(collider: Collider): boolean;
  6566. intersectsPoint(point: Vector3): boolean;
  6567. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  6568. }
  6569. }
  6570. declare module BABYLON {
  6571. class BoundingSphere {
  6572. center: Vector3;
  6573. radius: number;
  6574. centerWorld: Vector3;
  6575. radiusWorld: number;
  6576. minimum: Vector3;
  6577. maximum: Vector3;
  6578. private _tempRadiusVector;
  6579. /**
  6580. * Creates a new bounding sphere
  6581. * @param min defines the minimum vector (in local space)
  6582. * @param max defines the maximum vector (in local space)
  6583. */
  6584. constructor(min: Vector3, max: Vector3);
  6585. /**
  6586. * Recreates the entire bounding sphere from scratch
  6587. * @param min defines the new minimum vector (in local space)
  6588. * @param max defines the new maximum vector (in local space)
  6589. */
  6590. reConstruct(min: Vector3, max: Vector3): void;
  6591. _update(world: Matrix): void;
  6592. isInFrustum(frustumPlanes: Plane[]): boolean;
  6593. intersectsPoint(point: Vector3): boolean;
  6594. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  6595. }
  6596. }
  6597. declare module BABYLON {
  6598. class Ray {
  6599. origin: Vector3;
  6600. direction: Vector3;
  6601. length: number;
  6602. private _edge1;
  6603. private _edge2;
  6604. private _pvec;
  6605. private _tvec;
  6606. private _qvec;
  6607. private _tmpRay;
  6608. constructor(origin: Vector3, direction: Vector3, length?: number);
  6609. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  6610. intersectsBox(box: BoundingBox): boolean;
  6611. intersectsSphere(sphere: BoundingSphere): boolean;
  6612. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  6613. intersectsPlane(plane: Plane): Nullable<number>;
  6614. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  6615. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  6616. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  6617. private static smallnum;
  6618. private static rayl;
  6619. /**
  6620. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  6621. * @param sega the first point of the segment to test the intersection against
  6622. * @param segb the second point of the segment to test the intersection against
  6623. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  6624. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  6625. */
  6626. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  6627. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6628. static Zero(): Ray;
  6629. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  6630. /**
  6631. * 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
  6632. * transformed to the given world matrix.
  6633. * @param origin The origin point
  6634. * @param end The end point
  6635. * @param world a matrix to transform the ray to. Default is the identity matrix.
  6636. */
  6637. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  6638. static Transform(ray: Ray, matrix: Matrix): Ray;
  6639. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  6640. }
  6641. }
  6642. /**
  6643. * Module Debug contains the (visual) components to debug a scene correctly
  6644. */
  6645. declare module BABYLON.Debug {
  6646. /**
  6647. * The Axes viewer will show 3 axes in a specific point in space
  6648. */
  6649. class AxesViewer {
  6650. private _xline;
  6651. private _yline;
  6652. private _zline;
  6653. private _xmesh;
  6654. private _ymesh;
  6655. private _zmesh;
  6656. scene: Nullable<Scene>;
  6657. scaleLines: number;
  6658. constructor(scene: Scene, scaleLines?: number);
  6659. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  6660. dispose(): void;
  6661. }
  6662. }
  6663. declare module BABYLON.Debug {
  6664. /**
  6665. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  6666. */
  6667. class BoneAxesViewer extends AxesViewer {
  6668. mesh: Nullable<Mesh>;
  6669. bone: Nullable<Bone>;
  6670. pos: Vector3;
  6671. xaxis: Vector3;
  6672. yaxis: Vector3;
  6673. zaxis: Vector3;
  6674. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  6675. update(): void;
  6676. dispose(): void;
  6677. }
  6678. }
  6679. declare module BABYLON {
  6680. class DebugLayer {
  6681. private _scene;
  6682. static InspectorURL: string;
  6683. private _inspector;
  6684. private BJSINSPECTOR;
  6685. constructor(scene: Scene);
  6686. /** Creates the inspector window. */
  6687. private _createInspector(config?);
  6688. isVisible(): boolean;
  6689. hide(): void;
  6690. show(config?: {
  6691. popup?: boolean;
  6692. initialTab?: number;
  6693. parentElement?: HTMLElement;
  6694. newColors?: {
  6695. backgroundColor?: string;
  6696. backgroundColorLighter?: string;
  6697. backgroundColorLighter2?: string;
  6698. backgroundColorLighter3?: string;
  6699. color?: string;
  6700. colorTop?: string;
  6701. colorBot?: string;
  6702. };
  6703. }): void;
  6704. }
  6705. }
  6706. declare module BABYLON.Debug {
  6707. /**
  6708. * Used to show the physics impostor around the specific mesh.
  6709. */
  6710. class PhysicsViewer {
  6711. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  6712. protected _meshes: Array<Nullable<AbstractMesh>>;
  6713. protected _scene: Nullable<Scene>;
  6714. protected _numMeshes: number;
  6715. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  6716. private _renderFunction;
  6717. private _debugBoxMesh;
  6718. private _debugSphereMesh;
  6719. private _debugMaterial;
  6720. constructor(scene: Scene);
  6721. protected _updateDebugMeshes(): void;
  6722. showImpostor(impostor: PhysicsImpostor): void;
  6723. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  6724. private _getDebugMaterial(scene);
  6725. private _getDebugBoxMesh(scene);
  6726. private _getDebugSphereMesh(scene);
  6727. private _getDebugMesh(impostor, scene);
  6728. dispose(): void;
  6729. }
  6730. }
  6731. declare module BABYLON {
  6732. class RayHelper {
  6733. ray: Nullable<Ray>;
  6734. private _renderPoints;
  6735. private _renderLine;
  6736. private _renderFunction;
  6737. private _scene;
  6738. private _updateToMeshFunction;
  6739. private _attachedToMesh;
  6740. private _meshSpaceDirection;
  6741. private _meshSpaceOrigin;
  6742. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  6743. constructor(ray: Ray);
  6744. show(scene: Scene, color: Color3): void;
  6745. hide(): void;
  6746. private _render();
  6747. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  6748. detachFromMesh(): void;
  6749. private _updateToMesh();
  6750. dispose(): void;
  6751. }
  6752. }
  6753. declare module BABYLON.Debug {
  6754. /**
  6755. * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8
  6756. */
  6757. class SkeletonViewer {
  6758. skeleton: Skeleton;
  6759. mesh: AbstractMesh;
  6760. autoUpdateBonesMatrices: boolean;
  6761. renderingGroupId: number;
  6762. color: Color3;
  6763. private _scene;
  6764. private _debugLines;
  6765. private _debugMesh;
  6766. private _isEnabled;
  6767. private _renderFunction;
  6768. constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number);
  6769. isEnabled: boolean;
  6770. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  6771. private _getLinesForBonesWithLength(bones, meshMat);
  6772. private _getLinesForBonesNoLength(bones, meshMat);
  6773. update(): void;
  6774. dispose(): void;
  6775. }
  6776. }
  6777. declare module BABYLON {
  6778. /**
  6779. * Interface for attribute information associated with buffer instanciation
  6780. */
  6781. class InstancingAttributeInfo {
  6782. /**
  6783. * Index/offset of the attribute in the vertex shader
  6784. */
  6785. index: number;
  6786. /**
  6787. * size of the attribute, 1, 2, 3 or 4
  6788. */
  6789. attributeSize: number;
  6790. /**
  6791. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  6792. * default is FLOAT
  6793. */
  6794. attribyteType: number;
  6795. /**
  6796. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  6797. */
  6798. normalized: boolean;
  6799. /**
  6800. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  6801. */
  6802. offset: number;
  6803. /**
  6804. * Name of the GLSL attribute, for debugging purpose only
  6805. */
  6806. attributeName: string;
  6807. }
  6808. /**
  6809. * Define options used to create a render target texture
  6810. */
  6811. class RenderTargetCreationOptions {
  6812. /**
  6813. * Specifies is mipmaps must be generated
  6814. */
  6815. generateMipMaps?: boolean;
  6816. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6817. generateDepthBuffer?: boolean;
  6818. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6819. generateStencilBuffer?: boolean;
  6820. /** Defines texture type (int by default) */
  6821. type?: number;
  6822. /** Defines sampling mode (trilinear by default) */
  6823. samplingMode?: number;
  6824. /** Defines format (RGBA by default) */
  6825. format?: number;
  6826. }
  6827. /**
  6828. * Define options used to create a depth texture
  6829. */
  6830. class DepthTextureCreationOptions {
  6831. /** Specifies whether or not a stencil should be allocated in the texture */
  6832. generateStencil?: boolean;
  6833. /** Specifies whether or not bilinear filtering is enable on the texture */
  6834. bilinearFiltering?: boolean;
  6835. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  6836. comparisonFunction?: number;
  6837. /** Specifies if the created texture is a cube texture */
  6838. isCube?: boolean;
  6839. }
  6840. /**
  6841. * Class used to describe the capabilities of the engine relatively to the current browser
  6842. */
  6843. class EngineCapabilities {
  6844. /** Maximum textures units per fragment shader */
  6845. maxTexturesImageUnits: number;
  6846. /** Maximum texture units per vertex shader */
  6847. maxVertexTextureImageUnits: number;
  6848. /** Maximum textures units in the entire pipeline */
  6849. maxCombinedTexturesImageUnits: number;
  6850. /** Maximum texture size */
  6851. maxTextureSize: number;
  6852. /** Maximum cube texture size */
  6853. maxCubemapTextureSize: number;
  6854. /** Maximum render texture size */
  6855. maxRenderTextureSize: number;
  6856. /** Maximum number of vertex attributes */
  6857. maxVertexAttribs: number;
  6858. /** Maximum number of varyings */
  6859. maxVaryingVectors: number;
  6860. /** Maximum number of uniforms per vertex shader */
  6861. maxVertexUniformVectors: number;
  6862. /** Maximum number of uniforms per fragment shader */
  6863. maxFragmentUniformVectors: number;
  6864. /** Defines if standard derivates (dx/dy) are supported */
  6865. standardDerivatives: boolean;
  6866. /** Defines if s3tc texture compression is supported */
  6867. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  6868. /** Defines if pvrtc texture compression is supported */
  6869. pvrtc: any;
  6870. /** Defines if etc1 texture compression is supported */
  6871. etc1: any;
  6872. /** Defines if etc2 texture compression is supported */
  6873. etc2: any;
  6874. /** Defines if astc texture compression is supported */
  6875. astc: any;
  6876. /** Defines if float textures are supported */
  6877. textureFloat: boolean;
  6878. /** Defines if vertex array objects are supported */
  6879. vertexArrayObject: boolean;
  6880. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  6881. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  6882. /** Gets the maximum level of anisotropy supported */
  6883. maxAnisotropy: number;
  6884. /** Defines if instancing is supported */
  6885. instancedArrays: boolean;
  6886. /** Defines if 32 bits indices are supported */
  6887. uintIndices: boolean;
  6888. /** Defines if high precision shaders are supported */
  6889. highPrecisionShaderSupported: boolean;
  6890. /** Defines if depth reading in the fragment shader is supported */
  6891. fragmentDepthSupported: boolean;
  6892. /** Defines if float texture linear filtering is supported*/
  6893. textureFloatLinearFiltering: boolean;
  6894. /** Defines if rendering to float textures is supported */
  6895. textureFloatRender: boolean;
  6896. /** Defines if half float textures are supported*/
  6897. textureHalfFloat: boolean;
  6898. /** Defines if half float texture linear filtering is supported*/
  6899. textureHalfFloatLinearFiltering: boolean;
  6900. /** Defines if rendering to half float textures is supported */
  6901. textureHalfFloatRender: boolean;
  6902. /** Defines if textureLOD shader command is supported */
  6903. textureLOD: boolean;
  6904. /** Defines if draw buffers extension is supported */
  6905. drawBuffersExtension: boolean;
  6906. /** Defines if depth textures are supported */
  6907. depthTextureExtension: boolean;
  6908. /** Defines if float color buffer are supported */
  6909. colorBufferFloat: boolean;
  6910. /** Gets disjoint timer query extension (null if not supported) */
  6911. timerQuery: EXT_disjoint_timer_query;
  6912. /** Defines if timestamp can be used with timer query */
  6913. canUseTimestampForTimerQuery: boolean;
  6914. }
  6915. /** Interface defining initialization parameters for Engine class */
  6916. interface EngineOptions extends WebGLContextAttributes {
  6917. /**
  6918. * Defines if the engine should no exceed a specified device ratio
  6919. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  6920. */
  6921. limitDeviceRatio?: number;
  6922. /**
  6923. * Defines if webvr should be enabled automatically
  6924. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6925. */
  6926. autoEnableWebVR?: boolean;
  6927. /**
  6928. * Defines if webgl2 should be turned off even if supported
  6929. * @see http://doc.babylonjs.com/features/webgl2
  6930. */
  6931. disableWebGL2Support?: boolean;
  6932. /**
  6933. * Defines if webaudio should be initialized as well
  6934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6935. */
  6936. audioEngine?: boolean;
  6937. /**
  6938. * Defines if animations should run using a deterministic lock step
  6939. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6940. */
  6941. deterministicLockstep?: boolean;
  6942. /** Defines the maximum steps to use with deterministic lock step mode */
  6943. lockstepMaxSteps?: number;
  6944. /**
  6945. * Defines that engine should ignore context lost events
  6946. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  6947. */
  6948. doNotHandleContextLost?: boolean;
  6949. }
  6950. /**
  6951. * Defines the interface used by display changed events
  6952. */
  6953. interface IDisplayChangedEventArgs {
  6954. /** Gets the vrDisplay object (if any) */
  6955. vrDisplay: Nullable<any>;
  6956. /** Gets a boolean indicating if webVR is supported */
  6957. vrSupported: boolean;
  6958. }
  6959. /**
  6960. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  6961. */
  6962. class Engine {
  6963. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  6964. static ExceptionList: ({
  6965. key: string;
  6966. capture: string;
  6967. captureConstraint: number;
  6968. targets: string[];
  6969. } | {
  6970. key: string;
  6971. capture: null;
  6972. captureConstraint: null;
  6973. targets: string[];
  6974. })[];
  6975. /** Gets the list of created engines */
  6976. static Instances: Engine[];
  6977. /**
  6978. * Gets the latest created engine
  6979. */
  6980. static readonly LastCreatedEngine: Nullable<Engine>;
  6981. /**
  6982. * Gets the latest created scene
  6983. */
  6984. static readonly LastCreatedScene: Nullable<Scene>;
  6985. /**
  6986. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  6987. * @param flag defines which part of the materials must be marked as dirty
  6988. * @param predicate defines a predicate used to filter which materials should be affected
  6989. */
  6990. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  6991. private static _ALPHA_DISABLE;
  6992. private static _ALPHA_ADD;
  6993. private static _ALPHA_COMBINE;
  6994. private static _ALPHA_SUBTRACT;
  6995. private static _ALPHA_MULTIPLY;
  6996. private static _ALPHA_MAXIMIZED;
  6997. private static _ALPHA_ONEONE;
  6998. private static _ALPHA_PREMULTIPLIED;
  6999. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  7000. private static _ALPHA_INTERPOLATE;
  7001. private static _ALPHA_SCREENMODE;
  7002. private static _DELAYLOADSTATE_NONE;
  7003. private static _DELAYLOADSTATE_LOADED;
  7004. private static _DELAYLOADSTATE_LOADING;
  7005. private static _DELAYLOADSTATE_NOTLOADED;
  7006. private static _TEXTUREFORMAT_ALPHA;
  7007. private static _TEXTUREFORMAT_LUMINANCE;
  7008. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  7009. private static _TEXTUREFORMAT_RGB;
  7010. private static _TEXTUREFORMAT_RGBA;
  7011. private static _TEXTUREFORMAT_R32F;
  7012. private static _TEXTUREFORMAT_RG32F;
  7013. private static _TEXTUREFORMAT_RGB32F;
  7014. private static _TEXTUREFORMAT_RGBA32F;
  7015. private static _TEXTURETYPE_UNSIGNED_INT;
  7016. private static _TEXTURETYPE_FLOAT;
  7017. private static _TEXTURETYPE_HALF_FLOAT;
  7018. private static _NEVER;
  7019. private static _ALWAYS;
  7020. private static _LESS;
  7021. private static _EQUAL;
  7022. private static _LEQUAL;
  7023. private static _GREATER;
  7024. private static _GEQUAL;
  7025. private static _NOTEQUAL;
  7026. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  7027. static readonly NEVER: number;
  7028. /** 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 */
  7029. static readonly ALWAYS: number;
  7030. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  7031. static readonly LESS: number;
  7032. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  7033. static readonly EQUAL: number;
  7034. /** 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 */
  7035. static readonly LEQUAL: number;
  7036. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  7037. static readonly GREATER: number;
  7038. /** 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 */
  7039. static readonly GEQUAL: number;
  7040. /** 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 */
  7041. static readonly NOTEQUAL: number;
  7042. private static _KEEP;
  7043. private static _REPLACE;
  7044. private static _INCR;
  7045. private static _DECR;
  7046. private static _INVERT;
  7047. private static _INCR_WRAP;
  7048. private static _DECR_WRAP;
  7049. /** Passed to stencilOperation to specify that stencil value must be kept */
  7050. static readonly KEEP: number;
  7051. /** Passed to stencilOperation to specify that stencil value must be replaced */
  7052. static readonly REPLACE: number;
  7053. /** Passed to stencilOperation to specify that stencil value must be incremented */
  7054. static readonly INCR: number;
  7055. /** Passed to stencilOperation to specify that stencil value must be decremented */
  7056. static readonly DECR: number;
  7057. /** Passed to stencilOperation to specify that stencil value must be inverted */
  7058. static readonly INVERT: number;
  7059. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  7060. static readonly INCR_WRAP: number;
  7061. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  7062. static readonly DECR_WRAP: number;
  7063. /** Defines that alpha blending is disabled */
  7064. static readonly ALPHA_DISABLE: number;
  7065. /** Defines that alpha blending to SRC + DEST */
  7066. static readonly ALPHA_ONEONE: number;
  7067. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  7068. static readonly ALPHA_ADD: number;
  7069. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  7070. static readonly ALPHA_COMBINE: number;
  7071. /** Defines that alpha blending to DEST - SRC * DEST */
  7072. static readonly ALPHA_SUBTRACT: number;
  7073. /** Defines that alpha blending to SRC * DEST */
  7074. static readonly ALPHA_MULTIPLY: number;
  7075. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  7076. static readonly ALPHA_MAXIMIZED: number;
  7077. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  7078. static readonly ALPHA_PREMULTIPLIED: number;
  7079. /**
  7080. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  7081. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  7082. */
  7083. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  7084. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  7085. static readonly ALPHA_INTERPOLATE: number;
  7086. /**
  7087. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  7088. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  7089. */
  7090. static readonly ALPHA_SCREENMODE: number;
  7091. /** Defines that the ressource is not delayed*/
  7092. static readonly DELAYLOADSTATE_NONE: number;
  7093. /** Defines that the ressource was successfully delay loaded */
  7094. static readonly DELAYLOADSTATE_LOADED: number;
  7095. /** Defines that the ressource is currently delay loading */
  7096. static readonly DELAYLOADSTATE_LOADING: number;
  7097. /** Defines that the ressource is delayed and has not started loading */
  7098. static readonly DELAYLOADSTATE_NOTLOADED: number;
  7099. /** ALPHA */
  7100. static readonly TEXTUREFORMAT_ALPHA: number;
  7101. /** LUMINANCE */
  7102. static readonly TEXTUREFORMAT_LUMINANCE: number;
  7103. /**
  7104. * R32F
  7105. */
  7106. static readonly TEXTUREFORMAT_R32F: number;
  7107. /**
  7108. * RG32F
  7109. */
  7110. static readonly TEXTUREFORMAT_RG32F: number;
  7111. /**
  7112. * RGB32F
  7113. */
  7114. static readonly TEXTUREFORMAT_RGB32F: number;
  7115. /**
  7116. * RGBA32F
  7117. */
  7118. static readonly TEXTUREFORMAT_RGBA32F: number;
  7119. /** LUMINANCE_ALPHA */
  7120. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  7121. /** RGB */
  7122. static readonly TEXTUREFORMAT_RGB: number;
  7123. /** RGBA */
  7124. static readonly TEXTUREFORMAT_RGBA: number;
  7125. /** UNSIGNED_INT */
  7126. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  7127. /** FLOAT */
  7128. static readonly TEXTURETYPE_FLOAT: number;
  7129. /** HALF_FLOAT */
  7130. static readonly TEXTURETYPE_HALF_FLOAT: number;
  7131. private static _SCALEMODE_FLOOR;
  7132. private static _SCALEMODE_NEAREST;
  7133. private static _SCALEMODE_CEILING;
  7134. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  7135. static readonly SCALEMODE_FLOOR: number;
  7136. /** Defines that texture rescaling will look for the nearest power of 2 size */
  7137. static readonly SCALEMODE_NEAREST: number;
  7138. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  7139. static readonly SCALEMODE_CEILING: number;
  7140. /**
  7141. * Returns the current version of the framework
  7142. */
  7143. static readonly Version: string;
  7144. /**
  7145. * Gets or sets the epsilon value used by collision engine
  7146. */
  7147. static CollisionsEpsilon: number;
  7148. /**
  7149. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  7150. */
  7151. static CodeRepository: string;
  7152. /**
  7153. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7154. */
  7155. static ShadersRepository: string;
  7156. /**
  7157. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7158. */
  7159. forcePOTTextures: boolean;
  7160. /**
  7161. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7162. */
  7163. isFullscreen: boolean;
  7164. /**
  7165. * Gets a boolean indicating if the pointer is currently locked
  7166. */
  7167. isPointerLock: boolean;
  7168. /**
  7169. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7170. */
  7171. cullBackFaces: boolean;
  7172. /**
  7173. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7174. */
  7175. renderEvenInBackground: boolean;
  7176. /**
  7177. * Gets or sets a boolean indicating that cache can be kept between frames
  7178. */
  7179. preventCacheWipeBetweenFrames: boolean;
  7180. /**
  7181. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7182. **/
  7183. enableOfflineSupport: boolean;
  7184. /**
  7185. * 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)
  7186. **/
  7187. disableManifestCheck: boolean;
  7188. /**
  7189. * Gets the list of created scenes
  7190. */
  7191. scenes: Scene[];
  7192. /**
  7193. * Gets the list of created postprocesses
  7194. */
  7195. postProcesses: PostProcess[];
  7196. /**
  7197. * Observable event triggered each time the rendering canvas is resized
  7198. */
  7199. onResizeObservable: Observable<Engine>;
  7200. /**
  7201. * Observable event triggered each time the canvas loses focus
  7202. */
  7203. onCanvasBlurObservable: Observable<Engine>;
  7204. /**
  7205. * Observable event triggered each time the canvas gains focus
  7206. */
  7207. onCanvasFocusObservable: Observable<Engine>;
  7208. /**
  7209. * Observable event triggered each time the canvas receives pointerout event
  7210. */
  7211. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7212. /**
  7213. * Observable event triggered before each texture is initialized
  7214. */
  7215. onBeforeTextureInitObservable: Observable<Texture>;
  7216. private _vrDisplay;
  7217. private _vrSupported;
  7218. private _oldSize;
  7219. private _oldHardwareScaleFactor;
  7220. private _vrExclusivePointerMode;
  7221. private _webVRInitPromise;
  7222. /**
  7223. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7224. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7225. */
  7226. readonly isInVRExclusivePointerMode: boolean;
  7227. /**
  7228. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7229. */
  7230. disableUniformBuffers: boolean;
  7231. /** @hidden */
  7232. _uniformBuffers: UniformBuffer[];
  7233. /**
  7234. * Gets a boolean indicating that the engine supports uniform buffers
  7235. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7236. */
  7237. readonly supportsUniformBuffers: boolean;
  7238. /**
  7239. * Observable raised when the engine begins a new frame
  7240. */
  7241. onBeginFrameObservable: Observable<Engine>;
  7242. /**
  7243. * Observable raised when the engine ends the current frame
  7244. */
  7245. onEndFrameObservable: Observable<Engine>;
  7246. /**
  7247. * Observable raised when the engine is about to compile a shader
  7248. */
  7249. onBeforeShaderCompilationObservable: Observable<Engine>;
  7250. /**
  7251. * Observable raised when the engine has jsut compiled a shader
  7252. */
  7253. onAfterShaderCompilationObservable: Observable<Engine>;
  7254. private _gl;
  7255. private _renderingCanvas;
  7256. private _windowIsBackground;
  7257. private _webGLVersion;
  7258. /**
  7259. * Gets a boolean indicating that only power of 2 textures are supported
  7260. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7261. */
  7262. readonly needPOTTextures: boolean;
  7263. /** @hidden */
  7264. _badOS: boolean;
  7265. /** @hidden */
  7266. _badDesktopOS: boolean;
  7267. /**
  7268. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7269. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7270. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7271. */
  7272. disableTextureBindingOptimization: boolean;
  7273. /**
  7274. * Gets the audio engine
  7275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7276. * @ignorenaming
  7277. */
  7278. static audioEngine: AudioEngine;
  7279. private _onFocus;
  7280. private _onBlur;
  7281. private _onCanvasPointerOut;
  7282. private _onCanvasBlur;
  7283. private _onCanvasFocus;
  7284. private _onFullscreenChange;
  7285. private _onPointerLockChange;
  7286. private _onVRDisplayPointerRestricted;
  7287. private _onVRDisplayPointerUnrestricted;
  7288. private _onVrDisplayConnect;
  7289. private _onVrDisplayDisconnect;
  7290. private _onVrDisplayPresentChange;
  7291. /**
  7292. * Observable signaled when VR display mode changes
  7293. */
  7294. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7295. /**
  7296. * Observable signaled when VR request present is complete
  7297. */
  7298. onVRRequestPresentComplete: Observable<boolean>;
  7299. /**
  7300. * Observable signaled when VR request present starts
  7301. */
  7302. onVRRequestPresentStart: Observable<Engine>;
  7303. private _hardwareScalingLevel;
  7304. /** @hidden */
  7305. protected _caps: EngineCapabilities;
  7306. private _pointerLockRequested;
  7307. private _isStencilEnable;
  7308. private _colorWrite;
  7309. private _loadingScreen;
  7310. /** @hidden */
  7311. _drawCalls: PerfCounter;
  7312. /** @hidden */
  7313. _textureCollisions: PerfCounter;
  7314. private _glVersion;
  7315. private _glRenderer;
  7316. private _glVendor;
  7317. private _videoTextureSupported;
  7318. private _renderingQueueLaunched;
  7319. private _activeRenderLoops;
  7320. private _deterministicLockstep;
  7321. private _lockstepMaxSteps;
  7322. /**
  7323. * Observable signaled when a context lost event is raised
  7324. */
  7325. onContextLostObservable: Observable<Engine>;
  7326. /**
  7327. * Observable signaled when a context restored event is raised
  7328. */
  7329. onContextRestoredObservable: Observable<Engine>;
  7330. private _onContextLost;
  7331. private _onContextRestored;
  7332. private _contextWasLost;
  7333. private _doNotHandleContextLost;
  7334. private _performanceMonitor;
  7335. private _fps;
  7336. private _deltaTime;
  7337. /**
  7338. * Turn this value on if you want to pause FPS computation when in background
  7339. */
  7340. disablePerformanceMonitorInBackground: boolean;
  7341. /**
  7342. * Gets the performance monitor attached to this engine
  7343. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7344. */
  7345. readonly performanceMonitor: PerformanceMonitor;
  7346. /** @hidden */
  7347. protected _depthCullingState: _DepthCullingState;
  7348. /** @hidden */
  7349. protected _stencilState: _StencilState;
  7350. /** @hidden */
  7351. protected _alphaState: _AlphaState;
  7352. /** @hidden */
  7353. protected _alphaMode: number;
  7354. protected _internalTexturesCache: InternalTexture[];
  7355. /** @hidden */
  7356. protected _activeChannel: number;
  7357. private _currentTextureChannel;
  7358. /** @hidden */
  7359. protected _boundTexturesCache: {
  7360. [key: string]: Nullable<InternalTexture>;
  7361. };
  7362. /** @hidden */
  7363. protected _currentEffect: Nullable<Effect>;
  7364. /** @hidden */
  7365. protected _currentProgram: Nullable<WebGLProgram>;
  7366. private _compiledEffects;
  7367. private _vertexAttribArraysEnabled;
  7368. /** @hidden */
  7369. protected _cachedViewport: Nullable<Viewport>;
  7370. private _cachedVertexArrayObject;
  7371. /** @hidden */
  7372. protected _cachedVertexBuffers: any;
  7373. /** @hidden */
  7374. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7375. /** @hidden */
  7376. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7377. /** @hidden */
  7378. protected _currentRenderTarget: Nullable<InternalTexture>;
  7379. private _uintIndicesCurrentlySet;
  7380. private _currentBoundBuffer;
  7381. /** @hidden */
  7382. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7383. private _currentBufferPointers;
  7384. private _currentInstanceLocations;
  7385. private _currentInstanceBuffers;
  7386. private _textureUnits;
  7387. private _firstBoundInternalTextureTracker;
  7388. private _lastBoundInternalTextureTracker;
  7389. private _workingCanvas;
  7390. private _workingContext;
  7391. private _rescalePostProcess;
  7392. private _dummyFramebuffer;
  7393. private _externalData;
  7394. private _bindedRenderFunction;
  7395. private _vaoRecordInProgress;
  7396. private _mustWipeVertexAttributes;
  7397. private _emptyTexture;
  7398. private _emptyCubeTexture;
  7399. private _emptyTexture3D;
  7400. private _frameHandler;
  7401. private _nextFreeTextureSlots;
  7402. private _maxSimultaneousTextures;
  7403. private _activeRequests;
  7404. private _texturesSupported;
  7405. private _textureFormatInUse;
  7406. /**
  7407. * Gets the list of texture formats supported
  7408. */
  7409. readonly texturesSupported: Array<string>;
  7410. /**
  7411. * Gets the list of texture formats in use
  7412. */
  7413. readonly textureFormatInUse: Nullable<string>;
  7414. /**
  7415. * Gets the current viewport
  7416. */
  7417. readonly currentViewport: Nullable<Viewport>;
  7418. /**
  7419. * Gets the default empty texture
  7420. */
  7421. readonly emptyTexture: InternalTexture;
  7422. /**
  7423. * Gets the default empty 3D texture
  7424. */
  7425. readonly emptyTexture3D: InternalTexture;
  7426. /**
  7427. * Gets the default empty cube texture
  7428. */
  7429. readonly emptyCubeTexture: InternalTexture;
  7430. /**
  7431. * Creates a new engine
  7432. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  7433. * @param antialias defines enable antialiasing (default: false)
  7434. * @param options defines further options to be sent to the getContext() function
  7435. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7436. */
  7437. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7438. private _rebuildInternalTextures();
  7439. private _rebuildEffects();
  7440. private _rebuildBuffers();
  7441. private _initGLContext();
  7442. /**
  7443. * Gets version of the current webGL context
  7444. */
  7445. readonly webGLVersion: number;
  7446. /**
  7447. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7448. */
  7449. readonly isStencilEnable: boolean;
  7450. private _prepareWorkingCanvas();
  7451. /**
  7452. * Reset the texture cache to empty state
  7453. */
  7454. resetTextureCache(): void;
  7455. /**
  7456. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7457. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7458. * @returns true if engine is in deterministic lock step mode
  7459. */
  7460. isDeterministicLockStep(): boolean;
  7461. /**
  7462. * Gets the max steps when engine is running in deterministic lock step
  7463. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7464. * @returns the max steps
  7465. */
  7466. getLockstepMaxSteps(): number;
  7467. /**
  7468. * Gets an object containing information about the current webGL context
  7469. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7470. */
  7471. getGlInfo(): {
  7472. vendor: string;
  7473. renderer: string;
  7474. version: string;
  7475. };
  7476. /**
  7477. * Gets current aspect ratio
  7478. * @param camera defines the camera to use to get the aspect ratio
  7479. * @param useScreen defines if screen size must be used (or the current render target if any)
  7480. * @returns a number defining the aspect ratio
  7481. */
  7482. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7483. /**
  7484. * Gets current screen aspect ratio
  7485. * @returns a number defining the aspect ratio
  7486. */
  7487. getScreenAspectRatio(): number;
  7488. /**
  7489. * Gets the current render width
  7490. * @param useScreen defines if screen size must be used (or the current render target if any)
  7491. * @returns a number defining the current render width
  7492. */
  7493. getRenderWidth(useScreen?: boolean): number;
  7494. /**
  7495. * Gets the current render height
  7496. * @param useScreen defines if screen size must be used (or the current render target if any)
  7497. * @returns a number defining the current render height
  7498. */
  7499. getRenderHeight(useScreen?: boolean): number;
  7500. /**
  7501. * Gets the HTML canvas attached with the current webGL context
  7502. * @returns a HTML canvas
  7503. */
  7504. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7505. /**
  7506. * Gets the client rect of the HTML canvas attached with the current webGL context
  7507. * @returns a client rectanglee
  7508. */
  7509. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7510. /**
  7511. * Defines the hardware scaling level.
  7512. * By default the hardware scaling level is computed from the window device ratio.
  7513. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  7514. * @param level defines the level to use
  7515. */
  7516. setHardwareScalingLevel(level: number): void;
  7517. /**
  7518. * Gets the current hardware scaling level.
  7519. * By default the hardware scaling level is computed from the window device ratio.
  7520. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  7521. * @returns a number indicating the current hardware scaling level
  7522. */
  7523. getHardwareScalingLevel(): number;
  7524. /**
  7525. * Gets the list of loaded textures
  7526. * @returns an array containing all loaded textures
  7527. */
  7528. getLoadedTexturesCache(): InternalTexture[];
  7529. /**
  7530. * Gets the object containing all engine capabilities
  7531. * @returns the EngineCapabilities object
  7532. */
  7533. getCaps(): EngineCapabilities;
  7534. /** @hidden */
  7535. readonly drawCalls: number;
  7536. /** @hidden */
  7537. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  7538. /**
  7539. * Gets the current depth function
  7540. * @returns a number defining the depth function
  7541. */
  7542. getDepthFunction(): Nullable<number>;
  7543. /**
  7544. * Sets the current depth function
  7545. * @param depthFunc defines the function to use
  7546. */
  7547. setDepthFunction(depthFunc: number): void;
  7548. /**
  7549. * Sets the current depth function to GREATER
  7550. */
  7551. setDepthFunctionToGreater(): void;
  7552. /**
  7553. * Sets the current depth function to GEQUAL
  7554. */
  7555. setDepthFunctionToGreaterOrEqual(): void;
  7556. /**
  7557. * Sets the current depth function to LESS
  7558. */
  7559. setDepthFunctionToLess(): void;
  7560. /**
  7561. * Sets the current depth function to LEQUAL
  7562. */
  7563. setDepthFunctionToLessOrEqual(): void;
  7564. /**
  7565. * Gets a boolean indicating if stencil buffer is enabled
  7566. * @returns the current stencil buffer state
  7567. */
  7568. getStencilBuffer(): boolean;
  7569. /**
  7570. * Enable or disable the stencil buffer
  7571. * @param enable defines if the stencil buffer must be enabled or disabled
  7572. */
  7573. setStencilBuffer(enable: boolean): void;
  7574. /**
  7575. * Gets the current stencil mask
  7576. * @returns a number defining the new stencil mask to use
  7577. */
  7578. getStencilMask(): number;
  7579. /**
  7580. * Sets the current stencil mask
  7581. * @param mask defines the new stencil mask to use
  7582. */
  7583. setStencilMask(mask: number): void;
  7584. /**
  7585. * Gets the current stencil function
  7586. * @returns a number defining the stencil function to use
  7587. */
  7588. getStencilFunction(): number;
  7589. /**
  7590. * Gets the current stencil reference value
  7591. * @returns a number defining the stencil reference value to use
  7592. */
  7593. getStencilFunctionReference(): number;
  7594. /**
  7595. * Gets the current stencil mask
  7596. * @returns a number defining the stencil mask to use
  7597. */
  7598. getStencilFunctionMask(): number;
  7599. /**
  7600. * Sets the current stencil function
  7601. * @param stencilFunc defines the new stencil function to use
  7602. */
  7603. setStencilFunction(stencilFunc: number): void;
  7604. /**
  7605. * Sets the current stencil reference
  7606. * @param reference defines the new stencil reference to use
  7607. */
  7608. setStencilFunctionReference(reference: number): void;
  7609. /**
  7610. * Sets the current stencil mask
  7611. * @param mask defines the new stencil mask to use
  7612. */
  7613. setStencilFunctionMask(mask: number): void;
  7614. /**
  7615. * Gets the current stencil operation when stencil fails
  7616. * @returns a number defining stencil operation to use when stencil fails
  7617. */
  7618. getStencilOperationFail(): number;
  7619. /**
  7620. * Gets the current stencil operation when depth fails
  7621. * @returns a number defining stencil operation to use when depth fails
  7622. */
  7623. getStencilOperationDepthFail(): number;
  7624. /**
  7625. * Gets the current stencil operation when stencil passes
  7626. * @returns a number defining stencil operation to use when stencil passes
  7627. */
  7628. getStencilOperationPass(): number;
  7629. /**
  7630. * Sets the stencil operation to use when stencil fails
  7631. * @param operation defines the stencil operation to use when stencil fails
  7632. */
  7633. setStencilOperationFail(operation: number): void;
  7634. /**
  7635. * Sets the stencil operation to use when depth fails
  7636. * @param operation defines the stencil operation to use when depth fails
  7637. */
  7638. setStencilOperationDepthFail(operation: number): void;
  7639. /**
  7640. * Sets the stencil operation to use when stencil passes
  7641. * @param operation defines the stencil operation to use when stencil passes
  7642. */
  7643. setStencilOperationPass(operation: number): void;
  7644. /**
  7645. * Sets a boolean indicating if the dithering state is enabled or disabled
  7646. * @param value defines the dithering state
  7647. */
  7648. setDitheringState(value: boolean): void;
  7649. /**
  7650. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  7651. * @param value defines the rasterizer state
  7652. */
  7653. setRasterizerState(value: boolean): void;
  7654. /**
  7655. * stop executing a render loop function and remove it from the execution array
  7656. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  7657. */
  7658. stopRenderLoop(renderFunction?: () => void): void;
  7659. /** @hidden */
  7660. _renderLoop(): void;
  7661. /**
  7662. * Register and execute a render loop. The engine can have more than one render function
  7663. * @param renderFunction defines the function to continuously execute
  7664. */
  7665. runRenderLoop(renderFunction: () => void): void;
  7666. /**
  7667. * Toggle full screen mode
  7668. * @param requestPointerLock defines if a pointer lock should be requested from the user
  7669. * @param options defines an option object to be sent to the requestFullscreen function
  7670. */
  7671. switchFullscreen(requestPointerLock: boolean): void;
  7672. /**
  7673. * Clear the current render buffer or the current render target (if any is set up)
  7674. * @param color defines the color to use
  7675. * @param backBuffer defines if the back buffer must be cleared
  7676. * @param depth defines if the depth buffer must be cleared
  7677. * @param stencil defines if the stencil buffer must be cleared
  7678. */
  7679. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  7680. /**
  7681. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  7682. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  7683. * @param y defines the y-coordinate of the corner of the clear rectangle
  7684. * @param width defines the width of the clear rectangle
  7685. * @param height defines the height of the clear rectangle
  7686. * @param clearColor defines the clear color
  7687. */
  7688. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  7689. /**
  7690. * Set the WebGL's viewport
  7691. * @param viewport defines the viewport element to be used
  7692. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  7693. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  7694. */
  7695. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  7696. /**
  7697. * Directly set the WebGL Viewport
  7698. * @param x defines the x coordinate of the viewport (in screen space)
  7699. * @param y defines the y coordinate of the viewport (in screen space)
  7700. * @param width defines the width of the viewport (in screen space)
  7701. * @param height defines the height of the viewport (in screen space)
  7702. * @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
  7703. */
  7704. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  7705. /**
  7706. * Begin a new frame
  7707. */
  7708. beginFrame(): void;
  7709. /**
  7710. * Enf the current frame
  7711. */
  7712. endFrame(): void;
  7713. /**
  7714. * Resize the view according to the canvas' size
  7715. */
  7716. resize(): void;
  7717. /**
  7718. * Force a specific size of the canvas
  7719. * @param width defines the new canvas' width
  7720. * @param height defines the new canvas' height
  7721. */
  7722. setSize(width: number, height: number): void;
  7723. /**
  7724. * Gets a boolean indicating if a webVR device was detected
  7725. * @returns true if a webVR device was detected
  7726. */
  7727. isVRDevicePresent(): boolean;
  7728. /**
  7729. * Gets the current webVR device
  7730. * @returns the current webVR device (or null)
  7731. */
  7732. getVRDevice(): any;
  7733. /**
  7734. * Initializes a webVR display and starts listening to display change events
  7735. * The onVRDisplayChangedObservable will be notified upon these changes
  7736. * @returns The onVRDisplayChangedObservable
  7737. */
  7738. initWebVR(): Observable<IDisplayChangedEventArgs>;
  7739. /**
  7740. * Initializes a webVR display and starts listening to display change events
  7741. * The onVRDisplayChangedObservable will be notified upon these changes
  7742. * @returns A promise containing a VRDisplay and if vr is supported
  7743. */
  7744. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  7745. /**
  7746. * Call this function to switch to webVR mode
  7747. * Will do nothing if webVR is not supported or if there is no webVR device
  7748. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7749. */
  7750. enableVR(): void;
  7751. /**
  7752. * Call this function to leave webVR mode
  7753. * Will do nothing if webVR is not supported or if there is no webVR device
  7754. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7755. */
  7756. disableVR(): void;
  7757. private _onVRFullScreenTriggered;
  7758. private _getVRDisplaysAsync();
  7759. /**
  7760. * Binds the frame buffer to the specified texture.
  7761. * @param texture The texture to render to or null for the default canvas
  7762. * @param faceIndex The face of the texture to render to in case of cube texture
  7763. * @param requiredWidth The width of the target to render to
  7764. * @param requiredHeight The height of the target to render to
  7765. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  7766. * @param depthStencilTexture The depth stencil texture to use to render
  7767. */
  7768. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture): void;
  7769. private bindUnboundFramebuffer(framebuffer);
  7770. /**
  7771. * Unbind the current render target texture from the webGL context
  7772. * @param texture defines the render target texture to unbind
  7773. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7774. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7775. */
  7776. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7777. /**
  7778. * Unbind a list of render target textures from the webGL context
  7779. * This is used only when drawBuffer extension or webGL2 are active
  7780. * @param textures defines the render target textures to unbind
  7781. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7782. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7783. */
  7784. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7785. /**
  7786. * Force the mipmap generation for the given render target texture
  7787. * @param texture defines the render target texture to use
  7788. */
  7789. generateMipMapsForCubemap(texture: InternalTexture): void;
  7790. /**
  7791. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  7792. */
  7793. flushFramebuffer(): void;
  7794. /**
  7795. * Unbind the current render target and bind the default framebuffer
  7796. */
  7797. restoreDefaultFramebuffer(): void;
  7798. /**
  7799. * Create an uniform buffer
  7800. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7801. * @param elements defines the content of the uniform buffer
  7802. * @returns the webGL uniform buffer
  7803. */
  7804. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  7805. /**
  7806. * Create a dynamic uniform buffer
  7807. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7808. * @param elements defines the content of the uniform buffer
  7809. * @returns the webGL uniform buffer
  7810. */
  7811. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  7812. /**
  7813. * Update an existing uniform buffer
  7814. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7815. * @param uniformBuffer defines the target uniform buffer
  7816. * @param elements defines the content to update
  7817. * @param offset defines the offset in the uniform buffer where update should start
  7818. * @param count defines the size of the data to update
  7819. */
  7820. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7821. private _resetVertexBufferBinding();
  7822. /**
  7823. * Creates a vertex buffer
  7824. * @param data the data for the vertex buffer
  7825. * @returns the new WebGL static buffer
  7826. */
  7827. createVertexBuffer(data: DataArray): WebGLBuffer;
  7828. /**
  7829. * Creates a dynamic vertex buffer
  7830. * @param data the data for the dynamic vertex buffer
  7831. * @returns the new WebGL dynamic buffer
  7832. */
  7833. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  7834. /**
  7835. * Update a dynamic index buffer
  7836. * @param indexBuffer defines the target index buffer
  7837. * @param indices defines the data to update
  7838. * @param offset defines the offset in the target index buffer where update should start
  7839. */
  7840. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  7841. /**
  7842. * Updates a dynamic vertex buffer.
  7843. * @param vertexBuffer the vertex buffer to update
  7844. * @param data the data used to update the vertex buffer
  7845. * @param byteOffset the byte offset of the data
  7846. * @param byteLength the byte length of the data
  7847. */
  7848. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  7849. private _resetIndexBufferBinding();
  7850. /**
  7851. * Creates a new index buffer
  7852. * @param indices defines the content of the index buffer
  7853. * @param updatable defines if the index buffer must be updatable
  7854. * @returns a new webGL buffer
  7855. */
  7856. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  7857. /**
  7858. * Bind a webGL buffer to the webGL context
  7859. * @param buffer defines the buffer to bind
  7860. */
  7861. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  7862. /**
  7863. * Bind an uniform buffer to the current webGL context
  7864. * @param buffer defines the buffer to bind
  7865. */
  7866. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  7867. /**
  7868. * Bind a buffer to the current webGL context at a given location
  7869. * @param buffer defines the buffer to bind
  7870. * @param location defines the index where to bind the buffer
  7871. */
  7872. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  7873. /**
  7874. * Bind a specific block at a given index in a specific shader program
  7875. * @param shaderProgram defines the shader program
  7876. * @param blockName defines the block name
  7877. * @param index defines the index where to bind the block
  7878. */
  7879. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  7880. private bindIndexBuffer(buffer);
  7881. private bindBuffer(buffer, target);
  7882. /**
  7883. * update the bound buffer with the given data
  7884. * @param data defines the data to update
  7885. */
  7886. updateArrayBuffer(data: Float32Array): void;
  7887. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  7888. private _bindIndexBufferWithCache(indexBuffer);
  7889. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  7890. /**
  7891. * Records a vertex array object
  7892. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7893. * @param vertexBuffers defines the list of vertex buffers to store
  7894. * @param indexBuffer defines the index buffer to store
  7895. * @param effect defines the effect to store
  7896. * @returns the new vertex array object
  7897. */
  7898. recordVertexArrayObject(vertexBuffers: {
  7899. [key: string]: VertexBuffer;
  7900. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  7901. /**
  7902. * Bind a specific vertex array object
  7903. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7904. * @param vertexArrayObject defines the vertex array object to bind
  7905. * @param indexBuffer defines the index buffer to bind
  7906. */
  7907. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  7908. /**
  7909. * Bind webGl buffers directly to the webGL context
  7910. * @param vertexBuffer defines the vertex buffer to bind
  7911. * @param indexBuffer defines the index buffer to bind
  7912. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  7913. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  7914. * @param effect defines the effect associated with the vertex buffer
  7915. */
  7916. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  7917. private _unbindVertexArrayObject();
  7918. /**
  7919. * Bind a list of vertex buffers to the webGL context
  7920. * @param vertexBuffers defines the list of vertex buffers to bind
  7921. * @param indexBuffer defines the index buffer to bind
  7922. * @param effect defines the effect associated with the vertex buffers
  7923. */
  7924. bindBuffers(vertexBuffers: {
  7925. [key: string]: Nullable<VertexBuffer>;
  7926. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  7927. /**
  7928. * Unbind all instance attributes
  7929. */
  7930. unbindInstanceAttributes(): void;
  7931. /**
  7932. * Release and free the memory of a vertex array object
  7933. * @param vao defines the vertex array object to delete
  7934. */
  7935. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  7936. /** @hidden */
  7937. _releaseBuffer(buffer: WebGLBuffer): boolean;
  7938. /**
  7939. * Creates a webGL buffer to use with instanciation
  7940. * @param capacity defines the size of the buffer
  7941. * @returns the webGL buffer
  7942. */
  7943. createInstancesBuffer(capacity: number): WebGLBuffer;
  7944. /**
  7945. * Delete a webGL buffer used with instanciation
  7946. * @param buffer defines the webGL buffer to delete
  7947. */
  7948. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  7949. /**
  7950. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  7951. * @param instancesBuffer defines the webGL buffer to update and bind
  7952. * @param data defines the data to store in the buffer
  7953. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  7954. */
  7955. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  7956. /**
  7957. * Apply all cached states (depth, culling, stencil and alpha)
  7958. */
  7959. applyStates(): void;
  7960. /**
  7961. * Send a draw order
  7962. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7963. * @param indexStart defines the starting index
  7964. * @param indexCount defines the number of index to draw
  7965. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7966. */
  7967. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  7968. /**
  7969. * Draw a list of points
  7970. * @param verticesStart defines the index of first vertex to draw
  7971. * @param verticesCount defines the count of vertices to draw
  7972. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7973. */
  7974. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7975. /**
  7976. * Draw a list of unindexed primitives
  7977. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7978. * @param verticesStart defines the index of first vertex to draw
  7979. * @param verticesCount defines the count of vertices to draw
  7980. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7981. */
  7982. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7983. /**
  7984. * Draw a list of indexed primitives
  7985. * @param fillMode defines the primitive to use
  7986. * @param indexStart defines the starting index
  7987. * @param indexCount defines the number of index to draw
  7988. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7989. */
  7990. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  7991. /**
  7992. * Draw a list of unindexed primitives
  7993. * @param fillMode defines the primitive to use
  7994. * @param verticesStart defines the index of first vertex to draw
  7995. * @param verticesCount defines the count of vertices to draw
  7996. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7997. */
  7998. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7999. private _drawMode(fillMode);
  8000. /** @hidden */
  8001. _releaseEffect(effect: Effect): void;
  8002. /** @hidden */
  8003. _deleteProgram(program: WebGLProgram): void;
  8004. /**
  8005. * Create a new effect (used to store vertex/fragment shaders)
  8006. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  8007. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  8008. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  8009. * @param samplers defines an array of string used to represent textures
  8010. * @param defines defines the string containing the defines to use to compile the shaders
  8011. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8012. * @param onCompiled defines a function to call when the effect creation is successful
  8013. * @param onError defines a function to call when the effect creation has failed
  8014. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  8015. * @returns the new Effect
  8016. */
  8017. 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;
  8018. /**
  8019. * Create an effect to use with particle systems
  8020. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  8021. * @param uniformsNames defines a list of attribute names
  8022. * @param samplers defines an array of string used to represent textures
  8023. * @param defines defines the string containing the defines to use to compile the shaders
  8024. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8025. * @param onCompiled defines a function to call when the effect creation is successful
  8026. * @param onError defines a function to call when the effect creation has failed
  8027. * @returns the new Effect
  8028. */
  8029. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  8030. /**
  8031. * Directly creates a webGL program
  8032. * @param vertexCode defines the vertex shader code to use
  8033. * @param fragmentCode defines the fragment shader code to use
  8034. * @param context defines the webGL context to use (if not set, the current one will be used)
  8035. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8036. * @returns the new webGL program
  8037. */
  8038. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8039. /**
  8040. * Creates a webGL program
  8041. * @param vertexCode defines the vertex shader code to use
  8042. * @param fragmentCode defines the fragment shader code to use
  8043. * @param defines defines the string containing the defines to use to compile the shaders
  8044. * @param context defines the webGL context to use (if not set, the current one will be used)
  8045. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8046. * @returns the new webGL program
  8047. */
  8048. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8049. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  8050. /**
  8051. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  8052. * @param shaderProgram defines the webGL program to use
  8053. * @param uniformsNames defines the list of uniform names
  8054. * @returns an array of webGL uniform locations
  8055. */
  8056. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  8057. /**
  8058. * Gets the lsit of active attributes for a given webGL program
  8059. * @param shaderProgram defines the webGL program to use
  8060. * @param attributesNames defines the list of attribute names to get
  8061. * @returns an array of indices indicating the offset of each attribute
  8062. */
  8063. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8064. /**
  8065. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  8066. * @param effect defines the effect to activate
  8067. */
  8068. enableEffect(effect: Nullable<Effect>): void;
  8069. /**
  8070. * Set the value of an uniform to an array of int32
  8071. * @param uniform defines the webGL uniform location where to store the value
  8072. * @param array defines the array of int32 to store
  8073. */
  8074. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8075. /**
  8076. * Set the value of an uniform to an array of int32 (stored as vec2)
  8077. * @param uniform defines the webGL uniform location where to store the value
  8078. * @param array defines the array of int32 to store
  8079. */
  8080. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8081. /**
  8082. * Set the value of an uniform to an array of int32 (stored as vec3)
  8083. * @param uniform defines the webGL uniform location where to store the value
  8084. * @param array defines the array of int32 to store
  8085. */
  8086. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8087. /**
  8088. * Set the value of an uniform to an array of int32 (stored as vec4)
  8089. * @param uniform defines the webGL uniform location where to store the value
  8090. * @param array defines the array of int32 to store
  8091. */
  8092. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8093. /**
  8094. * Set the value of an uniform to an array of float32
  8095. * @param uniform defines the webGL uniform location where to store the value
  8096. * @param array defines the array of float32 to store
  8097. */
  8098. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8099. /**
  8100. * Set the value of an uniform to an array of float32 (stored as vec2)
  8101. * @param uniform defines the webGL uniform location where to store the value
  8102. * @param array defines the array of float32 to store
  8103. */
  8104. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8105. /**
  8106. * Set the value of an uniform to an array of float32 (stored as vec3)
  8107. * @param uniform defines the webGL uniform location where to store the value
  8108. * @param array defines the array of float32 to store
  8109. */
  8110. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8111. /**
  8112. * Set the value of an uniform to an array of float32 (stored as vec4)
  8113. * @param uniform defines the webGL uniform location where to store the value
  8114. * @param array defines the array of float32 to store
  8115. */
  8116. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8117. /**
  8118. * Set the value of an uniform to an array of number
  8119. * @param uniform defines the webGL uniform location where to store the value
  8120. * @param array defines the array of number to store
  8121. */
  8122. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8123. /**
  8124. * Set the value of an uniform to an array of number (stored as vec2)
  8125. * @param uniform defines the webGL uniform location where to store the value
  8126. * @param array defines the array of number to store
  8127. */
  8128. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8129. /**
  8130. * Set the value of an uniform to an array of number (stored as vec3)
  8131. * @param uniform defines the webGL uniform location where to store the value
  8132. * @param array defines the array of number to store
  8133. */
  8134. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8135. /**
  8136. * Set the value of an uniform to an array of number (stored as vec4)
  8137. * @param uniform defines the webGL uniform location where to store the value
  8138. * @param array defines the array of number to store
  8139. */
  8140. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8141. /**
  8142. * Set the value of an uniform to an array of float32 (stored as matrices)
  8143. * @param uniform defines the webGL uniform location where to store the value
  8144. * @param matrices defines the array of float32 to store
  8145. */
  8146. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  8147. /**
  8148. * Set the value of an uniform to a matrix
  8149. * @param uniform defines the webGL uniform location where to store the value
  8150. * @param matrix defines the matrix to store
  8151. */
  8152. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  8153. /**
  8154. * Set the value of an uniform to a matrix (3x3)
  8155. * @param uniform defines the webGL uniform location where to store the value
  8156. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8157. */
  8158. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8159. /**
  8160. * Set the value of an uniform to a matrix (2x2)
  8161. * @param uniform defines the webGL uniform location where to store the value
  8162. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8163. */
  8164. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8165. /**
  8166. * Set the value of an uniform to a number (int)
  8167. * @param uniform defines the webGL uniform location where to store the value
  8168. * @param value defines the int number to store
  8169. */
  8170. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8171. /**
  8172. * Set the value of an uniform to a number (float)
  8173. * @param uniform defines the webGL uniform location where to store the value
  8174. * @param value defines the float number to store
  8175. */
  8176. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8177. /**
  8178. * Set the value of an uniform to a vec2
  8179. * @param uniform defines the webGL uniform location where to store the value
  8180. * @param x defines the 1st component of the value
  8181. * @param y defines the 2nd component of the value
  8182. */
  8183. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8184. /**
  8185. * Set the value of an uniform to a vec3
  8186. * @param uniform defines the webGL uniform location where to store the value
  8187. * @param x defines the 1st component of the value
  8188. * @param y defines the 2nd component of the value
  8189. * @param z defines the 3rd component of the value
  8190. */
  8191. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8192. /**
  8193. * Set the value of an uniform to a boolean
  8194. * @param uniform defines the webGL uniform location where to store the value
  8195. * @param bool defines the boolean to store
  8196. */
  8197. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8198. /**
  8199. * Set the value of an uniform to a vec4
  8200. * @param uniform defines the webGL uniform location where to store the value
  8201. * @param x defines the 1st component of the value
  8202. * @param y defines the 2nd component of the value
  8203. * @param z defines the 3rd component of the value
  8204. * @param w defines the 4th component of the value
  8205. */
  8206. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8207. /**
  8208. * Set the value of an uniform to a Color3
  8209. * @param uniform defines the webGL uniform location where to store the value
  8210. * @param color3 defines the color to store
  8211. */
  8212. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8213. /**
  8214. * Set the value of an uniform to a Color3 and an alpha value
  8215. * @param uniform defines the webGL uniform location where to store the value
  8216. * @param color3 defines the color to store
  8217. * @param alpha defines the alpha component to store
  8218. */
  8219. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8220. /**
  8221. * Sets a Color4 on a uniform variable
  8222. * @param uniform defines the uniform location
  8223. * @param color4 defines the value to be set
  8224. */
  8225. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8226. /**
  8227. * Set various states to the webGL context
  8228. * @param culling defines backface culling state
  8229. * @param zOffset defines the value to apply to zOffset (0 by default)
  8230. * @param force defines if states must be applied even if cache is up to date
  8231. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8232. */
  8233. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8234. /**
  8235. * Set the z offset to apply to current rendering
  8236. * @param value defines the offset to apply
  8237. */
  8238. setZOffset(value: number): void;
  8239. /**
  8240. * Gets the current value of the zOffset
  8241. * @returns the current zOffset state
  8242. */
  8243. getZOffset(): number;
  8244. /**
  8245. * Enable or disable depth buffering
  8246. * @param enable defines the state to set
  8247. */
  8248. setDepthBuffer(enable: boolean): void;
  8249. /**
  8250. * Gets a boolean indicating if depth writing is enabled
  8251. * @returns the current depth writing state
  8252. */
  8253. getDepthWrite(): boolean;
  8254. /**
  8255. * Enable or disable depth writing
  8256. * @param enable defines the state to set
  8257. */
  8258. setDepthWrite(enable: boolean): void;
  8259. /**
  8260. * Enable or disable color writing
  8261. * @param enable defines the state to set
  8262. */
  8263. setColorWrite(enable: boolean): void;
  8264. /**
  8265. * Gets a boolean indicating if color writing is enabled
  8266. * @returns the current color writing state
  8267. */
  8268. getColorWrite(): boolean;
  8269. /**
  8270. * Sets alpha constants used by some alpha blending modes
  8271. * @param r defines the red component
  8272. * @param g defines the green component
  8273. * @param b defines the blue component
  8274. * @param a defines the alpha component
  8275. */
  8276. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8277. /**
  8278. * Sets the current alpha mode
  8279. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8280. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8281. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8282. */
  8283. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8284. /**
  8285. * Gets the current alpha mode
  8286. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8287. * @returns the current alpha mode
  8288. */
  8289. getAlphaMode(): number;
  8290. /**
  8291. * Force the entire cache to be cleared
  8292. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8293. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8294. */
  8295. wipeCaches(bruteForce?: boolean): void;
  8296. /**
  8297. * Set the compressed texture format to use, based on the formats you have, and the formats
  8298. * supported by the hardware / browser.
  8299. *
  8300. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8301. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8302. * to API arguments needed to compressed textures. This puts the burden on the container
  8303. * generator to house the arcane code for determining these for current & future formats.
  8304. *
  8305. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8306. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8307. *
  8308. * Note: The result of this call is not taken into account when a texture is base64.
  8309. *
  8310. * @param formatsAvailable defines the list of those format families you have created
  8311. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8312. *
  8313. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8314. * @returns The extension selected.
  8315. */
  8316. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8317. /** @hidden */
  8318. _createTexture(): WebGLTexture;
  8319. /**
  8320. * Usually called from BABYLON.Texture.ts.
  8321. * Passed information to create a WebGLTexture
  8322. * @param urlArg defines a value which contains one of the following:
  8323. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8324. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8325. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8326. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8327. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8328. * @param scene needed for loading to the correct scene
  8329. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8330. * @param onLoad optional callback to be called upon successful completion
  8331. * @param onError optional callback to be called upon failure
  8332. * @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
  8333. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8334. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8335. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8336. */
  8337. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>): InternalTexture;
  8338. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  8339. /**
  8340. * Update a raw texture
  8341. * @param texture defines the texture to update
  8342. * @param data defines the data to store in the texture
  8343. * @param format defines the format of the data
  8344. * @param invertY defines if data must be stored with Y axis inverted
  8345. * @param compression defines the compression used (null by default)
  8346. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8347. */
  8348. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8349. /**
  8350. * Creates a raw texture
  8351. * @param data defines the data to store in the texture
  8352. * @param width defines the width of the texture
  8353. * @param height defines the height of the texture
  8354. * @param format defines the format of the data
  8355. * @param generateMipMaps defines if the engine should generate the mip levels
  8356. * @param invertY defines if data must be stored with Y axis inverted
  8357. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8358. * @param compression defines the compression used (null by default)
  8359. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8360. * @returns the raw texture inside an InternalTexture
  8361. */
  8362. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8363. /**
  8364. * Creates a dynamic texture
  8365. * @param width defines the width of the texture
  8366. * @param height defines the height of the texture
  8367. * @param generateMipMaps defines if the engine should generate the mip levels
  8368. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8369. * @returns the dynamic texture inside an InternalTexture
  8370. */
  8371. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8372. /**
  8373. * Update the sampling mode of a given texture
  8374. * @param samplingMode defines the required sampling mode
  8375. * @param texture defines the texture to update
  8376. */
  8377. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8378. /**
  8379. * Update the content of a dynamic texture
  8380. * @param texture defines the texture to update
  8381. * @param canvas defines the canvas containing the source
  8382. * @param invertY defines if data must be stored with Y axis inverted
  8383. * @param premulAlpha defines if alpha is stored as premultiplied
  8384. * @param format defines the format of the data
  8385. */
  8386. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8387. /**
  8388. * Update a video texture
  8389. * @param texture defines the texture to update
  8390. * @param video defines the video element to use
  8391. * @param invertY defines if data must be stored with Y axis inverted
  8392. */
  8393. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8394. /**
  8395. * Updates a depth texture Comparison Mode and Function.
  8396. * If the comparison Function is equal to 0, the mode will be set to none.
  8397. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8398. * @param texture The texture to set the comparison function for
  8399. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8400. */
  8401. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8402. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  8403. /**
  8404. * Creates a depth stencil texture.
  8405. * This is only available in WebGL 2 or with the depth texture extension available.
  8406. * @param size The size of face edge in the texture.
  8407. * @param options The options defining the texture.
  8408. * @returns The texture
  8409. */
  8410. createDepthStencilTexture(size: number | {
  8411. width: number;
  8412. height: number;
  8413. }, options: DepthTextureCreationOptions): InternalTexture;
  8414. /**
  8415. * Creates a depth stencil texture.
  8416. * This is only available in WebGL 2 or with the depth texture extension available.
  8417. * @param size The size of face edge in the texture.
  8418. * @param options The options defining the texture.
  8419. * @returns The texture
  8420. */
  8421. private _createDepthStencilTexture(size, options);
  8422. /**
  8423. * Creates a depth stencil cube texture.
  8424. * This is only available in WebGL 2.
  8425. * @param size The size of face edge in the cube texture.
  8426. * @param options The options defining the cube texture.
  8427. * @returns The cube texture
  8428. */
  8429. private _createDepthStencilCubeTexture(size, options);
  8430. /**
  8431. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8432. * @param renderTarget The render target to set the frame buffer for
  8433. */
  8434. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8435. /**
  8436. * Creates a new render target texture
  8437. * @param size defines the size of the texture
  8438. * @param options defines the options used to create the texture
  8439. * @returns a new render target texture stored in an InternalTexture
  8440. */
  8441. createRenderTargetTexture(size: number | {
  8442. width: number;
  8443. height: number;
  8444. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8445. /**
  8446. * Create a multi render target texture
  8447. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8448. * @param size defines the size of the texture
  8449. * @param options defines the creation options
  8450. * @returns the cube texture as an InternalTexture
  8451. */
  8452. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8453. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  8454. /**
  8455. * Updates the sample count of a render target texture
  8456. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8457. * @param texture defines the texture to update
  8458. * @param samples defines the sample count to set
  8459. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8460. */
  8461. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8462. /**
  8463. * Update the sample count for a given multiple render target texture
  8464. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8465. * @param textures defines the textures to update
  8466. * @param samples defines the sample count to set
  8467. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8468. */
  8469. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8470. /** @hidden */
  8471. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  8472. /** @hidden */
  8473. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  8474. /**
  8475. * Creates a new render target cube texture
  8476. * @param size defines the size of the texture
  8477. * @param options defines the options used to create the texture
  8478. * @returns a new render target cube texture stored in an InternalTexture
  8479. */
  8480. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8481. /**
  8482. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8483. * @param rootUrl defines the url where the file to load is located
  8484. * @param scene defines the current scene
  8485. * @param scale defines scale to apply to the mip map selection
  8486. * @param offset defines offset to apply to the mip map selection
  8487. * @param onLoad defines an optional callback raised when the texture is loaded
  8488. * @param onError defines an optional callback raised if there is an issue to load the texture
  8489. * @param format defines the format of the data
  8490. * @param forcedExtension defines the extension to use to pick the right loader
  8491. * @returns the cube texture as an InternalTexture
  8492. */
  8493. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, scale: number, offset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any): InternalTexture;
  8494. /**
  8495. * Creates a cube texture
  8496. * @param rootUrl defines the url where the files to load is located
  8497. * @param scene defines the current scene
  8498. * @param files defines the list of files to load (1 per face)
  8499. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8500. * @param onLoad defines an optional callback raised when the texture is loaded
  8501. * @param onError defines an optional callback raised if there is an issue to load the texture
  8502. * @param format defines the format of the data
  8503. * @param forcedExtension defines the extension to use to pick the right loader
  8504. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8505. * @returns the cube texture as an InternalTexture
  8506. */
  8507. 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): InternalTexture;
  8508. private setCubeMapTextureParams(gl, loadMipmap);
  8509. /**
  8510. * Update a raw cube texture
  8511. * @param texture defines the texture to udpdate
  8512. * @param data defines the data to store
  8513. * @param format defines the data format
  8514. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8515. * @param invertY defines if data must be stored with Y axis inverted
  8516. * @param compression defines the compression used (null by default)
  8517. * @param level defines which level of the texture to update
  8518. */
  8519. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  8520. /**
  8521. * Creates a new raw cube texture
  8522. * @param data defines the array of data to use to create each face
  8523. * @param size defines the size of the textures
  8524. * @param format defines the format of the data
  8525. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8526. * @param generateMipMaps defines if the engine should generate the mip levels
  8527. * @param invertY defines if data must be stored with Y axis inverted
  8528. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8529. * @param compression defines the compression used (null by default)
  8530. * @returns the cube texture as an InternalTexture
  8531. */
  8532. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8533. /**
  8534. * Creates a new raw cube texture from a specified url
  8535. * @param url defines the url where the data is located
  8536. * @param scene defines the current scene
  8537. * @param size defines the size of the textures
  8538. * @param format defines the format of the data
  8539. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8540. * @param noMipmap defines if the engine should avoid generating the mip levels
  8541. * @param callback defines a callback used to extract texture data from loaded data
  8542. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  8543. * @param onLoad defines a callback called when texture is loaded
  8544. * @param onError defines a callback called if there is an error
  8545. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8546. * @param invertY defines if data must be stored with Y axis inverted
  8547. * @returns the cube texture as an InternalTexture
  8548. */
  8549. 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;
  8550. /**
  8551. * Update a raw 3D texture
  8552. * @param texture defines the texture to update
  8553. * @param data defines the data to store
  8554. * @param format defines the data format
  8555. * @param invertY defines if data must be stored with Y axis inverted
  8556. * @param compression defines the used compression (can be null)
  8557. */
  8558. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>): void;
  8559. /**
  8560. * Creates a new raw 3D texture
  8561. * @param data defines the data used to create the texture
  8562. * @param width defines the width of the texture
  8563. * @param height defines the height of the texture
  8564. * @param depth defines the depth of the texture
  8565. * @param format defines the format of the texture
  8566. * @param generateMipMaps defines if the engine must generate mip levels
  8567. * @param invertY defines if data must be stored with Y axis inverted
  8568. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8569. * @param compression defines the compressed used (can be null)
  8570. * @returns a new raw 3D texture (stored in an InternalTexture)
  8571. */
  8572. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8573. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  8574. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  8575. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  8576. /** @hidden */
  8577. _releaseFramebufferObjects(texture: InternalTexture): void;
  8578. /** @hidden */
  8579. _releaseTexture(texture: InternalTexture): void;
  8580. private setProgram(program);
  8581. private _boundUniforms;
  8582. /**
  8583. * Binds an effect to the webGL context
  8584. * @param effect defines the effect to bind
  8585. */
  8586. bindSamplers(effect: Effect): void;
  8587. private _moveBoundTextureOnTop(internalTexture);
  8588. private _getCorrectTextureChannel(channel, internalTexture);
  8589. private _linkTrackers(previous, next);
  8590. private _removeDesignatedSlot(internalTexture);
  8591. private _activateCurrentTexture();
  8592. /** @hidden */
  8593. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): void;
  8594. /** @hidden */
  8595. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  8596. /**
  8597. * Sets a texture to the webGL context from a postprocess
  8598. * @param channel defines the channel to use
  8599. * @param postProcess defines the source postprocess
  8600. */
  8601. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  8602. /**
  8603. * Binds the output of the passed in post process to the texture channel specified
  8604. * @param channel The channel the texture should be bound to
  8605. * @param postProcess The post process which's output should be bound
  8606. */
  8607. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  8608. /**
  8609. * Unbind all textures from the webGL context
  8610. */
  8611. unbindAllTextures(): void;
  8612. /**
  8613. * Sets a texture to the according uniform.
  8614. * @param channel The texture channel
  8615. * @param uniform The uniform to set
  8616. * @param texture The texture to apply
  8617. */
  8618. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  8619. /**
  8620. * Sets a depth stencil texture from a render target to the according uniform.
  8621. * @param channel The texture channel
  8622. * @param uniform The uniform to set
  8623. * @param texture The render target texture containing the depth stencil texture to apply
  8624. */
  8625. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  8626. private _bindSamplerUniformToChannel(sourceSlot, destination);
  8627. private _getTextureWrapMode(mode);
  8628. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  8629. /**
  8630. * Sets an array of texture to the webGL context
  8631. * @param channel defines the channel where the texture array must be set
  8632. * @param uniform defines the associated uniform location
  8633. * @param textures defines the array of textures to bind
  8634. */
  8635. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  8636. /** @hidden */
  8637. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  8638. private _setTextureParameterFloat(target, parameter, value, texture);
  8639. private _setTextureParameterInteger(target, parameter, value, texture?);
  8640. /**
  8641. * Reads pixels from the current frame buffer. Please note that this function can be slow
  8642. * @param x defines the x coordinate of the rectangle where pixels must be read
  8643. * @param y defines the y coordinate of the rectangle where pixels must be read
  8644. * @param width defines the width of the rectangle where pixels must be read
  8645. * @param height defines the height of the rectangle where pixels must be read
  8646. * @returns a Uint8Array containing RGBA colors
  8647. */
  8648. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  8649. /**
  8650. * Add an externaly attached data from its key.
  8651. * This method call will fail and return false, if such key already exists.
  8652. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  8653. * @param key the unique key that identifies the data
  8654. * @param data the data object to associate to the key for this Engine instance
  8655. * @return true if no such key were already present and the data was added successfully, false otherwise
  8656. */
  8657. addExternalData<T>(key: string, data: T): boolean;
  8658. /**
  8659. * Get an externaly attached data from its key
  8660. * @param key the unique key that identifies the data
  8661. * @return the associated data, if present (can be null), or undefined if not present
  8662. */
  8663. getExternalData<T>(key: string): T;
  8664. /**
  8665. * Get an externaly attached data from its key, create it using a factory if it's not already present
  8666. * @param key the unique key that identifies the data
  8667. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  8668. * @return the associated data, can be null if the factory returned null.
  8669. */
  8670. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  8671. /**
  8672. * Remove an externaly attached data from the Engine instance
  8673. * @param key the unique key that identifies the data
  8674. * @return true if the data was successfully removed, false if it doesn't exist
  8675. */
  8676. removeExternalData(key: string): boolean;
  8677. /**
  8678. * Unbind all vertex attributes from the webGL context
  8679. */
  8680. unbindAllAttributes(): void;
  8681. /**
  8682. * 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
  8683. */
  8684. releaseEffects(): void;
  8685. /**
  8686. * Dispose and release all associated resources
  8687. */
  8688. dispose(): void;
  8689. /**
  8690. * Display the loading screen
  8691. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8692. */
  8693. displayLoadingUI(): void;
  8694. /**
  8695. * Hide the loading screen
  8696. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8697. */
  8698. hideLoadingUI(): void;
  8699. /**
  8700. * Gets the current loading screen object
  8701. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8702. */
  8703. /**
  8704. * Sets the current loading screen object
  8705. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8706. */
  8707. loadingScreen: ILoadingScreen;
  8708. /**
  8709. * Sets the current loading screen text
  8710. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8711. */
  8712. loadingUIText: string;
  8713. /**
  8714. * Sets the current loading screen background color
  8715. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8716. */
  8717. loadingUIBackgroundColor: string;
  8718. /**
  8719. * Attach a new callback raised when context lost event is fired
  8720. * @param callback defines the callback to call
  8721. */
  8722. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8723. /**
  8724. * Attach a new callback raised when context restored event is fired
  8725. * @param callback defines the callback to call
  8726. */
  8727. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8728. /**
  8729. * Gets the source code of the vertex shader associated with a specific webGL program
  8730. * @param program defines the program to use
  8731. * @returns a string containing the source code of the vertex shader associated with the program
  8732. */
  8733. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  8734. /**
  8735. * Gets the source code of the fragment shader associated with a specific webGL program
  8736. * @param program defines the program to use
  8737. * @returns a string containing the source code of the fragment shader associated with the program
  8738. */
  8739. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  8740. /**
  8741. * Get the current error code of the webGL context
  8742. * @returns the error code
  8743. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  8744. */
  8745. getError(): number;
  8746. /**
  8747. * Gets the current framerate
  8748. * @returns a number representing the framerate
  8749. */
  8750. getFps(): number;
  8751. /**
  8752. * Gets the time spent between current and previous frame
  8753. * @returns a number representing the delta time in ms
  8754. */
  8755. getDeltaTime(): number;
  8756. private _measureFps();
  8757. /** @hidden */
  8758. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number): ArrayBufferView;
  8759. private _canRenderToFloatFramebuffer();
  8760. private _canRenderToHalfFloatFramebuffer();
  8761. private _canRenderToFramebuffer(type);
  8762. /** @hidden */
  8763. _getWebGLTextureType(type: number): number;
  8764. private _getInternalFormat(format);
  8765. /** @hidden */
  8766. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  8767. /** @hidden */
  8768. _getRGBAMultiSampleBufferFormat(type: number): number;
  8769. /**
  8770. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  8771. * @return the new query
  8772. */
  8773. createQuery(): WebGLQuery;
  8774. /**
  8775. * Delete and release a webGL query
  8776. * @param query defines the query to delete
  8777. * @return the current engine
  8778. */
  8779. deleteQuery(query: WebGLQuery): Engine;
  8780. /**
  8781. * Check if a given query has resolved and got its value
  8782. * @param query defines the query to check
  8783. * @returns true if the query got its value
  8784. */
  8785. isQueryResultAvailable(query: WebGLQuery): boolean;
  8786. /**
  8787. * Gets the value of a given query
  8788. * @param query defines the query to check
  8789. * @returns the value of the query
  8790. */
  8791. getQueryResult(query: WebGLQuery): number;
  8792. /**
  8793. * Initiates an occlusion query
  8794. * @param algorithmType defines the algorithm to use
  8795. * @param query defines the query to use
  8796. * @returns the current engine
  8797. * @see http://doc.babylonjs.com/features/occlusionquery
  8798. */
  8799. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  8800. /**
  8801. * Ends an occlusion query
  8802. * @see http://doc.babylonjs.com/features/occlusionquery
  8803. * @param algorithmType defines the algorithm to use
  8804. * @returns the current engine
  8805. */
  8806. endOcclusionQuery(algorithmType: number): Engine;
  8807. private _createTimeQuery();
  8808. private _deleteTimeQuery(query);
  8809. private _getTimeQueryResult(query);
  8810. private _getTimeQueryAvailability(query);
  8811. private _currentNonTimestampToken;
  8812. /**
  8813. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  8814. * Please note that only one query can be issued at a time
  8815. * @returns a time token used to track the time span
  8816. */
  8817. startTimeQuery(): Nullable<_TimeToken>;
  8818. /**
  8819. * Ends a time query
  8820. * @param token defines the token used to measure the time span
  8821. * @returns the time spent (in ns)
  8822. */
  8823. endTimeQuery(token: _TimeToken): int;
  8824. private getGlAlgorithmType(algorithmType);
  8825. /**
  8826. * Creates a webGL transform feedback object
  8827. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  8828. * @returns the webGL transform feedback object
  8829. */
  8830. createTransformFeedback(): WebGLTransformFeedback;
  8831. /**
  8832. * Delete a webGL transform feedback object
  8833. * @param value defines the webGL transform feedback object to delete
  8834. */
  8835. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  8836. /**
  8837. * Bind a webGL transform feedback object to the webgl context
  8838. * @param value defines the webGL transform feedback object to bind
  8839. */
  8840. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  8841. /**
  8842. * Begins a transform feedback operation
  8843. * @param usePoints defines if points or triangles must be used
  8844. */
  8845. beginTransformFeedback(usePoints?: boolean): void;
  8846. /**
  8847. * Ends a transform feedback operation
  8848. */
  8849. endTransformFeedback(): void;
  8850. /**
  8851. * Specify the varyings to use with transform feedback
  8852. * @param program defines the associated webGL program
  8853. * @param value defines the list of strings representing the varying names
  8854. */
  8855. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  8856. /**
  8857. * Bind a webGL buffer for a transform feedback operation
  8858. * @param value defines the webGL buffer to bind
  8859. */
  8860. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  8861. /** @hidden */
  8862. _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;
  8863. /** @hidden */
  8864. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  8865. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  8866. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  8867. /**
  8868. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  8869. * @returns true if the engine can be created
  8870. * @ignorenaming
  8871. */
  8872. static isSupported(): boolean;
  8873. }
  8874. }
  8875. declare module BABYLON {
  8876. class NullEngineOptions {
  8877. renderWidth: number;
  8878. renderHeight: number;
  8879. textureSize: number;
  8880. deterministicLockstep: boolean;
  8881. lockstepMaxSteps: number;
  8882. }
  8883. /**
  8884. * The null engine class provides support for headless version of babylon.js.
  8885. * This can be used in server side scenario or for testing purposes
  8886. */
  8887. class NullEngine extends Engine {
  8888. private _options;
  8889. isDeterministicLockStep(): boolean;
  8890. getLockstepMaxSteps(): number;
  8891. getHardwareScalingLevel(): number;
  8892. constructor(options?: NullEngineOptions);
  8893. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8894. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  8895. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8896. getRenderWidth(useScreen?: boolean): number;
  8897. getRenderHeight(useScreen?: boolean): number;
  8898. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8899. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  8900. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  8901. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8902. bindSamplers(effect: Effect): void;
  8903. enableEffect(effect: Effect): void;
  8904. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8905. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  8906. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  8907. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  8908. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  8909. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  8910. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  8911. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  8912. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  8913. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  8914. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  8915. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  8916. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  8917. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  8918. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  8919. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8920. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8921. setFloat(uniform: WebGLUniformLocation, value: number): void;
  8922. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  8923. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  8924. setBool(uniform: WebGLUniformLocation, bool: number): void;
  8925. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  8926. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  8927. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  8928. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8929. bindBuffers(vertexBuffers: {
  8930. [key: string]: VertexBuffer;
  8931. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  8932. wipeCaches(bruteForce?: boolean): void;
  8933. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8934. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8935. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8936. _createTexture(): WebGLTexture;
  8937. _releaseTexture(texture: InternalTexture): void;
  8938. 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;
  8939. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8940. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8941. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  8942. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8943. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8944. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8945. /**
  8946. * Updates a dynamic vertex buffer.
  8947. * @param vertexBuffer the vertex buffer to update
  8948. * @param data the data used to update the vertex buffer
  8949. * @param byteOffset the byte offset of the data (optional)
  8950. * @param byteLength the byte length of the data (optional)
  8951. */
  8952. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  8953. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  8954. _bindTexture(channel: number, texture: InternalTexture): void;
  8955. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8956. releaseEffects(): void;
  8957. }
  8958. }
  8959. interface WebGLRenderingContext {
  8960. readonly RASTERIZER_DISCARD: number;
  8961. readonly DEPTH_COMPONENT24: number;
  8962. readonly TEXTURE_3D: number;
  8963. readonly TEXTURE_2D_ARRAY: number;
  8964. readonly TEXTURE_COMPARE_FUNC: number;
  8965. readonly TEXTURE_COMPARE_MODE: number;
  8966. readonly COMPARE_REF_TO_TEXTURE: number;
  8967. readonly TEXTURE_WRAP_R: number;
  8968. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  8969. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  8970. 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;
  8971. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  8972. readonly TRANSFORM_FEEDBACK: number;
  8973. readonly INTERLEAVED_ATTRIBS: number;
  8974. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  8975. createTransformFeedback(): WebGLTransformFeedback;
  8976. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  8977. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  8978. beginTransformFeedback(primitiveMode: number): void;
  8979. endTransformFeedback(): void;
  8980. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  8981. }
  8982. interface ImageBitmap {
  8983. readonly width: number;
  8984. readonly height: number;
  8985. close(): void;
  8986. }
  8987. interface WebGLQuery extends WebGLObject {
  8988. }
  8989. declare var WebGLQuery: {
  8990. prototype: WebGLQuery;
  8991. new (): WebGLQuery;
  8992. };
  8993. interface WebGLSampler extends WebGLObject {
  8994. }
  8995. declare var WebGLSampler: {
  8996. prototype: WebGLSampler;
  8997. new (): WebGLSampler;
  8998. };
  8999. interface WebGLSync extends WebGLObject {
  9000. }
  9001. declare var WebGLSync: {
  9002. prototype: WebGLSync;
  9003. new (): WebGLSync;
  9004. };
  9005. interface WebGLTransformFeedback extends WebGLObject {
  9006. }
  9007. declare var WebGLTransformFeedback: {
  9008. prototype: WebGLTransformFeedback;
  9009. new (): WebGLTransformFeedback;
  9010. };
  9011. interface WebGLVertexArrayObject extends WebGLObject {
  9012. }
  9013. declare var WebGLVertexArrayObject: {
  9014. prototype: WebGLVertexArrayObject;
  9015. new (): WebGLVertexArrayObject;
  9016. };
  9017. declare module BABYLON {
  9018. class KeyboardEventTypes {
  9019. static _KEYDOWN: number;
  9020. static _KEYUP: number;
  9021. static readonly KEYDOWN: number;
  9022. static readonly KEYUP: number;
  9023. }
  9024. class KeyboardInfo {
  9025. type: number;
  9026. event: KeyboardEvent;
  9027. constructor(type: number, event: KeyboardEvent);
  9028. }
  9029. /**
  9030. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9031. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9032. */
  9033. class KeyboardInfoPre extends KeyboardInfo {
  9034. constructor(type: number, event: KeyboardEvent);
  9035. skipOnPointerObservable: boolean;
  9036. }
  9037. }
  9038. declare module BABYLON {
  9039. class PointerEventTypes {
  9040. static _POINTERDOWN: number;
  9041. static _POINTERUP: number;
  9042. static _POINTERMOVE: number;
  9043. static _POINTERWHEEL: number;
  9044. static _POINTERPICK: number;
  9045. static _POINTERTAP: number;
  9046. static _POINTERDOUBLETAP: number;
  9047. static readonly POINTERDOWN: number;
  9048. static readonly POINTERUP: number;
  9049. static readonly POINTERMOVE: number;
  9050. static readonly POINTERWHEEL: number;
  9051. static readonly POINTERPICK: number;
  9052. static readonly POINTERTAP: number;
  9053. static readonly POINTERDOUBLETAP: number;
  9054. }
  9055. class PointerInfoBase {
  9056. type: number;
  9057. event: PointerEvent | MouseWheelEvent;
  9058. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9059. }
  9060. /**
  9061. * This class is used to store pointer related info for the onPrePointerObservable event.
  9062. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9063. */
  9064. class PointerInfoPre extends PointerInfoBase {
  9065. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9066. localPosition: Vector2;
  9067. skipOnPointerObservable: boolean;
  9068. }
  9069. /**
  9070. * This type contains all the data related to a pointer event in Babylon.js.
  9071. * 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.
  9072. */
  9073. class PointerInfo extends PointerInfoBase {
  9074. pickInfo: Nullable<PickingInfo>;
  9075. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9076. }
  9077. }
  9078. declare module BABYLON {
  9079. class StickValues {
  9080. x: number;
  9081. y: number;
  9082. constructor(x: number, y: number);
  9083. }
  9084. interface GamepadButtonChanges {
  9085. changed: boolean;
  9086. pressChanged: boolean;
  9087. touchChanged: boolean;
  9088. valueChanged: boolean;
  9089. }
  9090. class Gamepad {
  9091. id: string;
  9092. index: number;
  9093. browserGamepad: any;
  9094. type: number;
  9095. private _leftStick;
  9096. private _rightStick;
  9097. _isConnected: boolean;
  9098. private _leftStickAxisX;
  9099. private _leftStickAxisY;
  9100. private _rightStickAxisX;
  9101. private _rightStickAxisY;
  9102. private _onleftstickchanged;
  9103. private _onrightstickchanged;
  9104. static GAMEPAD: number;
  9105. static GENERIC: number;
  9106. static XBOX: number;
  9107. static POSE_ENABLED: number;
  9108. protected _invertLeftStickY: boolean;
  9109. readonly isConnected: boolean;
  9110. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9111. onleftstickchanged(callback: (values: StickValues) => void): void;
  9112. onrightstickchanged(callback: (values: StickValues) => void): void;
  9113. leftStick: StickValues;
  9114. rightStick: StickValues;
  9115. update(): void;
  9116. dispose(): void;
  9117. }
  9118. class GenericPad extends Gamepad {
  9119. private _buttons;
  9120. private _onbuttondown;
  9121. private _onbuttonup;
  9122. onButtonDownObservable: Observable<number>;
  9123. onButtonUpObservable: Observable<number>;
  9124. onbuttondown(callback: (buttonPressed: number) => void): void;
  9125. onbuttonup(callback: (buttonReleased: number) => void): void;
  9126. constructor(id: string, index: number, browserGamepad: any);
  9127. private _setButtonValue(newValue, currentValue, buttonIndex);
  9128. update(): void;
  9129. dispose(): void;
  9130. }
  9131. }
  9132. declare module BABYLON {
  9133. class GamepadManager {
  9134. private _scene;
  9135. private _babylonGamepads;
  9136. private _oneGamepadConnected;
  9137. _isMonitoring: boolean;
  9138. private _gamepadEventSupported;
  9139. private _gamepadSupport;
  9140. onGamepadConnectedObservable: Observable<Gamepad>;
  9141. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9142. private _onGamepadConnectedEvent;
  9143. private _onGamepadDisconnectedEvent;
  9144. constructor(_scene?: Scene | undefined);
  9145. readonly gamepads: Gamepad[];
  9146. getGamepadByType(type?: number): Nullable<Gamepad>;
  9147. dispose(): void;
  9148. private _addNewGamepad(gamepad);
  9149. private _startMonitoringGamepads();
  9150. private _stopMonitoringGamepads();
  9151. _checkGamepadsStatus(): void;
  9152. private _updateGamepadObjects();
  9153. }
  9154. }
  9155. declare module BABYLON {
  9156. /**
  9157. * Defines supported buttons for XBox360 compatible gamepads
  9158. */
  9159. enum Xbox360Button {
  9160. /** A */
  9161. A = 0,
  9162. /** B */
  9163. B = 1,
  9164. /** X */
  9165. X = 2,
  9166. /** Y */
  9167. Y = 3,
  9168. /** Start */
  9169. Start = 4,
  9170. /** Back */
  9171. Back = 5,
  9172. /** Left button */
  9173. LB = 6,
  9174. /** Right button */
  9175. RB = 7,
  9176. /** Left stick */
  9177. LeftStick = 8,
  9178. /** Right stick */
  9179. RightStick = 9,
  9180. }
  9181. /** Defines values for XBox360 DPad */
  9182. enum Xbox360Dpad {
  9183. /** Up */
  9184. Up = 0,
  9185. /** Down */
  9186. Down = 1,
  9187. /** Left */
  9188. Left = 2,
  9189. /** Right */
  9190. Right = 3,
  9191. }
  9192. /**
  9193. * Defines a XBox360 gamepad
  9194. */
  9195. class Xbox360Pad extends Gamepad {
  9196. private _leftTrigger;
  9197. private _rightTrigger;
  9198. private _onlefttriggerchanged;
  9199. private _onrighttriggerchanged;
  9200. private _onbuttondown;
  9201. private _onbuttonup;
  9202. private _ondpaddown;
  9203. private _ondpadup;
  9204. /** Observable raised when a button is pressed */
  9205. onButtonDownObservable: Observable<Xbox360Button>;
  9206. /** Observable raised when a button is released */
  9207. onButtonUpObservable: Observable<Xbox360Button>;
  9208. /** Observable raised when a pad is pressed */
  9209. onPadDownObservable: Observable<Xbox360Dpad>;
  9210. /** Observable raised when a pad is released */
  9211. onPadUpObservable: Observable<Xbox360Dpad>;
  9212. private _buttonA;
  9213. private _buttonB;
  9214. private _buttonX;
  9215. private _buttonY;
  9216. private _buttonBack;
  9217. private _buttonStart;
  9218. private _buttonLB;
  9219. private _buttonRB;
  9220. private _buttonLeftStick;
  9221. private _buttonRightStick;
  9222. private _dPadUp;
  9223. private _dPadDown;
  9224. private _dPadLeft;
  9225. private _dPadRight;
  9226. private _isXboxOnePad;
  9227. /**
  9228. * Creates a new XBox360 gamepad object
  9229. * @param id defines the id of this gamepad
  9230. * @param index defines its index
  9231. * @param gamepad defines the internal HTML gamepad object
  9232. * @param xboxOne defines if it is a XBox One gamepad
  9233. */
  9234. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9235. /**
  9236. * Defines the callback to call when left trigger is pressed
  9237. * @param callback defines the callback to use
  9238. */
  9239. onlefttriggerchanged(callback: (value: number) => void): void;
  9240. /**
  9241. * Defines the callback to call when right trigger is pressed
  9242. * @param callback defines the callback to use
  9243. */
  9244. onrighttriggerchanged(callback: (value: number) => void): void;
  9245. /**
  9246. * Gets or sets left trigger value
  9247. */
  9248. leftTrigger: number;
  9249. /**
  9250. * Gets or sets right trigger value
  9251. */
  9252. rightTrigger: number;
  9253. /**
  9254. * Defines the callback to call when a button is pressed
  9255. * @param callback defines the callback to use
  9256. */
  9257. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9258. /**
  9259. * Defines the callback to call when a button is released
  9260. * @param callback defines the callback to use
  9261. */
  9262. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9263. /**
  9264. * Defines the callback to call when a pad is pressed
  9265. * @param callback defines the callback to use
  9266. */
  9267. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9268. /**
  9269. * Defines the callback to call when a pad is released
  9270. * @param callback defines the callback to use
  9271. */
  9272. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9273. private _setButtonValue(newValue, currentValue, buttonType);
  9274. private _setDPadValue(newValue, currentValue, buttonType);
  9275. /** Gets or sets value of A button */
  9276. buttonA: number;
  9277. /** Gets or sets value of B button */
  9278. buttonB: number;
  9279. /** Gets or sets value of X button */
  9280. buttonX: number;
  9281. /** Gets or sets value of Y button */
  9282. buttonY: number;
  9283. /** Gets or sets value of Start button */
  9284. buttonStart: number;
  9285. /** Gets or sets value of Back button */
  9286. buttonBack: number;
  9287. /** Gets or sets value of Left button */
  9288. buttonLB: number;
  9289. /** Gets or sets value of Right button */
  9290. buttonRB: number;
  9291. /** Gets or sets value of left stick */
  9292. buttonLeftStick: number;
  9293. /** Gets or sets value of right stick */
  9294. buttonRightStick: number;
  9295. /** Gets or sets value of DPad up */
  9296. dPadUp: number;
  9297. /** Gets or sets value of DPad down */
  9298. dPadDown: number;
  9299. /** Gets or sets value of DPad left */
  9300. dPadLeft: number;
  9301. /** Gets or sets value of DPad right */
  9302. dPadRight: number;
  9303. /**
  9304. * Force the gamepad to synchronize with device values
  9305. */
  9306. update(): void;
  9307. dispose(): void;
  9308. }
  9309. }
  9310. declare module BABYLON {
  9311. /**
  9312. * Represents the different options available during the creation of
  9313. * a Environment helper.
  9314. *
  9315. * This can control the default ground, skybox and image processing setup of your scene.
  9316. */
  9317. interface IEnvironmentHelperOptions {
  9318. /**
  9319. * Specifies wether or not to create a ground.
  9320. * True by default.
  9321. */
  9322. createGround: boolean;
  9323. /**
  9324. * Specifies the ground size.
  9325. * 15 by default.
  9326. */
  9327. groundSize: number;
  9328. /**
  9329. * The texture used on the ground for the main color.
  9330. * Comes from the BabylonJS CDN by default.
  9331. *
  9332. * Remarks: Can be either a texture or a url.
  9333. */
  9334. groundTexture: string | BaseTexture;
  9335. /**
  9336. * The color mixed in the ground texture by default.
  9337. * BabylonJS clearColor by default.
  9338. */
  9339. groundColor: Color3;
  9340. /**
  9341. * Specifies the ground opacity.
  9342. * 1 by default.
  9343. */
  9344. groundOpacity: number;
  9345. /**
  9346. * Enables the ground to receive shadows.
  9347. * True by default.
  9348. */
  9349. enableGroundShadow: boolean;
  9350. /**
  9351. * Helps preventing the shadow to be fully black on the ground.
  9352. * 0.5 by default.
  9353. */
  9354. groundShadowLevel: number;
  9355. /**
  9356. * Creates a mirror texture attach to the ground.
  9357. * false by default.
  9358. */
  9359. enableGroundMirror: boolean;
  9360. /**
  9361. * Specifies the ground mirror size ratio.
  9362. * 0.3 by default as the default kernel is 64.
  9363. */
  9364. groundMirrorSizeRatio: number;
  9365. /**
  9366. * Specifies the ground mirror blur kernel size.
  9367. * 64 by default.
  9368. */
  9369. groundMirrorBlurKernel: number;
  9370. /**
  9371. * Specifies the ground mirror visibility amount.
  9372. * 1 by default
  9373. */
  9374. groundMirrorAmount: number;
  9375. /**
  9376. * Specifies the ground mirror reflectance weight.
  9377. * This uses the standard weight of the background material to setup the fresnel effect
  9378. * of the mirror.
  9379. * 1 by default.
  9380. */
  9381. groundMirrorFresnelWeight: number;
  9382. /**
  9383. * Specifies the ground mirror Falloff distance.
  9384. * This can helps reducing the size of the reflection.
  9385. * 0 by Default.
  9386. */
  9387. groundMirrorFallOffDistance: number;
  9388. /**
  9389. * Specifies the ground mirror texture type.
  9390. * Unsigned Int by Default.
  9391. */
  9392. groundMirrorTextureType: number;
  9393. /**
  9394. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  9395. * the shown objects.
  9396. */
  9397. groundYBias: number;
  9398. /**
  9399. * Specifies wether or not to create a skybox.
  9400. * True by default.
  9401. */
  9402. createSkybox: boolean;
  9403. /**
  9404. * Specifies the skybox size.
  9405. * 20 by default.
  9406. */
  9407. skyboxSize: number;
  9408. /**
  9409. * The texture used on the skybox for the main color.
  9410. * Comes from the BabylonJS CDN by default.
  9411. *
  9412. * Remarks: Can be either a texture or a url.
  9413. */
  9414. skyboxTexture: string | BaseTexture;
  9415. /**
  9416. * The color mixed in the skybox texture by default.
  9417. * BabylonJS clearColor by default.
  9418. */
  9419. skyboxColor: Color3;
  9420. /**
  9421. * The background rotation around the Y axis of the scene.
  9422. * This helps aligning the key lights of your scene with the background.
  9423. * 0 by default.
  9424. */
  9425. backgroundYRotation: number;
  9426. /**
  9427. * Compute automatically the size of the elements to best fit with the scene.
  9428. */
  9429. sizeAuto: boolean;
  9430. /**
  9431. * Default position of the rootMesh if autoSize is not true.
  9432. */
  9433. rootPosition: Vector3;
  9434. /**
  9435. * Sets up the image processing in the scene.
  9436. * true by default.
  9437. */
  9438. setupImageProcessing: boolean;
  9439. /**
  9440. * The texture used as your environment texture in the scene.
  9441. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  9442. *
  9443. * Remarks: Can be either a texture or a url.
  9444. */
  9445. environmentTexture: string | BaseTexture;
  9446. /**
  9447. * The value of the exposure to apply to the scene.
  9448. * 0.6 by default if setupImageProcessing is true.
  9449. */
  9450. cameraExposure: number;
  9451. /**
  9452. * The value of the contrast to apply to the scene.
  9453. * 1.6 by default if setupImageProcessing is true.
  9454. */
  9455. cameraContrast: number;
  9456. /**
  9457. * Specifies wether or not tonemapping should be enabled in the scene.
  9458. * true by default if setupImageProcessing is true.
  9459. */
  9460. toneMappingEnabled: boolean;
  9461. }
  9462. /**
  9463. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  9464. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  9465. * It also helps with the default setup of your imageProcessing configuration.
  9466. */
  9467. class EnvironmentHelper {
  9468. /**
  9469. * Default ground texture URL.
  9470. */
  9471. private static _groundTextureCDNUrl;
  9472. /**
  9473. * Default skybox texture URL.
  9474. */
  9475. private static _skyboxTextureCDNUrl;
  9476. /**
  9477. * Default environment texture URL.
  9478. */
  9479. private static _environmentTextureCDNUrl;
  9480. /**
  9481. * Creates the default options for the helper.
  9482. */
  9483. private static _getDefaultOptions();
  9484. private _rootMesh;
  9485. /**
  9486. * Gets the root mesh created by the helper.
  9487. */
  9488. readonly rootMesh: Mesh;
  9489. private _skybox;
  9490. /**
  9491. * Gets the skybox created by the helper.
  9492. */
  9493. readonly skybox: Nullable<Mesh>;
  9494. private _skyboxTexture;
  9495. /**
  9496. * Gets the skybox texture created by the helper.
  9497. */
  9498. readonly skyboxTexture: Nullable<BaseTexture>;
  9499. private _skyboxMaterial;
  9500. /**
  9501. * Gets the skybox material created by the helper.
  9502. */
  9503. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  9504. private _ground;
  9505. /**
  9506. * Gets the ground mesh created by the helper.
  9507. */
  9508. readonly ground: Nullable<Mesh>;
  9509. private _groundTexture;
  9510. /**
  9511. * Gets the ground texture created by the helper.
  9512. */
  9513. readonly groundTexture: Nullable<BaseTexture>;
  9514. private _groundMirror;
  9515. /**
  9516. * Gets the ground mirror created by the helper.
  9517. */
  9518. readonly groundMirror: Nullable<MirrorTexture>;
  9519. /**
  9520. * Gets the ground mirror render list to helps pushing the meshes
  9521. * you wish in the ground reflection.
  9522. */
  9523. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  9524. private _groundMaterial;
  9525. /**
  9526. * Gets the ground material created by the helper.
  9527. */
  9528. readonly groundMaterial: Nullable<BackgroundMaterial>;
  9529. /**
  9530. * Stores the creation options.
  9531. */
  9532. private readonly _scene;
  9533. private _options;
  9534. /**
  9535. * This observable will be notified with any error during the creation of the environment,
  9536. * mainly texture creation errors.
  9537. */
  9538. onErrorObservable: Observable<{
  9539. message?: string;
  9540. exception?: any;
  9541. }>;
  9542. /**
  9543. * constructor
  9544. * @param options
  9545. * @param scene The scene to add the material to
  9546. */
  9547. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  9548. /**
  9549. * Updates the background according to the new options
  9550. * @param options
  9551. */
  9552. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  9553. /**
  9554. * Sets the primary color of all the available elements.
  9555. * @param color the main color to affect to the ground and the background
  9556. */
  9557. setMainColor(color: Color3): void;
  9558. /**
  9559. * Setup the image processing according to the specified options.
  9560. */
  9561. private _setupImageProcessing();
  9562. /**
  9563. * Setup the environment texture according to the specified options.
  9564. */
  9565. private _setupEnvironmentTexture();
  9566. /**
  9567. * Setup the background according to the specified options.
  9568. */
  9569. private _setupBackground();
  9570. /**
  9571. * Get the scene sizes according to the setup.
  9572. */
  9573. private _getSceneSize();
  9574. /**
  9575. * Setup the ground according to the specified options.
  9576. */
  9577. private _setupGround(sceneSize);
  9578. /**
  9579. * Setup the ground material according to the specified options.
  9580. */
  9581. private _setupGroundMaterial();
  9582. /**
  9583. * Setup the ground diffuse texture according to the specified options.
  9584. */
  9585. private _setupGroundDiffuseTexture();
  9586. /**
  9587. * Setup the ground mirror texture according to the specified options.
  9588. */
  9589. private _setupGroundMirrorTexture(sceneSize);
  9590. /**
  9591. * Setup the ground to receive the mirror texture.
  9592. */
  9593. private _setupMirrorInGroundMaterial();
  9594. /**
  9595. * Setup the skybox according to the specified options.
  9596. */
  9597. private _setupSkybox(sceneSize);
  9598. /**
  9599. * Setup the skybox material according to the specified options.
  9600. */
  9601. private _setupSkyboxMaterial();
  9602. /**
  9603. * Setup the skybox reflection texture according to the specified options.
  9604. */
  9605. private _setupSkyboxReflectionTexture();
  9606. private _errorHandler;
  9607. /**
  9608. * Dispose all the elements created by the Helper.
  9609. */
  9610. dispose(): void;
  9611. }
  9612. }
  9613. declare module BABYLON {
  9614. /**
  9615. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  9616. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  9617. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  9618. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  9619. */
  9620. class VideoDome extends Node {
  9621. /**
  9622. * The video texture being displayed on the sphere
  9623. */
  9624. protected _videoTexture: VideoTexture;
  9625. /**
  9626. * The skybox material
  9627. */
  9628. protected _material: BackgroundMaterial;
  9629. /**
  9630. * The surface used for the skybox
  9631. */
  9632. protected _mesh: Mesh;
  9633. /**
  9634. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  9635. * Also see the options.resolution property.
  9636. */
  9637. fovMultiplier: number;
  9638. /**
  9639. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  9640. * @param name Element's name, child elements will append suffixes for their own names.
  9641. * @param urlsOrVideo
  9642. * @param options An object containing optional or exposed sub element properties:
  9643. * @param options **resolution=12** Integer, lower resolutions have more artifacts at extreme fovs
  9644. * @param options **clickToPlay=false** Add a click to play listener to the video, does not prevent autoplay.
  9645. * @param options **autoPlay=true** Automatically attempt to being playing the video.
  9646. * @param options **loop=true** Automatically loop video on end.
  9647. * @param options **size=1000** Physical radius to create the dome at, defaults to approximately half the far clip plane.
  9648. */
  9649. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  9650. resolution?: number;
  9651. clickToPlay?: boolean;
  9652. autoPlay?: boolean;
  9653. loop?: boolean;
  9654. size?: number;
  9655. }, scene: Scene);
  9656. /**
  9657. * Releases resources associated with this node.
  9658. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9659. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9660. */
  9661. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9662. }
  9663. }
  9664. declare module BABYLON {
  9665. /**
  9666. * This class can be used to get instrumentation data from a Babylon engine
  9667. */
  9668. class EngineInstrumentation implements IDisposable {
  9669. engine: Engine;
  9670. private _captureGPUFrameTime;
  9671. private _gpuFrameTimeToken;
  9672. private _gpuFrameTime;
  9673. private _captureShaderCompilationTime;
  9674. private _shaderCompilationTime;
  9675. private _onBeginFrameObserver;
  9676. private _onEndFrameObserver;
  9677. private _onBeforeShaderCompilationObserver;
  9678. private _onAfterShaderCompilationObserver;
  9679. /**
  9680. * Gets the perf counter used for GPU frame time
  9681. */
  9682. readonly gpuFrameTimeCounter: PerfCounter;
  9683. /**
  9684. * Gets the GPU frame time capture status
  9685. */
  9686. /**
  9687. * Enable or disable the GPU frame time capture
  9688. */
  9689. captureGPUFrameTime: boolean;
  9690. /**
  9691. * Gets the perf counter used for shader compilation time
  9692. */
  9693. readonly shaderCompilationTimeCounter: PerfCounter;
  9694. /**
  9695. * Gets the shader compilation time capture status
  9696. */
  9697. /**
  9698. * Enable or disable the shader compilation time capture
  9699. */
  9700. captureShaderCompilationTime: boolean;
  9701. constructor(engine: Engine);
  9702. dispose(): void;
  9703. }
  9704. }
  9705. declare module BABYLON {
  9706. /**
  9707. * This class can be used to get instrumentation data from a Babylon engine
  9708. */
  9709. class SceneInstrumentation implements IDisposable {
  9710. scene: Scene;
  9711. private _captureActiveMeshesEvaluationTime;
  9712. private _activeMeshesEvaluationTime;
  9713. private _captureRenderTargetsRenderTime;
  9714. private _renderTargetsRenderTime;
  9715. private _captureFrameTime;
  9716. private _frameTime;
  9717. private _captureRenderTime;
  9718. private _renderTime;
  9719. private _captureInterFrameTime;
  9720. private _interFrameTime;
  9721. private _captureParticlesRenderTime;
  9722. private _particlesRenderTime;
  9723. private _captureSpritesRenderTime;
  9724. private _spritesRenderTime;
  9725. private _capturePhysicsTime;
  9726. private _physicsTime;
  9727. private _captureAnimationsTime;
  9728. private _animationsTime;
  9729. private _onBeforeActiveMeshesEvaluationObserver;
  9730. private _onAfterActiveMeshesEvaluationObserver;
  9731. private _onBeforeRenderTargetsRenderObserver;
  9732. private _onAfterRenderTargetsRenderObserver;
  9733. private _onAfterRenderObserver;
  9734. private _onBeforeDrawPhaseObserver;
  9735. private _onAfterDrawPhaseObserver;
  9736. private _onBeforeAnimationsObserver;
  9737. private _onBeforeParticlesRenderingObserver;
  9738. private _onAfterParticlesRenderingObserver;
  9739. private _onBeforeSpritesRenderingObserver;
  9740. private _onAfterSpritesRenderingObserver;
  9741. private _onBeforePhysicsObserver;
  9742. private _onAfterPhysicsObserver;
  9743. private _onAfterAnimationsObserver;
  9744. /**
  9745. * Gets the perf counter used for active meshes evaluation time
  9746. */
  9747. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  9748. /**
  9749. * Gets the active meshes evaluation time capture status
  9750. */
  9751. /**
  9752. * Enable or disable the active meshes evaluation time capture
  9753. */
  9754. captureActiveMeshesEvaluationTime: boolean;
  9755. /**
  9756. * Gets the perf counter used for render targets render time
  9757. */
  9758. readonly renderTargetsRenderTimeCounter: PerfCounter;
  9759. /**
  9760. * Gets the render targets render time capture status
  9761. */
  9762. /**
  9763. * Enable or disable the render targets render time capture
  9764. */
  9765. captureRenderTargetsRenderTime: boolean;
  9766. /**
  9767. * Gets the perf counter used for particles render time
  9768. */
  9769. readonly particlesRenderTimeCounter: PerfCounter;
  9770. /**
  9771. * Gets the particles render time capture status
  9772. */
  9773. /**
  9774. * Enable or disable the particles render time capture
  9775. */
  9776. captureParticlesRenderTime: boolean;
  9777. /**
  9778. * Gets the perf counter used for sprites render time
  9779. */
  9780. readonly spritesRenderTimeCounter: PerfCounter;
  9781. /**
  9782. * Gets the sprites render time capture status
  9783. */
  9784. /**
  9785. * Enable or disable the sprites render time capture
  9786. */
  9787. captureSpritesRenderTime: boolean;
  9788. /**
  9789. * Gets the perf counter used for physics time
  9790. */
  9791. readonly physicsTimeCounter: PerfCounter;
  9792. /**
  9793. * Gets the physics time capture status
  9794. */
  9795. /**
  9796. * Enable or disable the physics time capture
  9797. */
  9798. capturePhysicsTime: boolean;
  9799. /**
  9800. * Gets the perf counter used for animations time
  9801. */
  9802. readonly animationsTimeCounter: PerfCounter;
  9803. /**
  9804. * Gets the animations time capture status
  9805. */
  9806. /**
  9807. * Enable or disable the animations time capture
  9808. */
  9809. captureAnimationsTime: boolean;
  9810. /**
  9811. * Gets the perf counter used for frame time capture
  9812. */
  9813. readonly frameTimeCounter: PerfCounter;
  9814. /**
  9815. * Gets the frame time capture status
  9816. */
  9817. /**
  9818. * Enable or disable the frame time capture
  9819. */
  9820. captureFrameTime: boolean;
  9821. /**
  9822. * Gets the perf counter used for inter-frames time capture
  9823. */
  9824. readonly interFrameTimeCounter: PerfCounter;
  9825. /**
  9826. * Gets the inter-frames time capture status
  9827. */
  9828. /**
  9829. * Enable or disable the inter-frames time capture
  9830. */
  9831. captureInterFrameTime: boolean;
  9832. /**
  9833. * Gets the perf counter used for render time capture
  9834. */
  9835. readonly renderTimeCounter: PerfCounter;
  9836. /**
  9837. * Gets the render time capture status
  9838. */
  9839. /**
  9840. * Enable or disable the render time capture
  9841. */
  9842. captureRenderTime: boolean;
  9843. /**
  9844. * Gets the perf counter used for draw calls
  9845. */
  9846. readonly drawCallsCounter: PerfCounter;
  9847. /**
  9848. * Gets the perf counter used for texture collisions
  9849. */
  9850. readonly textureCollisionsCounter: PerfCounter;
  9851. constructor(scene: Scene);
  9852. dispose(): void;
  9853. }
  9854. }
  9855. declare module BABYLON {
  9856. /**
  9857. * @hidden
  9858. **/
  9859. class _TimeToken {
  9860. _startTimeQuery: Nullable<WebGLQuery>;
  9861. _endTimeQuery: Nullable<WebGLQuery>;
  9862. _timeElapsedQuery: Nullable<WebGLQuery>;
  9863. _timeElapsedQueryEnded: boolean;
  9864. }
  9865. }
  9866. declare module BABYLON {
  9867. /**
  9868. * Effect layer options. This helps customizing the behaviour
  9869. * of the effect layer.
  9870. */
  9871. interface IEffectLayerOptions {
  9872. /**
  9873. * Multiplication factor apply to the canvas size to compute the render target size
  9874. * used to generated the objects (the smaller the faster).
  9875. */
  9876. mainTextureRatio: number;
  9877. /**
  9878. * Enforces a fixed size texture to ensure effect stability across devices.
  9879. */
  9880. mainTextureFixedSize?: number;
  9881. /**
  9882. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  9883. */
  9884. alphaBlendingMode: number;
  9885. /**
  9886. * The camera attached to the layer.
  9887. */
  9888. camera: Nullable<Camera>;
  9889. }
  9890. /**
  9891. * The effect layer Helps adding post process effect blended with the main pass.
  9892. *
  9893. * This can be for instance use to generate glow or higlight effects on the scene.
  9894. *
  9895. * The effect layer class can not be used directly and is intented to inherited from to be
  9896. * customized per effects.
  9897. */
  9898. abstract class EffectLayer {
  9899. private _vertexBuffers;
  9900. private _indexBuffer;
  9901. private _cachedDefines;
  9902. private _effectLayerMapGenerationEffect;
  9903. private _effectLayerOptions;
  9904. private _mergeEffect;
  9905. protected _scene: Scene;
  9906. protected _engine: Engine;
  9907. protected _maxSize: number;
  9908. protected _mainTextureDesiredSize: ISize;
  9909. protected _mainTexture: RenderTargetTexture;
  9910. protected _shouldRender: boolean;
  9911. protected _postProcesses: PostProcess[];
  9912. protected _textures: BaseTexture[];
  9913. protected _emissiveTextureAndColor: {
  9914. texture: Nullable<BaseTexture>;
  9915. color: Color4;
  9916. };
  9917. /**
  9918. * The name of the layer
  9919. */
  9920. name: string;
  9921. /**
  9922. * The clear color of the texture used to generate the glow map.
  9923. */
  9924. neutralColor: Color4;
  9925. /**
  9926. * Specifies wether the highlight layer is enabled or not.
  9927. */
  9928. isEnabled: boolean;
  9929. /**
  9930. * Gets the camera attached to the layer.
  9931. */
  9932. readonly camera: Nullable<Camera>;
  9933. /**
  9934. * An event triggered when the effect layer has been disposed.
  9935. */
  9936. onDisposeObservable: Observable<EffectLayer>;
  9937. /**
  9938. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  9939. */
  9940. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  9941. /**
  9942. * An event triggered when the generated texture is being merged in the scene.
  9943. */
  9944. onBeforeComposeObservable: Observable<EffectLayer>;
  9945. /**
  9946. * An event triggered when the generated texture has been merged in the scene.
  9947. */
  9948. onAfterComposeObservable: Observable<EffectLayer>;
  9949. /**
  9950. * An event triggered when the efffect layer changes its size.
  9951. */
  9952. onSizeChangedObservable: Observable<EffectLayer>;
  9953. /**
  9954. * Instantiates a new effect Layer and references it in the scene.
  9955. * @param name The name of the layer
  9956. * @param scene The scene to use the layer in
  9957. */
  9958. constructor(
  9959. /** The Friendly of the effect in the scene */
  9960. name: string, scene: Scene);
  9961. /**
  9962. * Get the effect name of the layer.
  9963. * @return The effect name
  9964. */
  9965. abstract getEffectName(): string;
  9966. /**
  9967. * Checks for the readiness of the element composing the layer.
  9968. * @param subMesh the mesh to check for
  9969. * @param useInstances specify wether or not to use instances to render the mesh
  9970. * @return true if ready otherwise, false
  9971. */
  9972. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9973. /**
  9974. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  9975. * @returns true if the effect requires stencil during the main canvas render pass.
  9976. */
  9977. abstract needStencil(): boolean;
  9978. /**
  9979. * Create the merge effect. This is the shader use to blit the information back
  9980. * to the main canvas at the end of the scene rendering.
  9981. * @returns The effect containing the shader used to merge the effect on the main canvas
  9982. */
  9983. protected abstract _createMergeEffect(): Effect;
  9984. /**
  9985. * Creates the render target textures and post processes used in the effect layer.
  9986. */
  9987. protected abstract _createTextureAndPostProcesses(): void;
  9988. /**
  9989. * Implementation specific of rendering the generating effect on the main canvas.
  9990. * @param effect The effect used to render through
  9991. */
  9992. protected abstract _internalRender(effect: Effect): void;
  9993. /**
  9994. * Sets the required values for both the emissive texture and and the main color.
  9995. */
  9996. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  9997. /**
  9998. * Free any resources and references associated to a mesh.
  9999. * Internal use
  10000. * @param mesh The mesh to free.
  10001. */
  10002. abstract _disposeMesh(mesh: Mesh): void;
  10003. /**
  10004. * Serializes this layer (Glow or Highlight for example)
  10005. * @returns a serialized layer object
  10006. */
  10007. abstract serialize?(): any;
  10008. /**
  10009. * Initializes the effect layer with the required options.
  10010. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  10011. */
  10012. protected _init(options: Partial<IEffectLayerOptions>): void;
  10013. /**
  10014. * Generates the index buffer of the full screen quad blending to the main canvas.
  10015. */
  10016. private _generateIndexBuffer();
  10017. /**
  10018. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  10019. */
  10020. private _genrateVertexBuffer();
  10021. /**
  10022. * Sets the main texture desired size which is the closest power of two
  10023. * of the engine canvas size.
  10024. */
  10025. private _setMainTextureSize();
  10026. /**
  10027. * Creates the main texture for the effect layer.
  10028. */
  10029. protected _createMainTexture(): void;
  10030. /**
  10031. * Checks for the readiness of the element composing the layer.
  10032. * @param subMesh the mesh to check for
  10033. * @param useInstances specify wether or not to use instances to render the mesh
  10034. * @param emissiveTexture the associated emissive texture used to generate the glow
  10035. * @return true if ready otherwise, false
  10036. */
  10037. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  10038. /**
  10039. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  10040. */
  10041. render(): void;
  10042. /**
  10043. * Determine if a given mesh will be used in the current effect.
  10044. * @param mesh mesh to test
  10045. * @returns true if the mesh will be used
  10046. */
  10047. hasMesh(mesh: AbstractMesh): boolean;
  10048. /**
  10049. * Returns true if the layer contains information to display, otherwise false.
  10050. * @returns true if the glow layer should be rendered
  10051. */
  10052. shouldRender(): boolean;
  10053. /**
  10054. * Returns true if the mesh should render, otherwise false.
  10055. * @param mesh The mesh to render
  10056. * @returns true if it should render otherwise false
  10057. */
  10058. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10059. /**
  10060. * Returns true if the mesh should render, otherwise false.
  10061. * @param mesh The mesh to render
  10062. * @returns true if it should render otherwise false
  10063. */
  10064. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  10065. /**
  10066. * Renders the submesh passed in parameter to the generation map.
  10067. */
  10068. protected _renderSubMesh(subMesh: SubMesh): void;
  10069. /**
  10070. * Rebuild the required buffers.
  10071. * @hidden Internal use only.
  10072. */
  10073. _rebuild(): void;
  10074. /**
  10075. * Dispose only the render target textures and post process.
  10076. */
  10077. private _disposeTextureAndPostProcesses();
  10078. /**
  10079. * Dispose the highlight layer and free resources.
  10080. */
  10081. dispose(): void;
  10082. /**
  10083. * Gets the class name of the effect layer
  10084. * @returns the string with the class name of the effect layer
  10085. */
  10086. getClassName(): string;
  10087. /**
  10088. * Creates an effect layer from parsed effect layer data
  10089. * @param parsedEffectLayer defines effect layer data
  10090. * @param scene defines the current scene
  10091. * @param rootUrl defines the root URL containing the effect layer information
  10092. * @returns a parsed effect Layer
  10093. */
  10094. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  10095. }
  10096. }
  10097. declare module BABYLON {
  10098. /**
  10099. * Glow layer options. This helps customizing the behaviour
  10100. * of the glow layer.
  10101. */
  10102. interface IGlowLayerOptions {
  10103. /**
  10104. * Multiplication factor apply to the canvas size to compute the render target size
  10105. * used to generated the glowing objects (the smaller the faster).
  10106. */
  10107. mainTextureRatio: number;
  10108. /**
  10109. * Enforces a fixed size texture to ensure resize independant blur.
  10110. */
  10111. mainTextureFixedSize?: number;
  10112. /**
  10113. * How big is the kernel of the blur texture.
  10114. */
  10115. blurKernelSize: number;
  10116. /**
  10117. * The camera attached to the layer.
  10118. */
  10119. camera: Nullable<Camera>;
  10120. /**
  10121. * Enable MSAA by chosing the number of samples.
  10122. */
  10123. mainTextureSamples?: number;
  10124. }
  10125. /**
  10126. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  10127. *
  10128. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10129. * glowy meshes to your scene.
  10130. *
  10131. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  10132. */
  10133. class GlowLayer extends EffectLayer {
  10134. /**
  10135. * Effect Name of the layer.
  10136. */
  10137. static readonly EffectName: string;
  10138. /**
  10139. * The default blur kernel size used for the glow.
  10140. */
  10141. static DefaultBlurKernelSize: number;
  10142. /**
  10143. * The default texture size ratio used for the glow.
  10144. */
  10145. static DefaultTextureRatio: number;
  10146. /**
  10147. * Gets the kernel size of the blur.
  10148. */
  10149. /**
  10150. * Sets the kernel size of the blur.
  10151. */
  10152. blurKernelSize: number;
  10153. /**
  10154. * Gets the glow intensity.
  10155. */
  10156. /**
  10157. * Sets the glow intensity.
  10158. */
  10159. intensity: number;
  10160. private _options;
  10161. private _intensity;
  10162. private _horizontalBlurPostprocess1;
  10163. private _verticalBlurPostprocess1;
  10164. private _horizontalBlurPostprocess2;
  10165. private _verticalBlurPostprocess2;
  10166. private _blurTexture1;
  10167. private _blurTexture2;
  10168. private _postProcesses1;
  10169. private _postProcesses2;
  10170. private _includedOnlyMeshes;
  10171. private _excludedMeshes;
  10172. /**
  10173. * Callback used to let the user override the color selection on a per mesh basis
  10174. */
  10175. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  10176. /**
  10177. * Callback used to let the user override the texture selection on a per mesh basis
  10178. */
  10179. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  10180. /**
  10181. * Instantiates a new glow Layer and references it to the scene.
  10182. * @param name The name of the layer
  10183. * @param scene The scene to use the layer in
  10184. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  10185. */
  10186. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  10187. /**
  10188. * Get the effect name of the layer.
  10189. * @return The effect name
  10190. */
  10191. getEffectName(): string;
  10192. /**
  10193. * Create the merge effect. This is the shader use to blit the information back
  10194. * to the main canvas at the end of the scene rendering.
  10195. */
  10196. protected _createMergeEffect(): Effect;
  10197. /**
  10198. * Creates the render target textures and post processes used in the glow layer.
  10199. */
  10200. protected _createTextureAndPostProcesses(): void;
  10201. /**
  10202. * Checks for the readiness of the element composing the layer.
  10203. * @param subMesh the mesh to check for
  10204. * @param useInstances specify wether or not to use instances to render the mesh
  10205. * @param emissiveTexture the associated emissive texture used to generate the glow
  10206. * @return true if ready otherwise, false
  10207. */
  10208. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10209. /**
  10210. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10211. */
  10212. needStencil(): boolean;
  10213. /**
  10214. * Implementation specific of rendering the generating effect on the main canvas.
  10215. * @param effect The effect used to render through
  10216. */
  10217. protected _internalRender(effect: Effect): void;
  10218. /**
  10219. * Sets the required values for both the emissive texture and and the main color.
  10220. */
  10221. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10222. /**
  10223. * Returns true if the mesh should render, otherwise false.
  10224. * @param mesh The mesh to render
  10225. * @returns true if it should render otherwise false
  10226. */
  10227. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10228. /**
  10229. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  10230. * @param mesh The mesh to exclude from the glow layer
  10231. */
  10232. addExcludedMesh(mesh: Mesh): void;
  10233. /**
  10234. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  10235. * @param mesh The mesh to remove
  10236. */
  10237. removeExcludedMesh(mesh: Mesh): void;
  10238. /**
  10239. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  10240. * @param mesh The mesh to include in the glow layer
  10241. */
  10242. addIncludedOnlyMesh(mesh: Mesh): void;
  10243. /**
  10244. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  10245. * @param mesh The mesh to remove
  10246. */
  10247. removeIncludedOnlyMesh(mesh: Mesh): void;
  10248. /**
  10249. * Determine if a given mesh will be used in the glow layer
  10250. * @param mesh The mesh to test
  10251. * @returns true if the mesh will be highlighted by the current glow layer
  10252. */
  10253. hasMesh(mesh: AbstractMesh): boolean;
  10254. /**
  10255. * Free any resources and references associated to a mesh.
  10256. * Internal use
  10257. * @param mesh The mesh to free.
  10258. */
  10259. _disposeMesh(mesh: Mesh): void;
  10260. /**
  10261. * Gets the class name of the effect layer
  10262. * @returns the string with the class name of the effect layer
  10263. */
  10264. getClassName(): string;
  10265. /**
  10266. * Serializes this glow layer
  10267. * @returns a serialized glow layer object
  10268. */
  10269. serialize(): any;
  10270. /**
  10271. * Creates a Glow Layer from parsed glow layer data
  10272. * @param parsedGlowLayer defines glow layer data
  10273. * @param scene defines the current scene
  10274. * @param rootUrl defines the root URL containing the glow layer information
  10275. * @returns a parsed Glow Layer
  10276. */
  10277. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  10278. }
  10279. }
  10280. declare module BABYLON {
  10281. /**
  10282. * Highlight layer options. This helps customizing the behaviour
  10283. * of the highlight layer.
  10284. */
  10285. interface IHighlightLayerOptions {
  10286. /**
  10287. * Multiplication factor apply to the canvas size to compute the render target size
  10288. * used to generated the glowing objects (the smaller the faster).
  10289. */
  10290. mainTextureRatio: number;
  10291. /**
  10292. * Enforces a fixed size texture to ensure resize independant blur.
  10293. */
  10294. mainTextureFixedSize?: number;
  10295. /**
  10296. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  10297. * of the picture to blur (the smaller the faster).
  10298. */
  10299. blurTextureSizeRatio: number;
  10300. /**
  10301. * How big in texel of the blur texture is the vertical blur.
  10302. */
  10303. blurVerticalSize: number;
  10304. /**
  10305. * How big in texel of the blur texture is the horizontal blur.
  10306. */
  10307. blurHorizontalSize: number;
  10308. /**
  10309. * Alpha blending mode used to apply the blur. Default is combine.
  10310. */
  10311. alphaBlendingMode: number;
  10312. /**
  10313. * The camera attached to the layer.
  10314. */
  10315. camera: Nullable<Camera>;
  10316. /**
  10317. * Should we display highlight as a solid stroke?
  10318. */
  10319. isStroke?: boolean;
  10320. }
  10321. /**
  10322. * The highlight layer Helps adding a glow effect around a mesh.
  10323. *
  10324. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10325. * glowy meshes to your scene.
  10326. *
  10327. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  10328. */
  10329. class HighlightLayer extends EffectLayer {
  10330. name: string;
  10331. /**
  10332. * Effect Name of the highlight layer.
  10333. */
  10334. static readonly EffectName: string;
  10335. /**
  10336. * The neutral color used during the preparation of the glow effect.
  10337. * This is black by default as the blend operation is a blend operation.
  10338. */
  10339. static NeutralColor: Color4;
  10340. /**
  10341. * Stencil value used for glowing meshes.
  10342. */
  10343. static GlowingMeshStencilReference: number;
  10344. /**
  10345. * Stencil value used for the other meshes in the scene.
  10346. */
  10347. static NormalMeshStencilReference: number;
  10348. /**
  10349. * Specifies whether or not the inner glow is ACTIVE in the layer.
  10350. */
  10351. innerGlow: boolean;
  10352. /**
  10353. * Specifies whether or not the outer glow is ACTIVE in the layer.
  10354. */
  10355. outerGlow: boolean;
  10356. /**
  10357. * Gets the horizontal size of the blur.
  10358. */
  10359. /**
  10360. * Specifies the horizontal size of the blur.
  10361. */
  10362. blurHorizontalSize: number;
  10363. /**
  10364. * Gets the vertical size of the blur.
  10365. */
  10366. /**
  10367. * Specifies the vertical size of the blur.
  10368. */
  10369. blurVerticalSize: number;
  10370. /**
  10371. * An event triggered when the highlight layer is being blurred.
  10372. */
  10373. onBeforeBlurObservable: Observable<HighlightLayer>;
  10374. /**
  10375. * An event triggered when the highlight layer has been blurred.
  10376. */
  10377. onAfterBlurObservable: Observable<HighlightLayer>;
  10378. private _instanceGlowingMeshStencilReference;
  10379. private _options;
  10380. private _downSamplePostprocess;
  10381. private _horizontalBlurPostprocess;
  10382. private _verticalBlurPostprocess;
  10383. private _blurTexture;
  10384. private _meshes;
  10385. private _excludedMeshes;
  10386. /**
  10387. * Instantiates a new highlight Layer and references it to the scene..
  10388. * @param name The name of the layer
  10389. * @param scene The scene to use the layer in
  10390. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  10391. */
  10392. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  10393. /**
  10394. * Get the effect name of the layer.
  10395. * @return The effect name
  10396. */
  10397. getEffectName(): string;
  10398. /**
  10399. * Create the merge effect. This is the shader use to blit the information back
  10400. * to the main canvas at the end of the scene rendering.
  10401. */
  10402. protected _createMergeEffect(): Effect;
  10403. /**
  10404. * Creates the render target textures and post processes used in the highlight layer.
  10405. */
  10406. protected _createTextureAndPostProcesses(): void;
  10407. /**
  10408. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10409. */
  10410. needStencil(): boolean;
  10411. /**
  10412. * Checks for the readiness of the element composing the layer.
  10413. * @param subMesh the mesh to check for
  10414. * @param useInstances specify wether or not to use instances to render the mesh
  10415. * @param emissiveTexture the associated emissive texture used to generate the glow
  10416. * @return true if ready otherwise, false
  10417. */
  10418. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10419. /**
  10420. * Implementation specific of rendering the generating effect on the main canvas.
  10421. * @param effect The effect used to render through
  10422. */
  10423. protected _internalRender(effect: Effect): void;
  10424. /**
  10425. * Returns true if the layer contains information to display, otherwise false.
  10426. */
  10427. shouldRender(): boolean;
  10428. /**
  10429. * Returns true if the mesh should render, otherwise false.
  10430. * @param mesh The mesh to render
  10431. * @returns true if it should render otherwise false
  10432. */
  10433. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10434. /**
  10435. * Sets the required values for both the emissive texture and and the main color.
  10436. */
  10437. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10438. /**
  10439. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  10440. * @param mesh The mesh to exclude from the highlight layer
  10441. */
  10442. addExcludedMesh(mesh: Mesh): void;
  10443. /**
  10444. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  10445. * @param mesh The mesh to highlight
  10446. */
  10447. removeExcludedMesh(mesh: Mesh): void;
  10448. /**
  10449. * Determine if a given mesh will be highlighted by the current HighlightLayer
  10450. * @param mesh mesh to test
  10451. * @returns true if the mesh will be highlighted by the current HighlightLayer
  10452. */
  10453. hasMesh(mesh: AbstractMesh): boolean;
  10454. /**
  10455. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  10456. * @param mesh The mesh to highlight
  10457. * @param color The color of the highlight
  10458. * @param glowEmissiveOnly Extract the glow from the emissive texture
  10459. */
  10460. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  10461. /**
  10462. * Remove a mesh from the highlight layer in order to make it stop glowing.
  10463. * @param mesh The mesh to highlight
  10464. */
  10465. removeMesh(mesh: Mesh): void;
  10466. /**
  10467. * Force the stencil to the normal expected value for none glowing parts
  10468. */
  10469. private _defaultStencilReference(mesh);
  10470. /**
  10471. * Free any resources and references associated to a mesh.
  10472. * Internal use
  10473. * @param mesh The mesh to free.
  10474. */
  10475. _disposeMesh(mesh: Mesh): void;
  10476. /**
  10477. * Dispose the highlight layer and free resources.
  10478. */
  10479. dispose(): void;
  10480. /**
  10481. * Gets the class name of the effect layer
  10482. * @returns the string with the class name of the effect layer
  10483. */
  10484. getClassName(): string;
  10485. /**
  10486. * Serializes this Highlight layer
  10487. * @returns a serialized Highlight layer object
  10488. */
  10489. serialize(): any;
  10490. /**
  10491. * Creates a Highlight layer from parsed Highlight layer data
  10492. * @param parsedHightlightLayer defines the Highlight layer data
  10493. * @param scene defines the current scene
  10494. * @param rootUrl defines the root URL containing the Highlight layer information
  10495. * @returns a parsed Highlight layer
  10496. */
  10497. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  10498. }
  10499. }
  10500. declare module BABYLON {
  10501. class Layer {
  10502. name: string;
  10503. texture: Nullable<Texture>;
  10504. isBackground: boolean;
  10505. color: Color4;
  10506. scale: Vector2;
  10507. offset: Vector2;
  10508. alphaBlendingMode: number;
  10509. alphaTest: boolean;
  10510. layerMask: number;
  10511. private _scene;
  10512. private _vertexBuffers;
  10513. private _indexBuffer;
  10514. private _effect;
  10515. private _alphaTestEffect;
  10516. /**
  10517. * An event triggered when the layer is disposed.
  10518. */
  10519. onDisposeObservable: Observable<Layer>;
  10520. private _onDisposeObserver;
  10521. onDispose: () => void;
  10522. /**
  10523. * An event triggered before rendering the scene
  10524. */
  10525. onBeforeRenderObservable: Observable<Layer>;
  10526. private _onBeforeRenderObserver;
  10527. onBeforeRender: () => void;
  10528. /**
  10529. * An event triggered after rendering the scene
  10530. */
  10531. onAfterRenderObservable: Observable<Layer>;
  10532. private _onAfterRenderObserver;
  10533. onAfterRender: () => void;
  10534. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  10535. private _createIndexBuffer();
  10536. _rebuild(): void;
  10537. render(): void;
  10538. dispose(): void;
  10539. }
  10540. }
  10541. declare module BABYLON {
  10542. class LensFlare {
  10543. size: number;
  10544. position: number;
  10545. color: Color3;
  10546. texture: Nullable<Texture>;
  10547. alphaMode: number;
  10548. private _system;
  10549. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  10550. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  10551. dispose(): void;
  10552. }
  10553. }
  10554. declare module BABYLON {
  10555. class LensFlareSystem {
  10556. name: string;
  10557. lensFlares: LensFlare[];
  10558. borderLimit: number;
  10559. viewportBorder: number;
  10560. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  10561. layerMask: number;
  10562. id: string;
  10563. private _scene;
  10564. private _emitter;
  10565. private _vertexBuffers;
  10566. private _indexBuffer;
  10567. private _effect;
  10568. private _positionX;
  10569. private _positionY;
  10570. private _isEnabled;
  10571. constructor(name: string, emitter: any, scene: Scene);
  10572. isEnabled: boolean;
  10573. getScene(): Scene;
  10574. getEmitter(): any;
  10575. setEmitter(newEmitter: any): void;
  10576. getEmitterPosition(): Vector3;
  10577. computeEffectivePosition(globalViewport: Viewport): boolean;
  10578. _isVisible(): boolean;
  10579. render(): boolean;
  10580. dispose(): void;
  10581. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  10582. serialize(): any;
  10583. }
  10584. }
  10585. declare module BABYLON {
  10586. /**
  10587. * A directional light is defined by a direction (what a surprise!).
  10588. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  10589. * 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.
  10590. * Documentation: https://doc.babylonjs.com/babylon101/lights
  10591. */
  10592. class DirectionalLight extends ShadowLight {
  10593. private _shadowFrustumSize;
  10594. /**
  10595. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  10596. */
  10597. /**
  10598. * Specifies a fix frustum size for the shadow generation.
  10599. */
  10600. shadowFrustumSize: number;
  10601. private _shadowOrthoScale;
  10602. /**
  10603. * Gets the shadow projection scale against the optimal computed one.
  10604. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  10605. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  10606. */
  10607. /**
  10608. * Sets the shadow projection scale against the optimal computed one.
  10609. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  10610. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  10611. */
  10612. shadowOrthoScale: number;
  10613. /**
  10614. * Automatically compute the projection matrix to best fit (including all the casters)
  10615. * on each frame.
  10616. */
  10617. autoUpdateExtends: boolean;
  10618. private _orthoLeft;
  10619. private _orthoRight;
  10620. private _orthoTop;
  10621. private _orthoBottom;
  10622. /**
  10623. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  10624. * The directional light is emitted from everywhere in the given direction.
  10625. * It can cast shawdows.
  10626. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10627. * @param name The friendly name of the light
  10628. * @param direction The direction of the light
  10629. * @param scene The scene the light belongs to
  10630. */
  10631. constructor(name: string, direction: Vector3, scene: Scene);
  10632. /**
  10633. * Returns the string "DirectionalLight".
  10634. * @return The class name
  10635. */
  10636. getClassName(): string;
  10637. /**
  10638. * Returns the integer 1.
  10639. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10640. */
  10641. getTypeID(): number;
  10642. /**
  10643. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  10644. * Returns the DirectionalLight Shadow projection matrix.
  10645. */
  10646. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10647. /**
  10648. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  10649. * Returns the DirectionalLight Shadow projection matrix.
  10650. */
  10651. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  10652. /**
  10653. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  10654. * Returns the DirectionalLight Shadow projection matrix.
  10655. */
  10656. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10657. protected _buildUniformLayout(): void;
  10658. /**
  10659. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  10660. * @param effect The effect to update
  10661. * @param lightIndex The index of the light in the effect to update
  10662. * @returns The directional light
  10663. */
  10664. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  10665. /**
  10666. * Gets the minZ used for shadow according to both the scene and the light.
  10667. *
  10668. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  10669. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  10670. * @param activeCamera The camera we are returning the min for
  10671. * @returns the depth min z
  10672. */
  10673. getDepthMinZ(activeCamera: Camera): number;
  10674. /**
  10675. * Gets the maxZ used for shadow according to both the scene and the light.
  10676. *
  10677. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  10678. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  10679. * @param activeCamera The camera we are returning the max for
  10680. * @returns the depth max z
  10681. */
  10682. getDepthMaxZ(activeCamera: Camera): number;
  10683. }
  10684. }
  10685. declare module BABYLON {
  10686. /**
  10687. * The HemisphericLight simulates the ambient environment light,
  10688. * so the passed direction is the light reflection direction, not the incoming direction.
  10689. */
  10690. class HemisphericLight extends Light {
  10691. /**
  10692. * The groundColor is the light in the opposite direction to the one specified during creation.
  10693. * 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.
  10694. */
  10695. groundColor: Color3;
  10696. /**
  10697. * The light reflection direction, not the incoming direction.
  10698. */
  10699. direction: Vector3;
  10700. private _worldMatrix;
  10701. /**
  10702. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  10703. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  10704. * The HemisphericLight can't cast shadows.
  10705. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10706. * @param name The friendly name of the light
  10707. * @param direction The direction of the light reflection
  10708. * @param scene The scene the light belongs to
  10709. */
  10710. constructor(name: string, direction: Vector3, scene: Scene);
  10711. protected _buildUniformLayout(): void;
  10712. /**
  10713. * Returns the string "HemisphericLight".
  10714. * @return The class name
  10715. */
  10716. getClassName(): string;
  10717. /**
  10718. * Sets the HemisphericLight direction towards the passed target (Vector3).
  10719. * Returns the updated direction.
  10720. * @param target The target the direction should point to
  10721. * @return The computed direction
  10722. */
  10723. setDirectionToTarget(target: Vector3): Vector3;
  10724. /**
  10725. * Returns the shadow generator associated to the light.
  10726. * @returns Always null for hemispheric lights because it does not support shadows.
  10727. */
  10728. getShadowGenerator(): Nullable<ShadowGenerator>;
  10729. /**
  10730. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  10731. * @param effect The effect to update
  10732. * @param lightIndex The index of the light in the effect to update
  10733. * @returns The hemispheric light
  10734. */
  10735. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  10736. /**
  10737. * @hidden internal use only.
  10738. */
  10739. _getWorldMatrix(): Matrix;
  10740. /**
  10741. * Returns the integer 3.
  10742. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10743. */
  10744. getTypeID(): number;
  10745. }
  10746. }
  10747. declare module BABYLON {
  10748. /**
  10749. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10750. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10751. * 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.
  10752. */
  10753. abstract class Light extends Node {
  10754. private static _LIGHTMAP_DEFAULT;
  10755. private static _LIGHTMAP_SPECULAR;
  10756. private static _LIGHTMAP_SHADOWSONLY;
  10757. /**
  10758. * If every light affecting the material is in this lightmapMode,
  10759. * material.lightmapTexture adds or multiplies
  10760. * (depends on material.useLightmapAsShadowmap)
  10761. * after every other light calculations.
  10762. */
  10763. static readonly LIGHTMAP_DEFAULT: number;
  10764. /**
  10765. * material.lightmapTexture as only diffuse lighting from this light
  10766. * adds only specular lighting from this light
  10767. * adds dynamic shadows
  10768. */
  10769. static readonly LIGHTMAP_SPECULAR: number;
  10770. /**
  10771. * material.lightmapTexture as only lighting
  10772. * no light calculation from this light
  10773. * only adds dynamic shadows from this light
  10774. */
  10775. static readonly LIGHTMAP_SHADOWSONLY: number;
  10776. private static _INTENSITYMODE_AUTOMATIC;
  10777. private static _INTENSITYMODE_LUMINOUSPOWER;
  10778. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  10779. private static _INTENSITYMODE_ILLUMINANCE;
  10780. private static _INTENSITYMODE_LUMINANCE;
  10781. /**
  10782. * Each light type uses the default quantity according to its type:
  10783. * point/spot lights use luminous intensity
  10784. * directional lights use illuminance
  10785. */
  10786. static readonly INTENSITYMODE_AUTOMATIC: number;
  10787. /**
  10788. * lumen (lm)
  10789. */
  10790. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10791. /**
  10792. * candela (lm/sr)
  10793. */
  10794. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10795. /**
  10796. * lux (lm/m^2)
  10797. */
  10798. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10799. /**
  10800. * nit (cd/m^2)
  10801. */
  10802. static readonly INTENSITYMODE_LUMINANCE: number;
  10803. private static _LIGHTTYPEID_POINTLIGHT;
  10804. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  10805. private static _LIGHTTYPEID_SPOTLIGHT;
  10806. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  10807. /**
  10808. * Light type const id of the point light.
  10809. */
  10810. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10811. /**
  10812. * Light type const id of the directional light.
  10813. */
  10814. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10815. /**
  10816. * Light type const id of the spot light.
  10817. */
  10818. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10819. /**
  10820. * Light type const id of the hemispheric light.
  10821. */
  10822. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10823. /**
  10824. * Diffuse gives the basic color to an object.
  10825. */
  10826. diffuse: Color3;
  10827. /**
  10828. * Specular produces a highlight color on an object.
  10829. * Note: This is note affecting PBR materials.
  10830. */
  10831. specular: Color3;
  10832. /**
  10833. * Strength of the light.
  10834. * Note: By default it is define in the framework own unit.
  10835. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10836. */
  10837. intensity: number;
  10838. /**
  10839. * Defines how far from the source the light is impacting in scene units.
  10840. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10841. */
  10842. range: number;
  10843. /**
  10844. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10845. * of light.
  10846. */
  10847. private _photometricScale;
  10848. private _intensityMode;
  10849. /**
  10850. * Gets the photometric scale used to interpret the intensity.
  10851. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10852. */
  10853. /**
  10854. * Sets the photometric scale used to interpret the intensity.
  10855. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10856. */
  10857. intensityMode: number;
  10858. private _radius;
  10859. /**
  10860. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10861. */
  10862. /**
  10863. * sets the light radius used by PBR Materials to simulate soft area lights.
  10864. */
  10865. radius: number;
  10866. private _renderPriority;
  10867. /**
  10868. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10869. * exceeding the number allowed of the materials.
  10870. */
  10871. renderPriority: number;
  10872. private _shadowEnabled;
  10873. /**
  10874. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10875. * the current shadow generator.
  10876. */
  10877. /**
  10878. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10879. * the current shadow generator.
  10880. */
  10881. shadowEnabled: boolean;
  10882. private _includedOnlyMeshes;
  10883. /**
  10884. * Gets the only meshes impacted by this light.
  10885. */
  10886. /**
  10887. * Sets the only meshes impacted by this light.
  10888. */
  10889. includedOnlyMeshes: AbstractMesh[];
  10890. private _excludedMeshes;
  10891. /**
  10892. * Gets the meshes not impacted by this light.
  10893. */
  10894. /**
  10895. * Sets the meshes not impacted by this light.
  10896. */
  10897. excludedMeshes: AbstractMesh[];
  10898. private _excludeWithLayerMask;
  10899. /**
  10900. * Gets the layer id use to find what meshes are not impacted by the light.
  10901. * Inactive if 0
  10902. */
  10903. /**
  10904. * Sets the layer id use to find what meshes are not impacted by the light.
  10905. * Inactive if 0
  10906. */
  10907. excludeWithLayerMask: number;
  10908. private _includeOnlyWithLayerMask;
  10909. /**
  10910. * Gets the layer id use to find what meshes are impacted by the light.
  10911. * Inactive if 0
  10912. */
  10913. /**
  10914. * Sets the layer id use to find what meshes are impacted by the light.
  10915. * Inactive if 0
  10916. */
  10917. includeOnlyWithLayerMask: number;
  10918. private _lightmapMode;
  10919. /**
  10920. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10921. */
  10922. /**
  10923. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10924. */
  10925. lightmapMode: number;
  10926. private _parentedWorldMatrix;
  10927. /**
  10928. * Shadow generator associted to the light.
  10929. * Internal use only.
  10930. */
  10931. _shadowGenerator: Nullable<IShadowGenerator>;
  10932. /**
  10933. * @hidden Internal use only.
  10934. */
  10935. _excludedMeshesIds: string[];
  10936. /**
  10937. * @hidden Internal use only.
  10938. */
  10939. _includedOnlyMeshesIds: string[];
  10940. /**
  10941. * The current light unifom buffer.
  10942. * @hidden Internal use only.
  10943. */
  10944. _uniformBuffer: UniformBuffer;
  10945. /**
  10946. * Creates a Light object in the scene.
  10947. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10948. * @param name The firendly name of the light
  10949. * @param scene The scene the light belongs too
  10950. */
  10951. constructor(name: string, scene: Scene);
  10952. protected abstract _buildUniformLayout(): void;
  10953. /**
  10954. * Sets the passed Effect "effect" with the Light information.
  10955. * @param effect The effect to update
  10956. * @param lightIndex The index of the light in the effect to update
  10957. * @returns The light
  10958. */
  10959. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10960. /**
  10961. * @hidden internal use only.
  10962. */
  10963. abstract _getWorldMatrix(): Matrix;
  10964. /**
  10965. * Returns the string "Light".
  10966. * @returns the class name
  10967. */
  10968. getClassName(): string;
  10969. /**
  10970. * Converts the light information to a readable string for debug purpose.
  10971. * @param fullDetails Supports for multiple levels of logging within scene loading
  10972. * @returns the human readable light info
  10973. */
  10974. toString(fullDetails?: boolean): string;
  10975. /**
  10976. * Set the enabled state of this node.
  10977. * @param value - the new enabled state
  10978. */
  10979. setEnabled(value: boolean): void;
  10980. /**
  10981. * Returns the Light associated shadow generator if any.
  10982. * @return the associated shadow generator.
  10983. */
  10984. getShadowGenerator(): Nullable<IShadowGenerator>;
  10985. /**
  10986. * Returns a Vector3, the absolute light position in the World.
  10987. * @returns the world space position of the light
  10988. */
  10989. getAbsolutePosition(): Vector3;
  10990. /**
  10991. * Specifies if the light will affect the passed mesh.
  10992. * @param mesh The mesh to test against the light
  10993. * @return true the mesh is affected otherwise, false.
  10994. */
  10995. canAffectMesh(mesh: AbstractMesh): boolean;
  10996. /**
  10997. * Computes and Returns the light World matrix.
  10998. * @returns the world matrix
  10999. */
  11000. getWorldMatrix(): Matrix;
  11001. /**
  11002. * Sort function to order lights for rendering.
  11003. * @param a First Light object to compare to second.
  11004. * @param b Second Light object to compare first.
  11005. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11006. */
  11007. static CompareLightsPriority(a: Light, b: Light): number;
  11008. /**
  11009. * Releases resources associated with this node.
  11010. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11011. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11012. */
  11013. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11014. /**
  11015. * Returns the light type ID (integer).
  11016. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11017. */
  11018. getTypeID(): number;
  11019. /**
  11020. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11021. * @returns the scaled intensity in intensity mode unit
  11022. */
  11023. getScaledIntensity(): number;
  11024. /**
  11025. * Returns a new Light object, named "name", from the current one.
  11026. * @param name The name of the cloned light
  11027. * @returns the new created light
  11028. */
  11029. clone(name: string): Nullable<Light>;
  11030. /**
  11031. * Serializes the current light into a Serialization object.
  11032. * @returns the serialized object.
  11033. */
  11034. serialize(): any;
  11035. /**
  11036. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11037. * This new light is named "name" and added to the passed scene.
  11038. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11039. * @param name The friendly name of the light
  11040. * @param scene The scene the new light will belong to
  11041. * @returns the constructor function
  11042. */
  11043. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11044. /**
  11045. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11046. * @param parsedLight The JSON representation of the light
  11047. * @param scene The scene to create the parsed light in
  11048. * @returns the created light after parsing
  11049. */
  11050. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11051. private _hookArrayForExcluded(array);
  11052. private _hookArrayForIncludedOnly(array);
  11053. private _resyncMeshes();
  11054. /**
  11055. * Forces the meshes to update their light related information in their rendering used effects
  11056. * @hidden Internal Use Only
  11057. */
  11058. _markMeshesAsLightDirty(): void;
  11059. /**
  11060. * Recomputes the cached photometric scale if needed.
  11061. */
  11062. private _computePhotometricScale();
  11063. /**
  11064. * Returns the Photometric Scale according to the light type and intensity mode.
  11065. */
  11066. private _getPhotometricScale();
  11067. /**
  11068. * Reorder the light in the scene according to their defined priority.
  11069. * @hidden Internal Use Only
  11070. */
  11071. _reorderLightsInScene(): void;
  11072. }
  11073. }
  11074. declare module BABYLON {
  11075. /**
  11076. * A point light is a light defined by an unique point in world space.
  11077. * The light is emitted in every direction from this point.
  11078. * A good example of a point light is a standard light bulb.
  11079. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11080. */
  11081. class PointLight extends ShadowLight {
  11082. private _shadowAngle;
  11083. /**
  11084. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11085. * This specifies what angle the shadow will use to be created.
  11086. *
  11087. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11088. */
  11089. /**
  11090. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11091. * This specifies what angle the shadow will use to be created.
  11092. *
  11093. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11094. */
  11095. shadowAngle: number;
  11096. /**
  11097. * Gets the direction if it has been set.
  11098. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11099. */
  11100. /**
  11101. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11102. */
  11103. direction: Vector3;
  11104. /**
  11105. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  11106. * A PointLight emits the light in every direction.
  11107. * It can cast shadows.
  11108. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  11109. * ```javascript
  11110. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  11111. * ```
  11112. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11113. * @param name The light friendly name
  11114. * @param position The position of the point light in the scene
  11115. * @param scene The scene the lights belongs to
  11116. */
  11117. constructor(name: string, position: Vector3, scene: Scene);
  11118. /**
  11119. * Returns the string "PointLight"
  11120. * @returns the class name
  11121. */
  11122. getClassName(): string;
  11123. /**
  11124. * Returns the integer 0.
  11125. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11126. */
  11127. getTypeID(): number;
  11128. /**
  11129. * Specifies wether or not the shadowmap should be a cube texture.
  11130. * @returns true if the shadowmap needs to be a cube texture.
  11131. */
  11132. needCube(): boolean;
  11133. /**
  11134. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  11135. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11136. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11137. */
  11138. getShadowDirection(faceIndex?: number): Vector3;
  11139. /**
  11140. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  11141. * - fov = PI / 2
  11142. * - aspect ratio : 1.0
  11143. * - z-near and far equal to the active camera minZ and maxZ.
  11144. * Returns the PointLight.
  11145. */
  11146. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11147. protected _buildUniformLayout(): void;
  11148. /**
  11149. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  11150. * @param effect The effect to update
  11151. * @param lightIndex The index of the light in the effect to update
  11152. * @returns The point light
  11153. */
  11154. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  11155. }
  11156. }
  11157. declare module BABYLON {
  11158. /**
  11159. * Interface describing all the common properties and methods a shadow light needs to implement.
  11160. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  11161. * as well as binding the different shadow properties to the effects.
  11162. */
  11163. interface IShadowLight extends Light {
  11164. /**
  11165. * The light id in the scene (used in scene.findLighById for instance)
  11166. */
  11167. id: string;
  11168. /**
  11169. * The position the shdow will be casted from.
  11170. */
  11171. position: Vector3;
  11172. /**
  11173. * In 2d mode (needCube being false), the direction used to cast the shadow.
  11174. */
  11175. direction: Vector3;
  11176. /**
  11177. * The transformed position. Position of the light in world space taking parenting in account.
  11178. */
  11179. transformedPosition: Vector3;
  11180. /**
  11181. * The transformed direction. Direction of the light in world space taking parenting in account.
  11182. */
  11183. transformedDirection: Vector3;
  11184. /**
  11185. * The friendly name of the light in the scene.
  11186. */
  11187. name: string;
  11188. /**
  11189. * Defines the shadow projection clipping minimum z value.
  11190. */
  11191. shadowMinZ: number;
  11192. /**
  11193. * Defines the shadow projection clipping maximum z value.
  11194. */
  11195. shadowMaxZ: number;
  11196. /**
  11197. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11198. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11199. */
  11200. computeTransformedInformation(): boolean;
  11201. /**
  11202. * Gets the scene the light belongs to.
  11203. * @returns The scene
  11204. */
  11205. getScene(): Scene;
  11206. /**
  11207. * Callback defining a custom Projection Matrix Builder.
  11208. * This can be used to override the default projection matrix computation.
  11209. */
  11210. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11211. /**
  11212. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11213. * @param matrix The materix to updated with the projection information
  11214. * @param viewMatrix The transform matrix of the light
  11215. * @param renderList The list of mesh to render in the map
  11216. * @returns The current light
  11217. */
  11218. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11219. /**
  11220. * Gets the current depth scale used in ESM.
  11221. * @returns The scale
  11222. */
  11223. getDepthScale(): number;
  11224. /**
  11225. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11226. * @returns true if a cube texture needs to be use
  11227. */
  11228. needCube(): boolean;
  11229. /**
  11230. * Detects if the projection matrix requires to be recomputed this frame.
  11231. * @returns true if it requires to be recomputed otherwise, false.
  11232. */
  11233. needProjectionMatrixCompute(): boolean;
  11234. /**
  11235. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11236. */
  11237. forceProjectionMatrixCompute(): void;
  11238. /**
  11239. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11240. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11241. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11242. */
  11243. getShadowDirection(faceIndex?: number): Vector3;
  11244. /**
  11245. * Gets the minZ used for shadow according to both the scene and the light.
  11246. * @param activeCamera The camera we are returning the min for
  11247. * @returns the depth min z
  11248. */
  11249. getDepthMinZ(activeCamera: Camera): number;
  11250. /**
  11251. * Gets the maxZ used for shadow according to both the scene and the light.
  11252. * @param activeCamera The camera we are returning the max for
  11253. * @returns the depth max z
  11254. */
  11255. getDepthMaxZ(activeCamera: Camera): number;
  11256. }
  11257. /**
  11258. * Base implementation IShadowLight
  11259. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  11260. */
  11261. abstract class ShadowLight extends Light implements IShadowLight {
  11262. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11263. protected _position: Vector3;
  11264. protected _setPosition(value: Vector3): void;
  11265. /**
  11266. * Sets the position the shadow will be casted from. Also use as the light position for both
  11267. * point and spot lights.
  11268. */
  11269. /**
  11270. * Sets the position the shadow will be casted from. Also use as the light position for both
  11271. * point and spot lights.
  11272. */
  11273. position: Vector3;
  11274. protected _direction: Vector3;
  11275. protected _setDirection(value: Vector3): void;
  11276. /**
  11277. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  11278. * Also use as the light direction on spot and directional lights.
  11279. */
  11280. /**
  11281. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  11282. * Also use as the light direction on spot and directional lights.
  11283. */
  11284. direction: Vector3;
  11285. private _shadowMinZ;
  11286. /**
  11287. * Gets the shadow projection clipping minimum z value.
  11288. */
  11289. /**
  11290. * Sets the shadow projection clipping minimum z value.
  11291. */
  11292. shadowMinZ: number;
  11293. private _shadowMaxZ;
  11294. /**
  11295. * Sets the shadow projection clipping maximum z value.
  11296. */
  11297. /**
  11298. * Gets the shadow projection clipping maximum z value.
  11299. */
  11300. shadowMaxZ: number;
  11301. /**
  11302. * Callback defining a custom Projection Matrix Builder.
  11303. * This can be used to override the default projection matrix computation.
  11304. */
  11305. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11306. /**
  11307. * The transformed position. Position of the light in world space taking parenting in account.
  11308. */
  11309. transformedPosition: Vector3;
  11310. /**
  11311. * The transformed direction. Direction of the light in world space taking parenting in account.
  11312. */
  11313. transformedDirection: Vector3;
  11314. private _worldMatrix;
  11315. private _needProjectionMatrixCompute;
  11316. /**
  11317. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11318. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11319. */
  11320. computeTransformedInformation(): boolean;
  11321. /**
  11322. * Return the depth scale used for the shadow map.
  11323. * @returns the depth scale.
  11324. */
  11325. getDepthScale(): number;
  11326. /**
  11327. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11328. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11329. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11330. */
  11331. getShadowDirection(faceIndex?: number): Vector3;
  11332. /**
  11333. * Returns the ShadowLight absolute position in the World.
  11334. * @returns the position vector in world space
  11335. */
  11336. getAbsolutePosition(): Vector3;
  11337. /**
  11338. * Sets the ShadowLight direction toward the passed target.
  11339. * @param target The point tot target in local space
  11340. * @returns the updated ShadowLight direction
  11341. */
  11342. setDirectionToTarget(target: Vector3): Vector3;
  11343. /**
  11344. * Returns the light rotation in euler definition.
  11345. * @returns the x y z rotation in local space.
  11346. */
  11347. getRotation(): Vector3;
  11348. /**
  11349. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11350. * @returns true if a cube texture needs to be use
  11351. */
  11352. needCube(): boolean;
  11353. /**
  11354. * Detects if the projection matrix requires to be recomputed this frame.
  11355. * @returns true if it requires to be recomputed otherwise, false.
  11356. */
  11357. needProjectionMatrixCompute(): boolean;
  11358. /**
  11359. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11360. */
  11361. forceProjectionMatrixCompute(): void;
  11362. /**
  11363. * Get the world matrix of the sahdow lights.
  11364. * @hidden Internal Use Only
  11365. */
  11366. _getWorldMatrix(): Matrix;
  11367. /**
  11368. * Gets the minZ used for shadow according to both the scene and the light.
  11369. * @param activeCamera The camera we are returning the min for
  11370. * @returns the depth min z
  11371. */
  11372. getDepthMinZ(activeCamera: Camera): number;
  11373. /**
  11374. * Gets the maxZ used for shadow according to both the scene and the light.
  11375. * @param activeCamera The camera we are returning the max for
  11376. * @returns the depth max z
  11377. */
  11378. getDepthMaxZ(activeCamera: Camera): number;
  11379. /**
  11380. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11381. * @param matrix The materix to updated with the projection information
  11382. * @param viewMatrix The transform matrix of the light
  11383. * @param renderList The list of mesh to render in the map
  11384. * @returns The current light
  11385. */
  11386. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11387. }
  11388. }
  11389. declare module BABYLON {
  11390. /**
  11391. * A spot light is defined by a position, a direction, an angle, and an exponent.
  11392. * These values define a cone of light starting from the position, emitting toward the direction.
  11393. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  11394. * and the exponent defines the speed of the decay of the light with distance (reach).
  11395. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11396. */
  11397. class SpotLight extends ShadowLight {
  11398. private _angle;
  11399. /**
  11400. * Gets the cone angle of the spot light in Radians.
  11401. */
  11402. /**
  11403. * Sets the cone angle of the spot light in Radians.
  11404. */
  11405. angle: number;
  11406. private _shadowAngleScale;
  11407. /**
  11408. * Allows scaling the angle of the light for shadow generation only.
  11409. */
  11410. /**
  11411. * Allows scaling the angle of the light for shadow generation only.
  11412. */
  11413. shadowAngleScale: number;
  11414. /**
  11415. * The light decay speed with the distance from the emission spot.
  11416. */
  11417. exponent: number;
  11418. private _projectionTextureMatrix;
  11419. /**
  11420. * Allows reading the projecton texture
  11421. */
  11422. readonly projectionTextureMatrix: Matrix;
  11423. protected _projectionTextureLightNear: number;
  11424. /**
  11425. * Gets the near clip of the Spotlight for texture projection.
  11426. */
  11427. /**
  11428. * Sets the near clip of the Spotlight for texture projection.
  11429. */
  11430. projectionTextureLightNear: number;
  11431. protected _projectionTextureLightFar: number;
  11432. /**
  11433. * Gets the far clip of the Spotlight for texture projection.
  11434. */
  11435. /**
  11436. * Sets the far clip of the Spotlight for texture projection.
  11437. */
  11438. projectionTextureLightFar: number;
  11439. protected _projectionTextureUpDirection: Vector3;
  11440. /**
  11441. * Gets the Up vector of the Spotlight for texture projection.
  11442. */
  11443. /**
  11444. * Sets the Up vector of the Spotlight for texture projection.
  11445. */
  11446. projectionTextureUpDirection: Vector3;
  11447. private _projectionTexture;
  11448. /**
  11449. * Gets the projection texture of the light.
  11450. */
  11451. /**
  11452. * Sets the projection texture of the light.
  11453. */
  11454. projectionTexture: Nullable<BaseTexture>;
  11455. private _projectionTextureViewLightDirty;
  11456. private _projectionTextureProjectionLightDirty;
  11457. private _projectionTextureDirty;
  11458. private _projectionTextureViewTargetVector;
  11459. private _projectionTextureViewLightMatrix;
  11460. private _projectionTextureProjectionLightMatrix;
  11461. private _projectionTextureScalingMatrix;
  11462. /**
  11463. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  11464. * It can cast shadows.
  11465. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11466. * @param name The light friendly name
  11467. * @param position The position of the spot light in the scene
  11468. * @param direction The direction of the light in the scene
  11469. * @param angle The cone angle of the light in Radians
  11470. * @param exponent The light decay speed with the distance from the emission spot
  11471. * @param scene The scene the lights belongs to
  11472. */
  11473. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  11474. /**
  11475. * Returns the string "SpotLight".
  11476. * @returns the class name
  11477. */
  11478. getClassName(): string;
  11479. /**
  11480. * Returns the integer 2.
  11481. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11482. */
  11483. getTypeID(): number;
  11484. /**
  11485. * Overrides the direction setter to recompute the projection texture view light Matrix.
  11486. */
  11487. protected _setDirection(value: Vector3): void;
  11488. /**
  11489. * Overrides the position setter to recompute the projection texture view light Matrix.
  11490. */
  11491. protected _setPosition(value: Vector3): void;
  11492. /**
  11493. * 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.
  11494. * Returns the SpotLight.
  11495. */
  11496. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11497. protected _computeProjectionTextureViewLightMatrix(): void;
  11498. protected _computeProjectionTextureProjectionLightMatrix(): void;
  11499. /**
  11500. * Main function for light texture projection matrix computing.
  11501. */
  11502. protected _computeProjectionTextureMatrix(): void;
  11503. protected _buildUniformLayout(): void;
  11504. /**
  11505. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  11506. * @param effect The effect to update
  11507. * @param lightIndex The index of the light in the effect to update
  11508. * @returns The spot light
  11509. */
  11510. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  11511. /**
  11512. * Disposes the light and the associated resources.
  11513. */
  11514. dispose(): void;
  11515. }
  11516. }
  11517. declare module BABYLON {
  11518. interface ILoadingScreen {
  11519. displayLoadingUI: () => void;
  11520. hideLoadingUI: () => void;
  11521. loadingUIBackgroundColor: string;
  11522. loadingUIText: string;
  11523. }
  11524. class DefaultLoadingScreen implements ILoadingScreen {
  11525. private _renderingCanvas;
  11526. private _loadingText;
  11527. private _loadingDivBackgroundColor;
  11528. private _loadingDiv;
  11529. private _loadingTextDiv;
  11530. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  11531. displayLoadingUI(): void;
  11532. hideLoadingUI(): void;
  11533. loadingUIText: string;
  11534. loadingUIBackgroundColor: string;
  11535. private _resizeLoadingUI;
  11536. }
  11537. }
  11538. declare module BABYLON {
  11539. class SceneLoaderProgressEvent {
  11540. readonly lengthComputable: boolean;
  11541. readonly loaded: number;
  11542. readonly total: number;
  11543. constructor(lengthComputable: boolean, loaded: number, total: number);
  11544. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  11545. }
  11546. interface ISceneLoaderPluginExtensions {
  11547. [extension: string]: {
  11548. isBinary: boolean;
  11549. };
  11550. }
  11551. interface ISceneLoaderPluginFactory {
  11552. name: string;
  11553. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  11554. canDirectLoad?: (data: string) => boolean;
  11555. }
  11556. interface ISceneLoaderPlugin {
  11557. /**
  11558. * The friendly name of this plugin.
  11559. */
  11560. name: string;
  11561. /**
  11562. * The file extensions supported by this plugin.
  11563. */
  11564. extensions: string | ISceneLoaderPluginExtensions;
  11565. /**
  11566. * Import meshes into a scene.
  11567. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11568. * @param scene The scene to import into
  11569. * @param data The data to import
  11570. * @param rootUrl The root url for scene and resources
  11571. * @param meshes The meshes array to import into
  11572. * @param particleSystems The particle systems array to import into
  11573. * @param skeletons The skeletons array to import into
  11574. * @param onError The callback when import fails
  11575. * @returns True if successful or false otherwise
  11576. */
  11577. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  11578. /**
  11579. * Load into a scene.
  11580. * @param scene The scene to load into
  11581. * @param data The data to import
  11582. * @param rootUrl The root url for scene and resources
  11583. * @param onError The callback when import fails
  11584. * @returns true if successful or false otherwise
  11585. */
  11586. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  11587. /**
  11588. * The callback that returns true if the data can be directly loaded.
  11589. */
  11590. canDirectLoad?: (data: string) => boolean;
  11591. /**
  11592. * The callback that allows custom handling of the root url based on the response url.
  11593. */
  11594. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  11595. /**
  11596. * Load into an asset container.
  11597. * @param scene The scene to load into
  11598. * @param data The data to import
  11599. * @param rootUrl The root url for scene and resources
  11600. * @param onError The callback when import fails
  11601. * @returns The loaded asset container
  11602. */
  11603. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  11604. }
  11605. interface ISceneLoaderPluginAsync {
  11606. /**
  11607. * The friendly name of this plugin.
  11608. */
  11609. name: string;
  11610. /**
  11611. * The file extensions supported by this plugin.
  11612. */
  11613. extensions: string | ISceneLoaderPluginExtensions;
  11614. /**
  11615. * Import meshes into a scene.
  11616. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11617. * @param scene The scene to import into
  11618. * @param data The data to import
  11619. * @param rootUrl The root url for scene and resources
  11620. * @param onProgress The callback when the load progresses
  11621. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  11622. */
  11623. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  11624. meshes: AbstractMesh[];
  11625. particleSystems: ParticleSystem[];
  11626. skeletons: Skeleton[];
  11627. animationGroups: AnimationGroup[];
  11628. }>;
  11629. /**
  11630. * Load into a scene.
  11631. * @param scene The scene to load into
  11632. * @param data The data to import
  11633. * @param rootUrl The root url for scene and resources
  11634. * @param onProgress The callback when the load progresses
  11635. * @returns Nothing
  11636. */
  11637. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  11638. /**
  11639. * The callback that returns true if the data can be directly loaded.
  11640. */
  11641. canDirectLoad?: (data: string) => boolean;
  11642. /**
  11643. * The callback that allows custom handling of the root url based on the response url.
  11644. */
  11645. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  11646. /**
  11647. * Load into an asset container.
  11648. * @param scene The scene to load into
  11649. * @param data The data to import
  11650. * @param rootUrl The root url for scene and resources
  11651. * @param onProgress The callback when the load progresses
  11652. * @returns The loaded asset container
  11653. */
  11654. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  11655. }
  11656. class SceneLoader {
  11657. private static _ForceFullSceneLoadingForIncremental;
  11658. private static _ShowLoadingScreen;
  11659. private static _CleanBoneMatrixWeights;
  11660. static readonly NO_LOGGING: number;
  11661. static readonly MINIMAL_LOGGING: number;
  11662. static readonly SUMMARY_LOGGING: number;
  11663. static readonly DETAILED_LOGGING: number;
  11664. private static _loggingLevel;
  11665. static ForceFullSceneLoadingForIncremental: boolean;
  11666. static ShowLoadingScreen: boolean;
  11667. static loggingLevel: number;
  11668. static CleanBoneMatrixWeights: boolean;
  11669. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  11670. private static _registeredPlugins;
  11671. private static _getDefaultPlugin();
  11672. private static _getPluginForExtension(extension);
  11673. private static _getPluginForDirectLoad(data);
  11674. private static _getPluginForFilename(sceneFilename);
  11675. private static _getDirectLoad(sceneFilename);
  11676. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  11677. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  11678. static IsPluginForExtensionAvailable(extension: string): boolean;
  11679. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  11680. /**
  11681. * Import meshes into a scene
  11682. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11683. * @param rootUrl a string that defines the root url for scene and resources
  11684. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11685. * @param scene the instance of BABYLON.Scene to append to
  11686. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  11687. * @param onProgress a callback with a progress event for each file being loaded
  11688. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11689. * @param pluginExtension the extension used to determine the plugin
  11690. * @returns The loaded plugin
  11691. */
  11692. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  11693. /**
  11694. * Import meshes into a scene
  11695. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11696. * @param rootUrl a string that defines the root url for scene and resources
  11697. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11698. * @param scene the instance of BABYLON.Scene to append to
  11699. * @param onProgress a callback with a progress event for each file being loaded
  11700. * @param pluginExtension the extension used to determine the plugin
  11701. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  11702. */
  11703. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  11704. meshes: AbstractMesh[];
  11705. particleSystems: ParticleSystem[];
  11706. skeletons: Skeleton[];
  11707. animationGroups: AnimationGroup[];
  11708. }>;
  11709. /**
  11710. * Load a scene
  11711. * @param rootUrl a string that defines the root url for scene and resources
  11712. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11713. * @param engine is the instance of BABYLON.Engine to use to create the scene
  11714. * @param onSuccess a callback with the scene when import succeeds
  11715. * @param onProgress a callback with a progress event for each file being loaded
  11716. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11717. * @param pluginExtension the extension used to determine the plugin
  11718. * @returns The loaded plugin
  11719. */
  11720. 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>;
  11721. /**
  11722. * Load a scene
  11723. * @param rootUrl a string that defines the root url for scene and resources
  11724. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11725. * @param engine is the instance of BABYLON.Engine to use to create the scene
  11726. * @param onProgress a callback with a progress event for each file being loaded
  11727. * @param pluginExtension the extension used to determine the plugin
  11728. * @returns The loaded scene
  11729. */
  11730. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  11731. /**
  11732. * Append a scene
  11733. * @param rootUrl a string that defines the root url for scene and resources
  11734. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11735. * @param scene is the instance of BABYLON.Scene to append to
  11736. * @param onSuccess a callback with the scene when import succeeds
  11737. * @param onProgress a callback with a progress event for each file being loaded
  11738. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11739. * @param pluginExtension the extension used to determine the plugin
  11740. * @returns The loaded plugin
  11741. */
  11742. static Append(rootUrl: string, sceneFilename: any, scene: 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>;
  11743. /**
  11744. * Append a scene
  11745. * @param rootUrl a string that defines the root url for scene and resources
  11746. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11747. * @param scene is the instance of BABYLON.Scene to append to
  11748. * @param onProgress a callback with a progress event for each file being loaded
  11749. * @param pluginExtension the extension used to determine the plugin
  11750. * @returns The given scene
  11751. */
  11752. static AppendAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  11753. /**
  11754. * Load a scene into an asset container
  11755. * @param rootUrl a string that defines the root url for scene and resources
  11756. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11757. * @param scene is the instance of BABYLON.Scene to append to
  11758. * @param onSuccess a callback with the scene when import succeeds
  11759. * @param onProgress a callback with a progress event for each file being loaded
  11760. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  11761. * @param pluginExtension the extension used to determine the plugin
  11762. * @returns The loaded plugin
  11763. */
  11764. static LoadAssetContainer(rootUrl: string, sceneFilename: any, scene: 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>;
  11765. /**
  11766. * Load a scene into an asset container
  11767. * @param rootUrl a string that defines the root url for scene and resources
  11768. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  11769. * @param scene is the instance of BABYLON.Scene to append to
  11770. * @param onProgress a callback with a progress event for each file being loaded
  11771. * @param pluginExtension the extension used to determine the plugin
  11772. * @returns The loaded asset container
  11773. */
  11774. static LoadAssetContainerAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  11775. }
  11776. }
  11777. declare module BABYLON {
  11778. /**
  11779. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11780. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11781. * 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;
  11782. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11783. */
  11784. class ColorCurves {
  11785. private _dirty;
  11786. private _tempColor;
  11787. private _globalCurve;
  11788. private _highlightsCurve;
  11789. private _midtonesCurve;
  11790. private _shadowsCurve;
  11791. private _positiveCurve;
  11792. private _negativeCurve;
  11793. private _globalHue;
  11794. private _globalDensity;
  11795. private _globalSaturation;
  11796. private _globalExposure;
  11797. /**
  11798. * Gets the global Hue value.
  11799. * 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).
  11800. */
  11801. /**
  11802. * Sets the global Hue value.
  11803. * 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).
  11804. */
  11805. globalHue: number;
  11806. /**
  11807. * Gets the global Density value.
  11808. * 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.
  11809. * Values less than zero provide a filter of opposite hue.
  11810. */
  11811. /**
  11812. * Sets the global Density value.
  11813. * 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.
  11814. * Values less than zero provide a filter of opposite hue.
  11815. */
  11816. globalDensity: number;
  11817. /**
  11818. * Gets the global Saturation value.
  11819. * 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.
  11820. */
  11821. /**
  11822. * Sets the global Saturation value.
  11823. * 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.
  11824. */
  11825. globalSaturation: number;
  11826. private _highlightsHue;
  11827. private _highlightsDensity;
  11828. private _highlightsSaturation;
  11829. private _highlightsExposure;
  11830. /**
  11831. * Gets the highlights Hue value.
  11832. * 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).
  11833. */
  11834. /**
  11835. * Sets the highlights Hue value.
  11836. * 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).
  11837. */
  11838. highlightsHue: number;
  11839. /**
  11840. * Gets the highlights Density value.
  11841. * 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.
  11842. * Values less than zero provide a filter of opposite hue.
  11843. */
  11844. /**
  11845. * Sets the highlights Density value.
  11846. * 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.
  11847. * Values less than zero provide a filter of opposite hue.
  11848. */
  11849. highlightsDensity: number;
  11850. /**
  11851. * Gets the highlights Saturation value.
  11852. * 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.
  11853. */
  11854. /**
  11855. * Sets the highlights Saturation value.
  11856. * 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.
  11857. */
  11858. highlightsSaturation: number;
  11859. /**
  11860. * Gets the highlights Exposure value.
  11861. * 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.
  11862. */
  11863. /**
  11864. * Sets the highlights Exposure value.
  11865. * 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.
  11866. */
  11867. highlightsExposure: number;
  11868. private _midtonesHue;
  11869. private _midtonesDensity;
  11870. private _midtonesSaturation;
  11871. private _midtonesExposure;
  11872. /**
  11873. * Gets the midtones Hue value.
  11874. * 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).
  11875. */
  11876. /**
  11877. * Sets the midtones Hue value.
  11878. * 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).
  11879. */
  11880. midtonesHue: number;
  11881. /**
  11882. * Gets the midtones Density value.
  11883. * 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.
  11884. * Values less than zero provide a filter of opposite hue.
  11885. */
  11886. /**
  11887. * Sets the midtones Density value.
  11888. * 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.
  11889. * Values less than zero provide a filter of opposite hue.
  11890. */
  11891. midtonesDensity: number;
  11892. /**
  11893. * Gets the midtones Saturation value.
  11894. * 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.
  11895. */
  11896. /**
  11897. * Sets the midtones Saturation value.
  11898. * 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.
  11899. */
  11900. midtonesSaturation: number;
  11901. /**
  11902. * Gets the midtones Exposure value.
  11903. * 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.
  11904. */
  11905. /**
  11906. * Sets the midtones Exposure value.
  11907. * 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.
  11908. */
  11909. midtonesExposure: number;
  11910. private _shadowsHue;
  11911. private _shadowsDensity;
  11912. private _shadowsSaturation;
  11913. private _shadowsExposure;
  11914. /**
  11915. * Gets the shadows Hue value.
  11916. * 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).
  11917. */
  11918. /**
  11919. * Sets the shadows Hue value.
  11920. * 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).
  11921. */
  11922. shadowsHue: number;
  11923. /**
  11924. * Gets the shadows Density value.
  11925. * 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.
  11926. * Values less than zero provide a filter of opposite hue.
  11927. */
  11928. /**
  11929. * Sets the shadows Density value.
  11930. * 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.
  11931. * Values less than zero provide a filter of opposite hue.
  11932. */
  11933. shadowsDensity: number;
  11934. /**
  11935. * Gets the shadows Saturation value.
  11936. * 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.
  11937. */
  11938. /**
  11939. * Sets the shadows Saturation value.
  11940. * 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.
  11941. */
  11942. shadowsSaturation: number;
  11943. /**
  11944. * Gets the shadows Exposure value.
  11945. * 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.
  11946. */
  11947. /**
  11948. * Sets the shadows Exposure value.
  11949. * 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.
  11950. */
  11951. shadowsExposure: number;
  11952. getClassName(): string;
  11953. /**
  11954. * Binds the color curves to the shader.
  11955. * @param colorCurves The color curve to bind
  11956. * @param effect The effect to bind to
  11957. */
  11958. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11959. /**
  11960. * Prepare the list of uniforms associated with the ColorCurves effects.
  11961. * @param uniformsList The list of uniforms used in the effect
  11962. */
  11963. static PrepareUniforms(uniformsList: string[]): void;
  11964. /**
  11965. * Returns color grading data based on a hue, density, saturation and exposure value.
  11966. * @param filterHue The hue of the color filter.
  11967. * @param filterDensity The density of the color filter.
  11968. * @param saturation The saturation.
  11969. * @param exposure The exposure.
  11970. * @param result The result data container.
  11971. */
  11972. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  11973. /**
  11974. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11975. * @param value The input slider value in range [-100,100].
  11976. * @returns Adjusted value.
  11977. */
  11978. private static applyColorGradingSliderNonlinear(value);
  11979. /**
  11980. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11981. * @param hue The hue (H) input.
  11982. * @param saturation The saturation (S) input.
  11983. * @param brightness The brightness (B) input.
  11984. * @result An RGBA color represented as Vector4.
  11985. */
  11986. private static fromHSBToRef(hue, saturation, brightness, result);
  11987. /**
  11988. * Returns a value clamped between min and max
  11989. * @param value The value to clamp
  11990. * @param min The minimum of value
  11991. * @param max The maximum of value
  11992. * @returns The clamped value.
  11993. */
  11994. private static clamp(value, min, max);
  11995. /**
  11996. * Clones the current color curve instance.
  11997. * @return The cloned curves
  11998. */
  11999. clone(): ColorCurves;
  12000. /**
  12001. * Serializes the current color curve instance to a json representation.
  12002. * @return a JSON representation
  12003. */
  12004. serialize(): any;
  12005. /**
  12006. * Parses the color curve from a json representation.
  12007. * @param source the JSON source to parse
  12008. * @return The parsed curves
  12009. */
  12010. static Parse(source: any): ColorCurves;
  12011. }
  12012. }
  12013. declare module BABYLON {
  12014. /**
  12015. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  12016. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  12017. */
  12018. class EffectFallbacks {
  12019. private _defines;
  12020. private _currentRank;
  12021. private _maxRank;
  12022. private _mesh;
  12023. /**
  12024. * Removes the fallback from the bound mesh.
  12025. */
  12026. unBindMesh(): void;
  12027. /**
  12028. * Adds a fallback on the specified property.
  12029. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12030. * @param define The name of the define in the shader
  12031. */
  12032. addFallback(rank: number, define: string): void;
  12033. /**
  12034. * Sets the mesh to use CPU skinning when needing to fallback.
  12035. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12036. * @param mesh The mesh to use the fallbacks.
  12037. */
  12038. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  12039. /**
  12040. * Checks to see if more fallbacks are still availible.
  12041. */
  12042. readonly isMoreFallbacks: boolean;
  12043. /**
  12044. * Removes the defines that shoould be removed when falling back.
  12045. * @param currentDefines defines the current define statements for the shader.
  12046. * @param effect defines the current effect we try to compile
  12047. * @returns The resulting defines with defines of the current rank removed.
  12048. */
  12049. reduce(currentDefines: string, effect: Effect): string;
  12050. }
  12051. /**
  12052. * Options to be used when creating an effect.
  12053. */
  12054. class EffectCreationOptions {
  12055. /**
  12056. * Atrributes that will be used in the shader.
  12057. */
  12058. attributes: string[];
  12059. /**
  12060. * Uniform varible names that will be set in the shader.
  12061. */
  12062. uniformsNames: string[];
  12063. /**
  12064. * Uniform buffer varible names that will be set in the shader.
  12065. */
  12066. uniformBuffersNames: string[];
  12067. /**
  12068. * Sampler texture variable names that will be set in the shader.
  12069. */
  12070. samplers: string[];
  12071. /**
  12072. * Define statements that will be set in the shader.
  12073. */
  12074. defines: any;
  12075. /**
  12076. * Possible fallbacks for this effect to improve performance when needed.
  12077. */
  12078. fallbacks: Nullable<EffectFallbacks>;
  12079. /**
  12080. * Callback that will be called when the shader is compiled.
  12081. */
  12082. onCompiled: Nullable<(effect: Effect) => void>;
  12083. /**
  12084. * Callback that will be called if an error occurs during shader compilation.
  12085. */
  12086. onError: Nullable<(effect: Effect, errors: string) => void>;
  12087. /**
  12088. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  12089. */
  12090. indexParameters: any;
  12091. /**
  12092. * Max number of lights that can be used in the shader.
  12093. */
  12094. maxSimultaneousLights: number;
  12095. /**
  12096. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  12097. */
  12098. transformFeedbackVaryings: Nullable<string[]>;
  12099. }
  12100. /**
  12101. * Effect containing vertex and fragment shader that can be executed on an object.
  12102. */
  12103. class Effect {
  12104. /**
  12105. * Name of the effect.
  12106. */
  12107. name: any;
  12108. /**
  12109. * String container all the define statements that should be set on the shader.
  12110. */
  12111. defines: string;
  12112. /**
  12113. * Callback that will be called when the shader is compiled.
  12114. */
  12115. onCompiled: Nullable<(effect: Effect) => void>;
  12116. /**
  12117. * Callback that will be called if an error occurs during shader compilation.
  12118. */
  12119. onError: Nullable<(effect: Effect, errors: string) => void>;
  12120. /**
  12121. * Callback that will be called when effect is bound.
  12122. */
  12123. onBind: Nullable<(effect: Effect) => void>;
  12124. /**
  12125. * Unique ID of the effect.
  12126. */
  12127. uniqueId: number;
  12128. /**
  12129. * Observable that will be called when the shader is compiled.
  12130. */
  12131. onCompileObservable: Observable<Effect>;
  12132. /**
  12133. * Observable that will be called if an error occurs during shader compilation.
  12134. */
  12135. onErrorObservable: Observable<Effect>;
  12136. /**
  12137. * Observable that will be called when effect is bound.
  12138. */
  12139. onBindObservable: Observable<Effect>;
  12140. /** @hidden */
  12141. _bonesComputationForcedToCPU: boolean;
  12142. private static _uniqueIdSeed;
  12143. private _engine;
  12144. private _uniformBuffersNames;
  12145. private _uniformsNames;
  12146. private _samplers;
  12147. private _isReady;
  12148. private _compilationError;
  12149. private _attributesNames;
  12150. private _attributes;
  12151. private _uniforms;
  12152. /**
  12153. * Key for the effect.
  12154. */
  12155. _key: string;
  12156. private _indexParameters;
  12157. private _fallbacks;
  12158. private _vertexSourceCode;
  12159. private _fragmentSourceCode;
  12160. private _vertexSourceCodeOverride;
  12161. private _fragmentSourceCodeOverride;
  12162. private _transformFeedbackVaryings;
  12163. /**
  12164. * Compiled shader to webGL program.
  12165. */
  12166. _program: WebGLProgram;
  12167. private _valueCache;
  12168. private static _baseCache;
  12169. /**
  12170. * Instantiates an effect.
  12171. * An effect can be used to create/manage/execute vertex and fragment shaders.
  12172. * @param baseName Name of the effect.
  12173. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  12174. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  12175. * @param samplers List of sampler variables that will be passed to the shader.
  12176. * @param engine Engine to be used to render the effect
  12177. * @param defines Define statements to be added to the shader.
  12178. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  12179. * @param onCompiled Callback that will be called when the shader is compiled.
  12180. * @param onError Callback that will be called if an error occurs during shader compilation.
  12181. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  12182. */
  12183. 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);
  12184. /**
  12185. * Unique key for this effect
  12186. */
  12187. readonly key: string;
  12188. /**
  12189. * If the effect has been compiled and prepared.
  12190. * @returns if the effect is compiled and prepared.
  12191. */
  12192. isReady(): boolean;
  12193. /**
  12194. * The engine the effect was initialized with.
  12195. * @returns the engine.
  12196. */
  12197. getEngine(): Engine;
  12198. /**
  12199. * The compiled webGL program for the effect
  12200. * @returns the webGL program.
  12201. */
  12202. getProgram(): WebGLProgram;
  12203. /**
  12204. * The set of names of attribute variables for the shader.
  12205. * @returns An array of attribute names.
  12206. */
  12207. getAttributesNames(): string[];
  12208. /**
  12209. * Returns the attribute at the given index.
  12210. * @param index The index of the attribute.
  12211. * @returns The location of the attribute.
  12212. */
  12213. getAttributeLocation(index: number): number;
  12214. /**
  12215. * Returns the attribute based on the name of the variable.
  12216. * @param name of the attribute to look up.
  12217. * @returns the attribute location.
  12218. */
  12219. getAttributeLocationByName(name: string): number;
  12220. /**
  12221. * The number of attributes.
  12222. * @returns the numnber of attributes.
  12223. */
  12224. getAttributesCount(): number;
  12225. /**
  12226. * Gets the index of a uniform variable.
  12227. * @param uniformName of the uniform to look up.
  12228. * @returns the index.
  12229. */
  12230. getUniformIndex(uniformName: string): number;
  12231. /**
  12232. * Returns the attribute based on the name of the variable.
  12233. * @param uniformName of the uniform to look up.
  12234. * @returns the location of the uniform.
  12235. */
  12236. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  12237. /**
  12238. * Returns an array of sampler variable names
  12239. * @returns The array of sampler variable neames.
  12240. */
  12241. getSamplers(): string[];
  12242. /**
  12243. * The error from the last compilation.
  12244. * @returns the error string.
  12245. */
  12246. getCompilationError(): string;
  12247. /**
  12248. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  12249. * @param func The callback to be used.
  12250. */
  12251. executeWhenCompiled(func: (effect: Effect) => void): void;
  12252. /** @hidden */
  12253. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  12254. /** @hidden */
  12255. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  12256. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  12257. private _processShaderConversion(sourceCode, isFragment, callback);
  12258. private _processIncludes(sourceCode, callback);
  12259. private _processPrecision(source);
  12260. /**
  12261. * Recompiles the webGL program
  12262. * @param vertexSourceCode The source code for the vertex shader.
  12263. * @param fragmentSourceCode The source code for the fragment shader.
  12264. * @param onCompiled Callback called when completed.
  12265. * @param onError Callback called on error.
  12266. */
  12267. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  12268. /**
  12269. * Gets the uniform locations of the the specified variable names
  12270. * @param names THe names of the variables to lookup.
  12271. * @returns Array of locations in the same order as variable names.
  12272. */
  12273. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  12274. /**
  12275. * Prepares the effect
  12276. */
  12277. _prepareEffect(): void;
  12278. /**
  12279. * Checks if the effect is supported. (Must be called after compilation)
  12280. */
  12281. readonly isSupported: boolean;
  12282. /**
  12283. * Binds a texture to the engine to be used as output of the shader.
  12284. * @param channel Name of the output variable.
  12285. * @param texture Texture to bind.
  12286. */
  12287. _bindTexture(channel: string, texture: InternalTexture): void;
  12288. /**
  12289. * Sets a texture on the engine to be used in the shader.
  12290. * @param channel Name of the sampler variable.
  12291. * @param texture Texture to set.
  12292. */
  12293. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  12294. /**
  12295. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  12296. * @param channel Name of the sampler variable.
  12297. * @param texture Texture to set.
  12298. */
  12299. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  12300. /**
  12301. * Sets an array of textures on the engine to be used in the shader.
  12302. * @param channel Name of the variable.
  12303. * @param textures Textures to set.
  12304. */
  12305. setTextureArray(channel: string, textures: BaseTexture[]): void;
  12306. /**
  12307. * 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)
  12308. * @param channel Name of the sampler variable.
  12309. * @param postProcess Post process to get the input texture from.
  12310. */
  12311. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  12312. /**
  12313. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  12314. * 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)
  12315. * @param channel Name of the sampler variable.
  12316. * @param postProcess Post process to get the output texture from.
  12317. */
  12318. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  12319. /** @hidden */
  12320. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  12321. /** @hidden */
  12322. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  12323. /** @hidden */
  12324. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  12325. /** @hidden */
  12326. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  12327. /**
  12328. * Binds a buffer to a uniform.
  12329. * @param buffer Buffer to bind.
  12330. * @param name Name of the uniform variable to bind to.
  12331. */
  12332. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  12333. /**
  12334. * Binds block to a uniform.
  12335. * @param blockName Name of the block to bind.
  12336. * @param index Index to bind.
  12337. */
  12338. bindUniformBlock(blockName: string, index: number): void;
  12339. /**
  12340. * Sets an interger value on a uniform variable.
  12341. * @param uniformName Name of the variable.
  12342. * @param value Value to be set.
  12343. * @returns this effect.
  12344. */
  12345. setInt(uniformName: string, value: number): Effect;
  12346. /**
  12347. * Sets an int array on a uniform variable.
  12348. * @param uniformName Name of the variable.
  12349. * @param array array to be set.
  12350. * @returns this effect.
  12351. */
  12352. setIntArray(uniformName: string, array: Int32Array): Effect;
  12353. /**
  12354. * 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)
  12355. * @param uniformName Name of the variable.
  12356. * @param array array to be set.
  12357. * @returns this effect.
  12358. */
  12359. setIntArray2(uniformName: string, array: Int32Array): Effect;
  12360. /**
  12361. * 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)
  12362. * @param uniformName Name of the variable.
  12363. * @param array array to be set.
  12364. * @returns this effect.
  12365. */
  12366. setIntArray3(uniformName: string, array: Int32Array): Effect;
  12367. /**
  12368. * 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)
  12369. * @param uniformName Name of the variable.
  12370. * @param array array to be set.
  12371. * @returns this effect.
  12372. */
  12373. setIntArray4(uniformName: string, array: Int32Array): Effect;
  12374. /**
  12375. * Sets an float array on a uniform variable.
  12376. * @param uniformName Name of the variable.
  12377. * @param array array to be set.
  12378. * @returns this effect.
  12379. */
  12380. setFloatArray(uniformName: string, array: Float32Array): Effect;
  12381. /**
  12382. * 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)
  12383. * @param uniformName Name of the variable.
  12384. * @param array array to be set.
  12385. * @returns this effect.
  12386. */
  12387. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  12388. /**
  12389. * 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)
  12390. * @param uniformName Name of the variable.
  12391. * @param array array to be set.
  12392. * @returns this effect.
  12393. */
  12394. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  12395. /**
  12396. * 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)
  12397. * @param uniformName Name of the variable.
  12398. * @param array array to be set.
  12399. * @returns this effect.
  12400. */
  12401. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  12402. /**
  12403. * Sets an array on a uniform variable.
  12404. * @param uniformName Name of the variable.
  12405. * @param array array to be set.
  12406. * @returns this effect.
  12407. */
  12408. setArray(uniformName: string, array: number[]): Effect;
  12409. /**
  12410. * 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)
  12411. * @param uniformName Name of the variable.
  12412. * @param array array to be set.
  12413. * @returns this effect.
  12414. */
  12415. setArray2(uniformName: string, array: number[]): Effect;
  12416. /**
  12417. * 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)
  12418. * @param uniformName Name of the variable.
  12419. * @param array array to be set.
  12420. * @returns this effect.
  12421. */
  12422. setArray3(uniformName: string, array: number[]): Effect;
  12423. /**
  12424. * 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)
  12425. * @param uniformName Name of the variable.
  12426. * @param array array to be set.
  12427. * @returns this effect.
  12428. */
  12429. setArray4(uniformName: string, array: number[]): Effect;
  12430. /**
  12431. * Sets matrices on a uniform variable.
  12432. * @param uniformName Name of the variable.
  12433. * @param matrices matrices to be set.
  12434. * @returns this effect.
  12435. */
  12436. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  12437. /**
  12438. * Sets matrix on a uniform variable.
  12439. * @param uniformName Name of the variable.
  12440. * @param matrix matrix to be set.
  12441. * @returns this effect.
  12442. */
  12443. setMatrix(uniformName: string, matrix: Matrix): Effect;
  12444. /**
  12445. * 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)
  12446. * @param uniformName Name of the variable.
  12447. * @param matrix matrix to be set.
  12448. * @returns this effect.
  12449. */
  12450. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  12451. /**
  12452. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  12453. * @param uniformName Name of the variable.
  12454. * @param matrix matrix to be set.
  12455. * @returns this effect.
  12456. */
  12457. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  12458. /**
  12459. * Sets a float on a uniform variable.
  12460. * @param uniformName Name of the variable.
  12461. * @param value value to be set.
  12462. * @returns this effect.
  12463. */
  12464. setFloat(uniformName: string, value: number): Effect;
  12465. /**
  12466. * Sets a boolean on a uniform variable.
  12467. * @param uniformName Name of the variable.
  12468. * @param bool value to be set.
  12469. * @returns this effect.
  12470. */
  12471. setBool(uniformName: string, bool: boolean): Effect;
  12472. /**
  12473. * Sets a Vector2 on a uniform variable.
  12474. * @param uniformName Name of the variable.
  12475. * @param vector2 vector2 to be set.
  12476. * @returns this effect.
  12477. */
  12478. setVector2(uniformName: string, vector2: Vector2): Effect;
  12479. /**
  12480. * Sets a float2 on a uniform variable.
  12481. * @param uniformName Name of the variable.
  12482. * @param x First float in float2.
  12483. * @param y Second float in float2.
  12484. * @returns this effect.
  12485. */
  12486. setFloat2(uniformName: string, x: number, y: number): Effect;
  12487. /**
  12488. * Sets a Vector3 on a uniform variable.
  12489. * @param uniformName Name of the variable.
  12490. * @param vector3 Value to be set.
  12491. * @returns this effect.
  12492. */
  12493. setVector3(uniformName: string, vector3: Vector3): Effect;
  12494. /**
  12495. * Sets a float3 on a uniform variable.
  12496. * @param uniformName Name of the variable.
  12497. * @param x First float in float3.
  12498. * @param y Second float in float3.
  12499. * @param z Third float in float3.
  12500. * @returns this effect.
  12501. */
  12502. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  12503. /**
  12504. * Sets a Vector4 on a uniform variable.
  12505. * @param uniformName Name of the variable.
  12506. * @param vector4 Value to be set.
  12507. * @returns this effect.
  12508. */
  12509. setVector4(uniformName: string, vector4: Vector4): Effect;
  12510. /**
  12511. * Sets a float4 on a uniform variable.
  12512. * @param uniformName Name of the variable.
  12513. * @param x First float in float4.
  12514. * @param y Second float in float4.
  12515. * @param z Third float in float4.
  12516. * @param w Fourth float in float4.
  12517. * @returns this effect.
  12518. */
  12519. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  12520. /**
  12521. * Sets a Color3 on a uniform variable.
  12522. * @param uniformName Name of the variable.
  12523. * @param color3 Value to be set.
  12524. * @returns this effect.
  12525. */
  12526. setColor3(uniformName: string, color3: Color3): Effect;
  12527. /**
  12528. * Sets a Color4 on a uniform variable.
  12529. * @param uniformName Name of the variable.
  12530. * @param color3 Value to be set.
  12531. * @param alpha Alpha value to be set.
  12532. * @returns this effect.
  12533. */
  12534. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  12535. /**
  12536. * Sets a Color4 on a uniform variable
  12537. * @param uniformName defines the name of the variable
  12538. * @param color4 defines the value to be set
  12539. * @returns this effect.
  12540. */
  12541. setDirectColor4(uniformName: string, color4: Color4): Effect;
  12542. /**
  12543. * Store of each shader (The can be looked up using effect.key)
  12544. */
  12545. static ShadersStore: {
  12546. [key: string]: string;
  12547. };
  12548. /**
  12549. * Store of each included file for a shader (The can be looked up using effect.key)
  12550. */
  12551. static IncludesShadersStore: {
  12552. [key: string]: string;
  12553. };
  12554. /**
  12555. * Resets the cache of effects.
  12556. */
  12557. static ResetCache(): void;
  12558. }
  12559. }
  12560. declare module BABYLON {
  12561. class FresnelParameters {
  12562. private _isEnabled;
  12563. isEnabled: boolean;
  12564. leftColor: Color3;
  12565. rightColor: Color3;
  12566. bias: number;
  12567. power: number;
  12568. clone(): FresnelParameters;
  12569. serialize(): any;
  12570. static Parse(parsedFresnelParameters: any): FresnelParameters;
  12571. }
  12572. }
  12573. declare module BABYLON {
  12574. /**
  12575. * Interface to follow in your material defines to integrate easily the
  12576. * Image proccessing functions.
  12577. * @hidden
  12578. */
  12579. interface IImageProcessingConfigurationDefines {
  12580. IMAGEPROCESSING: boolean;
  12581. VIGNETTE: boolean;
  12582. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12583. VIGNETTEBLENDMODEOPAQUE: boolean;
  12584. TONEMAPPING: boolean;
  12585. CONTRAST: boolean;
  12586. EXPOSURE: boolean;
  12587. COLORCURVES: boolean;
  12588. COLORGRADING: boolean;
  12589. COLORGRADING3D: boolean;
  12590. SAMPLER3DGREENDEPTH: boolean;
  12591. SAMPLER3DBGRMAP: boolean;
  12592. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12593. }
  12594. /**
  12595. * This groups together the common properties used for image processing either in direct forward pass
  12596. * or through post processing effect depending on the use of the image processing pipeline in your scene
  12597. * or not.
  12598. */
  12599. class ImageProcessingConfiguration {
  12600. /**
  12601. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  12602. */
  12603. colorCurves: Nullable<ColorCurves>;
  12604. private _colorCurvesEnabled;
  12605. /**
  12606. * Gets wether the color curves effect is enabled.
  12607. */
  12608. /**
  12609. * Sets wether the color curves effect is enabled.
  12610. */
  12611. colorCurvesEnabled: boolean;
  12612. /**
  12613. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12614. */
  12615. colorGradingTexture: Nullable<BaseTexture>;
  12616. private _colorGradingEnabled;
  12617. /**
  12618. * Gets wether the color grading effect is enabled.
  12619. */
  12620. /**
  12621. * Sets wether the color grading effect is enabled.
  12622. */
  12623. colorGradingEnabled: boolean;
  12624. private _colorGradingWithGreenDepth;
  12625. /**
  12626. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  12627. */
  12628. /**
  12629. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  12630. */
  12631. colorGradingWithGreenDepth: boolean;
  12632. private _colorGradingBGR;
  12633. /**
  12634. * Gets wether the color grading texture contains BGR values.
  12635. */
  12636. /**
  12637. * Sets wether the color grading texture contains BGR values.
  12638. */
  12639. colorGradingBGR: boolean;
  12640. _exposure: number;
  12641. /**
  12642. * Gets the Exposure used in the effect.
  12643. */
  12644. /**
  12645. * Sets the Exposure used in the effect.
  12646. */
  12647. exposure: number;
  12648. private _toneMappingEnabled;
  12649. /**
  12650. * Gets wether the tone mapping effect is enabled.
  12651. */
  12652. /**
  12653. * Sets wether the tone mapping effect is enabled.
  12654. */
  12655. toneMappingEnabled: boolean;
  12656. protected _contrast: number;
  12657. /**
  12658. * Gets the contrast used in the effect.
  12659. */
  12660. /**
  12661. * Sets the contrast used in the effect.
  12662. */
  12663. contrast: number;
  12664. /**
  12665. * Vignette stretch size.
  12666. */
  12667. vignetteStretch: number;
  12668. /**
  12669. * Vignette centre X Offset.
  12670. */
  12671. vignetteCentreX: number;
  12672. /**
  12673. * Vignette centre Y Offset.
  12674. */
  12675. vignetteCentreY: number;
  12676. /**
  12677. * Vignette weight or intensity of the vignette effect.
  12678. */
  12679. vignetteWeight: number;
  12680. /**
  12681. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12682. * if vignetteEnabled is set to true.
  12683. */
  12684. vignetteColor: Color4;
  12685. /**
  12686. * Camera field of view used by the Vignette effect.
  12687. */
  12688. vignetteCameraFov: number;
  12689. private _vignetteBlendMode;
  12690. /**
  12691. * Gets the vignette blend mode allowing different kind of effect.
  12692. */
  12693. /**
  12694. * Sets the vignette blend mode allowing different kind of effect.
  12695. */
  12696. vignetteBlendMode: number;
  12697. private _vignetteEnabled;
  12698. /**
  12699. * Gets wether the vignette effect is enabled.
  12700. */
  12701. /**
  12702. * Sets wether the vignette effect is enabled.
  12703. */
  12704. vignetteEnabled: boolean;
  12705. private _applyByPostProcess;
  12706. /**
  12707. * Gets wether the image processing is applied through a post process or not.
  12708. */
  12709. /**
  12710. * Sets wether the image processing is applied through a post process or not.
  12711. */
  12712. applyByPostProcess: boolean;
  12713. private _isEnabled;
  12714. /**
  12715. * Gets wether the image processing is enabled or not.
  12716. */
  12717. /**
  12718. * Sets wether the image processing is enabled or not.
  12719. */
  12720. isEnabled: boolean;
  12721. /**
  12722. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12723. */
  12724. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12725. /**
  12726. * Method called each time the image processing information changes requires to recompile the effect.
  12727. */
  12728. protected _updateParameters(): void;
  12729. getClassName(): string;
  12730. /**
  12731. * Prepare the list of uniforms associated with the Image Processing effects.
  12732. * @param uniformsList The list of uniforms used in the effect
  12733. * @param defines the list of defines currently in use
  12734. */
  12735. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12736. /**
  12737. * Prepare the list of samplers associated with the Image Processing effects.
  12738. * @param uniformsList The list of uniforms used in the effect
  12739. * @param defines the list of defines currently in use
  12740. */
  12741. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12742. /**
  12743. * Prepare the list of defines associated to the shader.
  12744. * @param defines the list of defines to complete
  12745. */
  12746. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12747. /**
  12748. * Returns true if all the image processing information are ready.
  12749. */
  12750. isReady(): boolean;
  12751. /**
  12752. * Binds the image processing to the shader.
  12753. * @param effect The effect to bind to
  12754. */
  12755. bind(effect: Effect, aspectRatio?: number): void;
  12756. /**
  12757. * Clones the current image processing instance.
  12758. * @return The cloned image processing
  12759. */
  12760. clone(): ImageProcessingConfiguration;
  12761. /**
  12762. * Serializes the current image processing instance to a json representation.
  12763. * @return a JSON representation
  12764. */
  12765. serialize(): any;
  12766. /**
  12767. * Parses the image processing from a json representation.
  12768. * @param source the JSON source to parse
  12769. * @return The parsed image processing
  12770. */
  12771. static Parse(source: any): ImageProcessingConfiguration;
  12772. private static _VIGNETTEMODE_MULTIPLY;
  12773. private static _VIGNETTEMODE_OPAQUE;
  12774. /**
  12775. * Used to apply the vignette as a mix with the pixel color.
  12776. */
  12777. static readonly VIGNETTEMODE_MULTIPLY: number;
  12778. /**
  12779. * Used to apply the vignette as a replacement of the pixel color.
  12780. */
  12781. static readonly VIGNETTEMODE_OPAQUE: number;
  12782. }
  12783. }
  12784. declare module BABYLON {
  12785. /**
  12786. * Manages the defines for the Material
  12787. */
  12788. class MaterialDefines {
  12789. private _keys;
  12790. private _isDirty;
  12791. /** @hidden */
  12792. _renderId: number;
  12793. /** @hidden */
  12794. _areLightsDirty: boolean;
  12795. /** @hidden */
  12796. _areAttributesDirty: boolean;
  12797. /** @hidden */
  12798. _areTexturesDirty: boolean;
  12799. /** @hidden */
  12800. _areFresnelDirty: boolean;
  12801. /** @hidden */
  12802. _areMiscDirty: boolean;
  12803. /** @hidden */
  12804. _areImageProcessingDirty: boolean;
  12805. /** @hidden */
  12806. _normals: boolean;
  12807. /** @hidden */
  12808. _uvs: boolean;
  12809. /** @hidden */
  12810. _needNormals: boolean;
  12811. /** @hidden */
  12812. _needUVs: boolean;
  12813. /**
  12814. * Specifies if the material needs to be re-calculated
  12815. */
  12816. readonly isDirty: boolean;
  12817. /**
  12818. * Marks the material to indicate that it has been re-calculated
  12819. */
  12820. markAsProcessed(): void;
  12821. /**
  12822. * Marks the material to indicate that it needs to be re-calculated
  12823. */
  12824. markAsUnprocessed(): void;
  12825. /**
  12826. * Marks the material to indicate all of its defines need to be re-calculated
  12827. */
  12828. markAllAsDirty(): void;
  12829. /**
  12830. * Marks the material to indicate that image processing needs to be re-calculated
  12831. */
  12832. markAsImageProcessingDirty(): void;
  12833. /**
  12834. * Marks the material to indicate the lights need to be re-calculated
  12835. */
  12836. markAsLightDirty(): void;
  12837. /**
  12838. * Marks the attribute state as changed
  12839. */
  12840. markAsAttributesDirty(): void;
  12841. /**
  12842. * Marks the texture state as changed
  12843. */
  12844. markAsTexturesDirty(): void;
  12845. /**
  12846. * Marks the fresnel state as changed
  12847. */
  12848. markAsFresnelDirty(): void;
  12849. /**
  12850. * Marks the misc state as changed
  12851. */
  12852. markAsMiscDirty(): void;
  12853. /**
  12854. * Rebuilds the material defines
  12855. */
  12856. rebuild(): void;
  12857. /**
  12858. * Specifies if two material defines are equal
  12859. * @param other - A material define instance to compare to
  12860. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  12861. */
  12862. isEqual(other: MaterialDefines): boolean;
  12863. /**
  12864. * Clones this instance's defines to another instance
  12865. * @param other - material defines to clone values to
  12866. */
  12867. cloneTo(other: MaterialDefines): void;
  12868. /**
  12869. * Resets the material define values
  12870. */
  12871. reset(): void;
  12872. /**
  12873. * Converts the material define values to a string
  12874. * @returns - String of material define information
  12875. */
  12876. toString(): string;
  12877. }
  12878. /**
  12879. * Base class for the main features of a material in Babylon.js
  12880. */
  12881. class Material implements IAnimatable {
  12882. private static _TriangleFillMode;
  12883. private static _WireFrameFillMode;
  12884. private static _PointFillMode;
  12885. private static _PointListDrawMode;
  12886. private static _LineListDrawMode;
  12887. private static _LineLoopDrawMode;
  12888. private static _LineStripDrawMode;
  12889. private static _TriangleStripDrawMode;
  12890. private static _TriangleFanDrawMode;
  12891. /**
  12892. * Returns the triangle fill mode
  12893. */
  12894. static readonly TriangleFillMode: number;
  12895. /**
  12896. * Returns the wireframe mode
  12897. */
  12898. static readonly WireFrameFillMode: number;
  12899. /**
  12900. * Returns the point fill mode
  12901. */
  12902. static readonly PointFillMode: number;
  12903. /**
  12904. * Returns the point list draw mode
  12905. */
  12906. static readonly PointListDrawMode: number;
  12907. /**
  12908. * Returns the line list draw mode
  12909. */
  12910. static readonly LineListDrawMode: number;
  12911. /**
  12912. * Returns the line loop draw mode
  12913. */
  12914. static readonly LineLoopDrawMode: number;
  12915. /**
  12916. * Returns the line strip draw mode
  12917. */
  12918. static readonly LineStripDrawMode: number;
  12919. /**
  12920. * Returns the triangle strip draw mode
  12921. */
  12922. static readonly TriangleStripDrawMode: number;
  12923. /**
  12924. * Returns the triangle fan draw mode
  12925. */
  12926. static readonly TriangleFanDrawMode: number;
  12927. /**
  12928. * Stores the clock-wise side orientation
  12929. */
  12930. private static _ClockWiseSideOrientation;
  12931. /**
  12932. * Stores the counter clock-wise side orientation
  12933. */
  12934. private static _CounterClockWiseSideOrientation;
  12935. /**
  12936. * Returns the clock-wise side orientation
  12937. */
  12938. static readonly ClockWiseSideOrientation: number;
  12939. /**
  12940. * Returns the counter clock-wise side orientation
  12941. */
  12942. static readonly CounterClockWiseSideOrientation: number;
  12943. /**
  12944. * The dirty texture flag value
  12945. */
  12946. private static _TextureDirtyFlag;
  12947. /**
  12948. * The dirty light flag value
  12949. */
  12950. private static _LightDirtyFlag;
  12951. /**
  12952. * The dirty fresnel flag value
  12953. */
  12954. private static _FresnelDirtyFlag;
  12955. /**
  12956. * The dirty attribute flag value
  12957. */
  12958. private static _AttributesDirtyFlag;
  12959. /**
  12960. * The dirty misc flag value
  12961. */
  12962. private static _MiscDirtyFlag;
  12963. /**
  12964. * Returns the dirty texture flag value
  12965. */
  12966. static readonly TextureDirtyFlag: number;
  12967. /**
  12968. * Returns the dirty light flag value
  12969. */
  12970. static readonly LightDirtyFlag: number;
  12971. /**
  12972. * Returns the dirty fresnel flag value
  12973. */
  12974. static readonly FresnelDirtyFlag: number;
  12975. /**
  12976. * Returns the dirty attributes flag value
  12977. */
  12978. static readonly AttributesDirtyFlag: number;
  12979. /**
  12980. * Returns the dirty misc flag value
  12981. */
  12982. static readonly MiscDirtyFlag: number;
  12983. /**
  12984. * The ID of the material
  12985. */
  12986. id: string;
  12987. /**
  12988. * The name of the material
  12989. */
  12990. name: string;
  12991. /**
  12992. * Specifies if the ready state should be checked on each call
  12993. */
  12994. checkReadyOnEveryCall: boolean;
  12995. /**
  12996. * Specifies if the ready state should be checked once
  12997. */
  12998. checkReadyOnlyOnce: boolean;
  12999. /**
  13000. * The state of the material
  13001. */
  13002. state: string;
  13003. /**
  13004. * The alpha value of the material
  13005. */
  13006. protected _alpha: number;
  13007. /**
  13008. * Gets the alpha value of the material
  13009. */
  13010. /**
  13011. * Sets the alpha value of the material
  13012. */
  13013. alpha: number;
  13014. /**
  13015. * Specifies if back face culling is enabled
  13016. */
  13017. protected _backFaceCulling: boolean;
  13018. /**
  13019. * Gets the back-face culling state
  13020. */
  13021. /**
  13022. * Sets the back-face culling state
  13023. */
  13024. backFaceCulling: boolean;
  13025. /**
  13026. * Stores the value for side orientation
  13027. */
  13028. sideOrientation: number;
  13029. /**
  13030. * Callback triggered when the material is compiled
  13031. */
  13032. onCompiled: (effect: Effect) => void;
  13033. /**
  13034. * Callback triggered when an error occurs
  13035. */
  13036. onError: (effect: Effect, errors: string) => void;
  13037. /**
  13038. * Callback triggered to get the render target textures
  13039. */
  13040. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  13041. /**
  13042. * Specifies if the material should be serialized
  13043. */
  13044. doNotSerialize: boolean;
  13045. /**
  13046. * Specifies if the effect should be stored on sub meshes
  13047. */
  13048. storeEffectOnSubMeshes: boolean;
  13049. /**
  13050. * Stores the animations for the material
  13051. */
  13052. animations: Array<Animation>;
  13053. /**
  13054. * An event triggered when the material is disposed
  13055. */
  13056. onDisposeObservable: Observable<Material>;
  13057. /**
  13058. * An observer which watches for dispose events
  13059. */
  13060. private _onDisposeObserver;
  13061. /**
  13062. * Called during a dispose event
  13063. */
  13064. onDispose: () => void;
  13065. /**
  13066. * An event triggered when the material is bound
  13067. */
  13068. onBindObservable: Observable<AbstractMesh>;
  13069. /**
  13070. * An observer which watches for bind events
  13071. */
  13072. private _onBindObserver;
  13073. /**
  13074. * Called during a bind event
  13075. */
  13076. onBind: (Mesh: AbstractMesh) => void;
  13077. /**
  13078. * An event triggered when the material is unbound
  13079. */
  13080. onUnBindObservable: Observable<Material>;
  13081. /**
  13082. * Stores the value of the alpha mode
  13083. */
  13084. private _alphaMode;
  13085. /**
  13086. * Gets the value of the alpha mode
  13087. */
  13088. /**
  13089. * Sets the value of the alpha mode.
  13090. *
  13091. * | Value | Type | Description |
  13092. * | --- | --- | --- |
  13093. * | 0 | ALPHA_DISABLE | |
  13094. * | 1 | ALPHA_ADD | |
  13095. * | 2 | ALPHA_COMBINE | |
  13096. * | 3 | ALPHA_SUBTRACT | |
  13097. * | 4 | ALPHA_MULTIPLY | |
  13098. * | 5 | ALPHA_MAXIMIZED | |
  13099. * | 6 | ALPHA_ONEONE | |
  13100. * | 7 | ALPHA_PREMULTIPLIED | |
  13101. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  13102. * | 9 | ALPHA_INTERPOLATE | |
  13103. * | 10 | ALPHA_SCREENMODE | |
  13104. *
  13105. */
  13106. alphaMode: number;
  13107. /**
  13108. * Stores the state of the need depth pre-pass value
  13109. */
  13110. private _needDepthPrePass;
  13111. /**
  13112. * Gets the depth pre-pass value
  13113. */
  13114. /**
  13115. * Sets the need depth pre-pass value
  13116. */
  13117. needDepthPrePass: boolean;
  13118. /**
  13119. * Specifies if depth writing should be disabled
  13120. */
  13121. disableDepthWrite: boolean;
  13122. /**
  13123. * Specifies if depth writing should be forced
  13124. */
  13125. forceDepthWrite: boolean;
  13126. /**
  13127. * Specifies if there should be a separate pass for culling
  13128. */
  13129. separateCullingPass: boolean;
  13130. /**
  13131. * Stores the state specifing if fog should be enabled
  13132. */
  13133. private _fogEnabled;
  13134. /**
  13135. * Gets the value of the fog enabled state
  13136. */
  13137. /**
  13138. * Sets the state for enabling fog
  13139. */
  13140. fogEnabled: boolean;
  13141. /**
  13142. * Stores the size of points
  13143. */
  13144. pointSize: number;
  13145. /**
  13146. * Stores the z offset value
  13147. */
  13148. zOffset: number;
  13149. /**
  13150. * Gets a value specifying if wireframe mode is enabled
  13151. */
  13152. /**
  13153. * Sets the state of wireframe mode
  13154. */
  13155. wireframe: boolean;
  13156. /**
  13157. * Gets the value specifying if point clouds are enabled
  13158. */
  13159. /**
  13160. * Sets the state of point cloud mode
  13161. */
  13162. pointsCloud: boolean;
  13163. /**
  13164. * Gets the material fill mode
  13165. */
  13166. /**
  13167. * Sets the material fill mode
  13168. */
  13169. fillMode: number;
  13170. /**
  13171. * Stores the effects for the material
  13172. */
  13173. _effect: Nullable<Effect>;
  13174. /**
  13175. * Specifies if the material was previously ready
  13176. */
  13177. _wasPreviouslyReady: boolean;
  13178. /**
  13179. * Specifies if uniform buffers should be used
  13180. */
  13181. private _useUBO;
  13182. /**
  13183. * Stores a reference to the scene
  13184. */
  13185. private _scene;
  13186. /**
  13187. * Stores the fill mode state
  13188. */
  13189. private _fillMode;
  13190. /**
  13191. * Specifies if the depth write state should be cached
  13192. */
  13193. private _cachedDepthWriteState;
  13194. /**
  13195. * Stores the uniform buffer
  13196. */
  13197. protected _uniformBuffer: UniformBuffer;
  13198. /**
  13199. * Creates a material instance
  13200. * @param name defines the name of the material
  13201. * @param scene defines the scene to reference
  13202. * @param doNotAdd specifies if the material should be added to the scene
  13203. */
  13204. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  13205. /**
  13206. * Returns a string representation of the current material
  13207. * @param fullDetails defines a boolean indicating which levels of logging is desired
  13208. * @returns a string with material information
  13209. */
  13210. toString(fullDetails?: boolean): string;
  13211. /**
  13212. * Gets the class name of the material
  13213. * @returns a string with the class name of the material
  13214. */
  13215. getClassName(): string;
  13216. /**
  13217. * Specifies if updates for the material been locked
  13218. */
  13219. readonly isFrozen: boolean;
  13220. /**
  13221. * Locks updates for the material
  13222. */
  13223. freeze(): void;
  13224. /**
  13225. * Unlocks updates for the material
  13226. */
  13227. unfreeze(): void;
  13228. /**
  13229. * Specifies if the material is ready to be used
  13230. * @param mesh defines the mesh to check
  13231. * @param useInstances specifies if instances should be used
  13232. * @returns a boolean indicating if the material is ready to be used
  13233. */
  13234. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13235. /**
  13236. * Specifies that the submesh is ready to be used
  13237. * @param mesh defines the mesh to check
  13238. * @param subMesh defines which submesh to check
  13239. * @param useInstances specifies that instances should be used
  13240. * @returns a boolean indicating that the submesh is ready or not
  13241. */
  13242. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  13243. /**
  13244. * Returns the material effect
  13245. * @returns the effect associated with the material
  13246. */
  13247. getEffect(): Nullable<Effect>;
  13248. /**
  13249. * Returns the current scene
  13250. * @returns a Scene
  13251. */
  13252. getScene(): Scene;
  13253. /**
  13254. * Specifies if the material will require alpha blending
  13255. * @returns a boolean specifying if alpha blending is needed
  13256. */
  13257. needAlphaBlending(): boolean;
  13258. /**
  13259. * Specifies if the mesh will require alpha blending
  13260. * @param mesh defines the mesh to check
  13261. * @returns a boolean specifying if alpha blending is needed for the mesh
  13262. */
  13263. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  13264. /**
  13265. * Specifies if this material should be rendered in alpha test mode
  13266. * @returns a boolean specifying if an alpha test is needed.
  13267. */
  13268. needAlphaTesting(): boolean;
  13269. /**
  13270. * Gets the texture used for the alpha test
  13271. * @returns the texture to use for alpha testing
  13272. */
  13273. getAlphaTestTexture(): Nullable<BaseTexture>;
  13274. /**
  13275. * Marks the material to indicate that it needs to be re-calculated
  13276. */
  13277. markDirty(): void;
  13278. /** @hidden */
  13279. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  13280. /**
  13281. * Binds the material to the mesh
  13282. * @param world defines the world transformation matrix
  13283. * @param mesh defines the mesh to bind the material to
  13284. */
  13285. bind(world: Matrix, mesh?: Mesh): void;
  13286. /**
  13287. * Binds the submesh to the material
  13288. * @param world defines the world transformation matrix
  13289. * @param mesh defines the mesh containing the submesh
  13290. * @param subMesh defines the submesh to bind the material to
  13291. */
  13292. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  13293. /**
  13294. * Binds the world matrix to the material
  13295. * @param world defines the world transformation matrix
  13296. */
  13297. bindOnlyWorldMatrix(world: Matrix): void;
  13298. /**
  13299. * Binds the scene's uniform buffer to the effect.
  13300. * @param effect defines the effect to bind to the scene uniform buffer
  13301. * @param sceneUbo defines the uniform buffer storing scene data
  13302. */
  13303. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  13304. /**
  13305. * Binds the view matrix to the effect
  13306. * @param effect defines the effect to bind the view matrix to
  13307. */
  13308. bindView(effect: Effect): void;
  13309. /**
  13310. * Binds the view projection matrix to the effect
  13311. * @param effect defines the effect to bind the view projection matrix to
  13312. */
  13313. bindViewProjection(effect: Effect): void;
  13314. /**
  13315. * Specifies if material alpha testing should be turned on for the mesh
  13316. * @param mesh defines the mesh to check
  13317. */
  13318. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  13319. /**
  13320. * Processes to execute after binding the material to a mesh
  13321. * @param mesh defines the rendered mesh
  13322. */
  13323. protected _afterBind(mesh?: Mesh): void;
  13324. /**
  13325. * Unbinds the material from the mesh
  13326. */
  13327. unbind(): void;
  13328. /**
  13329. * Gets the active textures from the material
  13330. * @returns an array of textures
  13331. */
  13332. getActiveTextures(): BaseTexture[];
  13333. /**
  13334. * Specifies if the material uses a texture
  13335. * @param texture defines the texture to check against the material
  13336. * @returns a boolean specifying if the material uses the texture
  13337. */
  13338. hasTexture(texture: BaseTexture): boolean;
  13339. /**
  13340. * Makes a duplicate of the material, and gives it a new name
  13341. * @param name defines the new name for the duplicated material
  13342. * @returns the cloned material
  13343. */
  13344. clone(name: string): Nullable<Material>;
  13345. /**
  13346. * Gets the meshes bound to the material
  13347. * @returns an array of meshes bound to the material
  13348. */
  13349. getBindedMeshes(): AbstractMesh[];
  13350. /**
  13351. * Force shader compilation
  13352. * @param mesh defines the mesh associated with this material
  13353. * @param onCompiled defines a function to execute once the material is compiled
  13354. * @param options defines the options to configure the compilation
  13355. */
  13356. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  13357. clipPlane: boolean;
  13358. }>): void;
  13359. /**
  13360. * Force shader compilation
  13361. * @param mesh defines the mesh that will use this material
  13362. * @param options defines additional options for compiling the shaders
  13363. * @returns a promise that resolves when the compilation completes
  13364. */
  13365. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  13366. clipPlane: boolean;
  13367. }>): Promise<void>;
  13368. /**
  13369. * Marks a define in the material to indicate that it needs to be re-computed
  13370. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  13371. */
  13372. markAsDirty(flag: number): void;
  13373. /**
  13374. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  13375. * @param func defines a function which checks material defines against the submeshes
  13376. */
  13377. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  13378. /**
  13379. * Indicates that image processing needs to be re-calculated for all submeshes
  13380. */
  13381. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  13382. /**
  13383. * Indicates that textures need to be re-calculated for all submeshes
  13384. */
  13385. protected _markAllSubMeshesAsTexturesDirty(): void;
  13386. /**
  13387. * Indicates that fresnel needs to be re-calculated for all submeshes
  13388. */
  13389. protected _markAllSubMeshesAsFresnelDirty(): void;
  13390. /**
  13391. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  13392. */
  13393. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  13394. /**
  13395. * Indicates that lights need to be re-calculated for all submeshes
  13396. */
  13397. protected _markAllSubMeshesAsLightsDirty(): void;
  13398. /**
  13399. * Indicates that attributes need to be re-calculated for all submeshes
  13400. */
  13401. protected _markAllSubMeshesAsAttributesDirty(): void;
  13402. /**
  13403. * Indicates that misc needs to be re-calculated for all submeshes
  13404. */
  13405. protected _markAllSubMeshesAsMiscDirty(): void;
  13406. /**
  13407. * Indicates that textures and misc need to be re-calculated for all submeshes
  13408. */
  13409. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  13410. /**
  13411. * Disposes the material
  13412. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  13413. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  13414. */
  13415. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13416. /**
  13417. * Serializes this material
  13418. * @returns the serialized material object
  13419. */
  13420. serialize(): any;
  13421. /**
  13422. * Creates a MultiMaterial from parsed MultiMaterial data.
  13423. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  13424. * @param scene defines the hosting scene
  13425. * @returns a new MultiMaterial
  13426. */
  13427. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  13428. /**
  13429. * Creates a material from parsed material data
  13430. * @param parsedMaterial defines parsed material data
  13431. * @param scene defines the hosting scene
  13432. * @param rootUrl defines the root URL to use to load textures
  13433. * @returns a new material
  13434. */
  13435. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  13436. }
  13437. }
  13438. declare module BABYLON {
  13439. /**
  13440. * "Static Class" containing the most commonly used helper while dealing with material for
  13441. * rendering purpose.
  13442. *
  13443. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  13444. *
  13445. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  13446. */
  13447. class MaterialHelper {
  13448. /**
  13449. * Bind the current view position to an effect.
  13450. * @param effect The effect to be bound
  13451. * @param scene The scene the eyes position is used from
  13452. */
  13453. static BindEyePosition(effect: Effect, scene: Scene): void;
  13454. /**
  13455. * Helps preparing the defines values about the UVs in used in the effect.
  13456. * UVs are shared as much as we can accross chanels in the shaders.
  13457. * @param texture The texture we are preparing the UVs for
  13458. * @param defines The defines to update
  13459. * @param key The chanel key "diffuse", "specular"... used in the shader
  13460. */
  13461. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  13462. /**
  13463. * Binds a texture matrix value to its corrsponding uniform
  13464. * @param texture The texture to bind the matrix for
  13465. * @param uniformBuffer The uniform buffer receivin the data
  13466. * @param key The chanel key "diffuse", "specular"... used in the shader
  13467. */
  13468. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  13469. /**
  13470. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  13471. * @param mesh defines the current mesh
  13472. * @param scene defines the current scene
  13473. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  13474. * @param pointsCloud defines if point cloud rendering has to be turned on
  13475. * @param fogEnabled defines if fog has to be turned on
  13476. * @param alphaTest defines if alpha testing has to be turned on
  13477. * @param defines defines the current list of defines
  13478. */
  13479. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  13480. /**
  13481. * Helper used to prepare the list of defines associated with frame values for shader compilation
  13482. * @param scene defines the current scene
  13483. * @param engine defines the current engine
  13484. * @param defines specifies the list of active defines
  13485. * @param useInstances defines if instances have to be turned on
  13486. * @param useClipPlane defines if clip plane have to be turned on
  13487. */
  13488. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  13489. /**
  13490. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  13491. * @param mesh The mesh containing the geometry data we will draw
  13492. * @param defines The defines to update
  13493. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  13494. * @param useBones Precise whether bones should be used or not (override mesh info)
  13495. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  13496. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  13497. * @returns false if defines are considered not dirty and have not been checked
  13498. */
  13499. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  13500. /**
  13501. * Prepares the defines related to the light information passed in parameter
  13502. * @param scene The scene we are intending to draw
  13503. * @param mesh The mesh the effect is compiling for
  13504. * @param defines The defines to update
  13505. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  13506. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  13507. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  13508. * @returns true if normals will be required for the rest of the effect
  13509. */
  13510. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  13511. /**
  13512. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  13513. * that won t be acctive due to defines being turned off.
  13514. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  13515. * @param samplersList The samplers list
  13516. * @param defines The defines helping in the list generation
  13517. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  13518. */
  13519. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  13520. /**
  13521. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  13522. * @param defines The defines to update while falling back
  13523. * @param fallbacks The authorized effect fallbacks
  13524. * @param maxSimultaneousLights The maximum number of lights allowed
  13525. * @param rank the current rank of the Effect
  13526. * @returns The newly affected rank
  13527. */
  13528. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  13529. /**
  13530. * Prepares the list of attributes required for morph targets according to the effect defines.
  13531. * @param attribs The current list of supported attribs
  13532. * @param mesh The mesh to prepare the morph targets attributes for
  13533. * @param defines The current Defines of the effect
  13534. */
  13535. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  13536. /**
  13537. * Prepares the list of attributes required for bones according to the effect defines.
  13538. * @param attribs The current list of supported attribs
  13539. * @param mesh The mesh to prepare the bones attributes for
  13540. * @param defines The current Defines of the effect
  13541. * @param fallbacks The current efffect fallback strategy
  13542. */
  13543. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  13544. /**
  13545. * Prepares the list of attributes required for instances according to the effect defines.
  13546. * @param attribs The current list of supported attribs
  13547. * @param defines The current Defines of the effect
  13548. */
  13549. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  13550. /**
  13551. * Binds the light shadow information to the effect for the given mesh.
  13552. * @param light The light containing the generator
  13553. * @param scene The scene the lights belongs to
  13554. * @param mesh The mesh we are binding the information to render
  13555. * @param lightIndex The light index in the effect used to render the mesh
  13556. * @param effect The effect we are binding the data to
  13557. */
  13558. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  13559. /**
  13560. * Binds the light information to the effect.
  13561. * @param light The light containing the generator
  13562. * @param effect The effect we are binding the data to
  13563. * @param lightIndex The light index in the effect used to render
  13564. */
  13565. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  13566. /**
  13567. * Binds the lights information from the scene to the effect for the given mesh.
  13568. * @param scene The scene the lights belongs to
  13569. * @param mesh The mesh we are binding the information to render
  13570. * @param effect The effect we are binding the data to
  13571. * @param defines The generated defines for the effect
  13572. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  13573. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  13574. */
  13575. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  13576. /**
  13577. * Binds the fog information from the scene to the effect for the given mesh.
  13578. * @param scene The scene the lights belongs to
  13579. * @param mesh The mesh we are binding the information to render
  13580. * @param effect The effect we are binding the data to
  13581. */
  13582. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  13583. /**
  13584. * Binds the bones information from the mesh to the effect.
  13585. * @param mesh The mesh we are binding the information to render
  13586. * @param effect The effect we are binding the data to
  13587. */
  13588. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  13589. /**
  13590. * Binds the morph targets information from the mesh to the effect.
  13591. * @param abstractMesh The mesh we are binding the information to render
  13592. * @param effect The effect we are binding the data to
  13593. */
  13594. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  13595. /**
  13596. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  13597. * @param defines The generated defines used in the effect
  13598. * @param effect The effect we are binding the data to
  13599. * @param scene The scene we are willing to render with logarithmic scale for
  13600. */
  13601. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  13602. /**
  13603. * Binds the clip plane information from the scene to the effect.
  13604. * @param scene The scene the clip plane information are extracted from
  13605. * @param effect The effect we are binding the data to
  13606. */
  13607. static BindClipPlane(effect: Effect, scene: Scene): void;
  13608. }
  13609. }
  13610. declare module BABYLON {
  13611. class MultiMaterial extends Material {
  13612. private _subMaterials;
  13613. subMaterials: Nullable<Material>[];
  13614. constructor(name: string, scene: Scene);
  13615. private _hookArray(array);
  13616. getSubMaterial(index: number): Nullable<Material>;
  13617. getActiveTextures(): BaseTexture[];
  13618. getClassName(): string;
  13619. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  13620. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  13621. serialize(): any;
  13622. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13623. }
  13624. }
  13625. declare module BABYLON {
  13626. class PushMaterial extends Material {
  13627. protected _activeEffect: Effect;
  13628. protected _normalMatrix: Matrix;
  13629. constructor(name: string, scene: Scene);
  13630. getEffect(): Effect;
  13631. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13632. /**
  13633. * Binds the given world matrix to the active effect
  13634. *
  13635. * @param world the matrix to bind
  13636. */
  13637. bindOnlyWorldMatrix(world: Matrix): void;
  13638. /**
  13639. * Binds the given normal matrix to the active effect
  13640. *
  13641. * @param normalMatrix the matrix to bind
  13642. */
  13643. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13644. bind(world: Matrix, mesh?: Mesh): void;
  13645. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13646. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13647. }
  13648. }
  13649. declare module BABYLON {
  13650. class ShaderMaterial extends Material {
  13651. private _shaderPath;
  13652. private _options;
  13653. private _textures;
  13654. private _textureArrays;
  13655. private _floats;
  13656. private _ints;
  13657. private _floatsArrays;
  13658. private _colors3;
  13659. private _colors3Arrays;
  13660. private _colors4;
  13661. private _vectors2;
  13662. private _vectors3;
  13663. private _vectors4;
  13664. private _matrices;
  13665. private _matrices3x3;
  13666. private _matrices2x2;
  13667. private _vectors2Arrays;
  13668. private _vectors3Arrays;
  13669. private _cachedWorldViewMatrix;
  13670. private _renderId;
  13671. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  13672. getClassName(): string;
  13673. needAlphaBlending(): boolean;
  13674. needAlphaTesting(): boolean;
  13675. private _checkUniform(uniformName);
  13676. setTexture(name: string, texture: Texture): ShaderMaterial;
  13677. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  13678. setFloat(name: string, value: number): ShaderMaterial;
  13679. setInt(name: string, value: number): ShaderMaterial;
  13680. setFloats(name: string, value: number[]): ShaderMaterial;
  13681. setColor3(name: string, value: Color3): ShaderMaterial;
  13682. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  13683. setColor4(name: string, value: Color4): ShaderMaterial;
  13684. setVector2(name: string, value: Vector2): ShaderMaterial;
  13685. setVector3(name: string, value: Vector3): ShaderMaterial;
  13686. setVector4(name: string, value: Vector4): ShaderMaterial;
  13687. setMatrix(name: string, value: Matrix): ShaderMaterial;
  13688. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  13689. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  13690. setArray2(name: string, value: number[]): ShaderMaterial;
  13691. setArray3(name: string, value: number[]): ShaderMaterial;
  13692. private _checkCache(scene, mesh?, useInstances?);
  13693. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13694. bindOnlyWorldMatrix(world: Matrix): void;
  13695. bind(world: Matrix, mesh?: Mesh): void;
  13696. getActiveTextures(): BaseTexture[];
  13697. hasTexture(texture: BaseTexture): boolean;
  13698. clone(name: string): ShaderMaterial;
  13699. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13700. serialize(): any;
  13701. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  13702. }
  13703. }
  13704. declare module BABYLON {
  13705. /** @hidden */
  13706. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  13707. MAINUV1: boolean;
  13708. MAINUV2: boolean;
  13709. DIFFUSE: boolean;
  13710. DIFFUSEDIRECTUV: number;
  13711. AMBIENT: boolean;
  13712. AMBIENTDIRECTUV: number;
  13713. OPACITY: boolean;
  13714. OPACITYDIRECTUV: number;
  13715. OPACITYRGB: boolean;
  13716. REFLECTION: boolean;
  13717. EMISSIVE: boolean;
  13718. EMISSIVEDIRECTUV: number;
  13719. SPECULAR: boolean;
  13720. SPECULARDIRECTUV: number;
  13721. BUMP: boolean;
  13722. BUMPDIRECTUV: number;
  13723. PARALLAX: boolean;
  13724. PARALLAXOCCLUSION: boolean;
  13725. SPECULAROVERALPHA: boolean;
  13726. CLIPPLANE: boolean;
  13727. ALPHATEST: boolean;
  13728. DEPTHPREPASS: boolean;
  13729. ALPHAFROMDIFFUSE: boolean;
  13730. POINTSIZE: boolean;
  13731. FOG: boolean;
  13732. SPECULARTERM: boolean;
  13733. DIFFUSEFRESNEL: boolean;
  13734. OPACITYFRESNEL: boolean;
  13735. REFLECTIONFRESNEL: boolean;
  13736. REFRACTIONFRESNEL: boolean;
  13737. EMISSIVEFRESNEL: boolean;
  13738. FRESNEL: boolean;
  13739. NORMAL: boolean;
  13740. UV1: boolean;
  13741. UV2: boolean;
  13742. VERTEXCOLOR: boolean;
  13743. VERTEXALPHA: boolean;
  13744. NUM_BONE_INFLUENCERS: number;
  13745. BonesPerMesh: number;
  13746. INSTANCES: boolean;
  13747. GLOSSINESS: boolean;
  13748. ROUGHNESS: boolean;
  13749. EMISSIVEASILLUMINATION: boolean;
  13750. LINKEMISSIVEWITHDIFFUSE: boolean;
  13751. REFLECTIONFRESNELFROMSPECULAR: boolean;
  13752. LIGHTMAP: boolean;
  13753. LIGHTMAPDIRECTUV: number;
  13754. OBJECTSPACE_NORMALMAP: boolean;
  13755. USELIGHTMAPASSHADOWMAP: boolean;
  13756. REFLECTIONMAP_3D: boolean;
  13757. REFLECTIONMAP_SPHERICAL: boolean;
  13758. REFLECTIONMAP_PLANAR: boolean;
  13759. REFLECTIONMAP_CUBIC: boolean;
  13760. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  13761. REFLECTIONMAP_PROJECTION: boolean;
  13762. REFLECTIONMAP_SKYBOX: boolean;
  13763. REFLECTIONMAP_EXPLICIT: boolean;
  13764. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  13765. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  13766. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  13767. INVERTCUBICMAP: boolean;
  13768. LOGARITHMICDEPTH: boolean;
  13769. REFRACTION: boolean;
  13770. REFRACTIONMAP_3D: boolean;
  13771. REFLECTIONOVERALPHA: boolean;
  13772. TWOSIDEDLIGHTING: boolean;
  13773. SHADOWFLOAT: boolean;
  13774. MORPHTARGETS: boolean;
  13775. MORPHTARGETS_NORMAL: boolean;
  13776. MORPHTARGETS_TANGENT: boolean;
  13777. NUM_MORPH_INFLUENCERS: number;
  13778. NONUNIFORMSCALING: boolean;
  13779. PREMULTIPLYALPHA: boolean;
  13780. IMAGEPROCESSING: boolean;
  13781. VIGNETTE: boolean;
  13782. VIGNETTEBLENDMODEMULTIPLY: boolean;
  13783. VIGNETTEBLENDMODEOPAQUE: boolean;
  13784. TONEMAPPING: boolean;
  13785. CONTRAST: boolean;
  13786. COLORCURVES: boolean;
  13787. COLORGRADING: boolean;
  13788. COLORGRADING3D: boolean;
  13789. SAMPLER3DGREENDEPTH: boolean;
  13790. SAMPLER3DBGRMAP: boolean;
  13791. IMAGEPROCESSINGPOSTPROCESS: boolean;
  13792. /**
  13793. * If the reflection texture on this material is in linear color space
  13794. * @hidden
  13795. */
  13796. IS_REFLECTION_LINEAR: boolean;
  13797. /**
  13798. * If the refraction texture on this material is in linear color space
  13799. * @hidden
  13800. */
  13801. IS_REFRACTION_LINEAR: boolean;
  13802. EXPOSURE: boolean;
  13803. constructor();
  13804. setReflectionMode(modeToEnable: string): void;
  13805. }
  13806. class StandardMaterial extends PushMaterial {
  13807. private _diffuseTexture;
  13808. diffuseTexture: Nullable<BaseTexture>;
  13809. private _ambientTexture;
  13810. ambientTexture: Nullable<BaseTexture>;
  13811. private _opacityTexture;
  13812. opacityTexture: Nullable<BaseTexture>;
  13813. private _reflectionTexture;
  13814. reflectionTexture: Nullable<BaseTexture>;
  13815. private _emissiveTexture;
  13816. emissiveTexture: Nullable<BaseTexture>;
  13817. private _specularTexture;
  13818. specularTexture: Nullable<BaseTexture>;
  13819. private _bumpTexture;
  13820. bumpTexture: Nullable<BaseTexture>;
  13821. private _lightmapTexture;
  13822. lightmapTexture: Nullable<BaseTexture>;
  13823. private _refractionTexture;
  13824. refractionTexture: Nullable<BaseTexture>;
  13825. ambientColor: Color3;
  13826. diffuseColor: Color3;
  13827. specularColor: Color3;
  13828. emissiveColor: Color3;
  13829. specularPower: number;
  13830. private _useAlphaFromDiffuseTexture;
  13831. useAlphaFromDiffuseTexture: boolean;
  13832. private _useEmissiveAsIllumination;
  13833. useEmissiveAsIllumination: boolean;
  13834. private _linkEmissiveWithDiffuse;
  13835. linkEmissiveWithDiffuse: boolean;
  13836. private _useSpecularOverAlpha;
  13837. useSpecularOverAlpha: boolean;
  13838. private _useReflectionOverAlpha;
  13839. useReflectionOverAlpha: boolean;
  13840. private _disableLighting;
  13841. disableLighting: boolean;
  13842. private _useObjectSpaceNormalMap;
  13843. /**
  13844. * Allows using an object space normal map (instead of tangent space).
  13845. */
  13846. useObjectSpaceNormalMap: boolean;
  13847. private _useParallax;
  13848. useParallax: boolean;
  13849. private _useParallaxOcclusion;
  13850. useParallaxOcclusion: boolean;
  13851. parallaxScaleBias: number;
  13852. private _roughness;
  13853. roughness: number;
  13854. indexOfRefraction: number;
  13855. invertRefractionY: boolean;
  13856. /**
  13857. * Defines the alpha limits in alpha test mode
  13858. */
  13859. alphaCutOff: number;
  13860. private _useLightmapAsShadowmap;
  13861. useLightmapAsShadowmap: boolean;
  13862. private _diffuseFresnelParameters;
  13863. diffuseFresnelParameters: FresnelParameters;
  13864. private _opacityFresnelParameters;
  13865. opacityFresnelParameters: FresnelParameters;
  13866. private _reflectionFresnelParameters;
  13867. reflectionFresnelParameters: FresnelParameters;
  13868. private _refractionFresnelParameters;
  13869. refractionFresnelParameters: FresnelParameters;
  13870. private _emissiveFresnelParameters;
  13871. emissiveFresnelParameters: FresnelParameters;
  13872. private _useReflectionFresnelFromSpecular;
  13873. useReflectionFresnelFromSpecular: boolean;
  13874. private _useGlossinessFromSpecularMapAlpha;
  13875. useGlossinessFromSpecularMapAlpha: boolean;
  13876. private _maxSimultaneousLights;
  13877. maxSimultaneousLights: number;
  13878. /**
  13879. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  13880. */
  13881. private _invertNormalMapX;
  13882. invertNormalMapX: boolean;
  13883. /**
  13884. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  13885. */
  13886. private _invertNormalMapY;
  13887. invertNormalMapY: boolean;
  13888. /**
  13889. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  13890. */
  13891. private _twoSidedLighting;
  13892. twoSidedLighting: boolean;
  13893. /**
  13894. * Default configuration related to image processing available in the standard Material.
  13895. */
  13896. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  13897. /**
  13898. * Gets the image processing configuration used either in this material.
  13899. */
  13900. /**
  13901. * Sets the Default image processing configuration used either in the this material.
  13902. *
  13903. * If sets to null, the scene one is in use.
  13904. */
  13905. imageProcessingConfiguration: ImageProcessingConfiguration;
  13906. /**
  13907. * Keep track of the image processing observer to allow dispose and replace.
  13908. */
  13909. private _imageProcessingObserver;
  13910. /**
  13911. * Attaches a new image processing configuration to the Standard Material.
  13912. * @param configuration
  13913. */
  13914. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  13915. /**
  13916. * Gets wether the color curves effect is enabled.
  13917. */
  13918. /**
  13919. * Sets wether the color curves effect is enabled.
  13920. */
  13921. cameraColorCurvesEnabled: boolean;
  13922. /**
  13923. * Gets wether the color grading effect is enabled.
  13924. */
  13925. /**
  13926. * Gets wether the color grading effect is enabled.
  13927. */
  13928. cameraColorGradingEnabled: boolean;
  13929. /**
  13930. * Gets wether tonemapping is enabled or not.
  13931. */
  13932. /**
  13933. * Sets wether tonemapping is enabled or not
  13934. */
  13935. cameraToneMappingEnabled: boolean;
  13936. /**
  13937. * The camera exposure used on this material.
  13938. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  13939. * This corresponds to a photographic exposure.
  13940. */
  13941. /**
  13942. * The camera exposure used on this material.
  13943. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  13944. * This corresponds to a photographic exposure.
  13945. */
  13946. cameraExposure: number;
  13947. /**
  13948. * Gets The camera contrast used on this material.
  13949. */
  13950. /**
  13951. * Sets The camera contrast used on this material.
  13952. */
  13953. cameraContrast: number;
  13954. /**
  13955. * Gets the Color Grading 2D Lookup Texture.
  13956. */
  13957. /**
  13958. * Sets the Color Grading 2D Lookup Texture.
  13959. */
  13960. cameraColorGradingTexture: Nullable<BaseTexture>;
  13961. /**
  13962. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  13963. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  13964. * 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;
  13965. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  13966. */
  13967. /**
  13968. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  13969. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  13970. * 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;
  13971. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  13972. */
  13973. cameraColorCurves: Nullable<ColorCurves>;
  13974. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  13975. protected _renderTargets: SmartArray<RenderTargetTexture>;
  13976. protected _worldViewProjectionMatrix: Matrix;
  13977. protected _globalAmbientColor: Color3;
  13978. protected _useLogarithmicDepth: boolean;
  13979. constructor(name: string, scene: Scene);
  13980. getClassName(): string;
  13981. useLogarithmicDepth: boolean;
  13982. needAlphaBlending(): boolean;
  13983. needAlphaTesting(): boolean;
  13984. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  13985. getAlphaTestTexture(): Nullable<BaseTexture>;
  13986. /**
  13987. * Child classes can use it to update shaders
  13988. */
  13989. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  13990. buildUniformLayout(): void;
  13991. unbind(): void;
  13992. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  13993. getAnimatables(): IAnimatable[];
  13994. getActiveTextures(): BaseTexture[];
  13995. hasTexture(texture: BaseTexture): boolean;
  13996. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13997. clone(name: string): StandardMaterial;
  13998. serialize(): any;
  13999. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  14000. static _DiffuseTextureEnabled: boolean;
  14001. static DiffuseTextureEnabled: boolean;
  14002. static _AmbientTextureEnabled: boolean;
  14003. static AmbientTextureEnabled: boolean;
  14004. static _OpacityTextureEnabled: boolean;
  14005. static OpacityTextureEnabled: boolean;
  14006. static _ReflectionTextureEnabled: boolean;
  14007. static ReflectionTextureEnabled: boolean;
  14008. static _EmissiveTextureEnabled: boolean;
  14009. static EmissiveTextureEnabled: boolean;
  14010. static _SpecularTextureEnabled: boolean;
  14011. static SpecularTextureEnabled: boolean;
  14012. static _BumpTextureEnabled: boolean;
  14013. static BumpTextureEnabled: boolean;
  14014. static _LightmapTextureEnabled: boolean;
  14015. static LightmapTextureEnabled: boolean;
  14016. static _RefractionTextureEnabled: boolean;
  14017. static RefractionTextureEnabled: boolean;
  14018. static _ColorGradingTextureEnabled: boolean;
  14019. static ColorGradingTextureEnabled: boolean;
  14020. static _FresnelEnabled: boolean;
  14021. static FresnelEnabled: boolean;
  14022. }
  14023. }
  14024. declare module BABYLON {
  14025. class UniformBuffer {
  14026. private _engine;
  14027. private _buffer;
  14028. private _data;
  14029. private _bufferData;
  14030. private _dynamic?;
  14031. private _uniformLocations;
  14032. private _uniformSizes;
  14033. private _uniformLocationPointer;
  14034. private _needSync;
  14035. private _noUBO;
  14036. private _currentEffect;
  14037. private static _MAX_UNIFORM_SIZE;
  14038. private static _tempBuffer;
  14039. /**
  14040. * Wrapper for updateUniform.
  14041. * @method updateMatrix3x3
  14042. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14043. * @param {Float32Array} matrix
  14044. */
  14045. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  14046. /**
  14047. * Wrapper for updateUniform.
  14048. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14049. * @param {Float32Array} matrix
  14050. */
  14051. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  14052. /**
  14053. * Wrapper for updateUniform.
  14054. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14055. * @param {number} x
  14056. */
  14057. updateFloat: (name: string, x: number) => void;
  14058. /**
  14059. * Wrapper for updateUniform.
  14060. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14061. * @param {number} x
  14062. * @param {number} y
  14063. * @param {string} [suffix] Suffix to add to the uniform name.
  14064. */
  14065. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  14066. /**
  14067. * Wrapper for updateUniform.
  14068. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14069. * @param {number} x
  14070. * @param {number} y
  14071. * @param {number} z
  14072. * @param {string} [suffix] Suffix to add to the uniform name.
  14073. */
  14074. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  14075. /**
  14076. * Wrapper for updateUniform.
  14077. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14078. * @param {number} x
  14079. * @param {number} y
  14080. * @param {number} z
  14081. * @param {number} w
  14082. * @param {string} [suffix] Suffix to add to the uniform name.
  14083. */
  14084. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  14085. /**
  14086. * Wrapper for updateUniform.
  14087. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14088. * @param {Matrix} A 4x4 matrix.
  14089. */
  14090. updateMatrix: (name: string, mat: Matrix) => void;
  14091. /**
  14092. * Wrapper for updateUniform.
  14093. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14094. * @param {Vector3} vector
  14095. */
  14096. updateVector3: (name: string, vector: Vector3) => void;
  14097. /**
  14098. * Wrapper for updateUniform.
  14099. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14100. * @param {Vector4} vector
  14101. */
  14102. updateVector4: (name: string, vector: Vector4) => void;
  14103. /**
  14104. * Wrapper for updateUniform.
  14105. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14106. * @param {Color3} color
  14107. * @param {string} [suffix] Suffix to add to the uniform name.
  14108. */
  14109. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  14110. /**
  14111. * Wrapper for updateUniform.
  14112. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14113. * @param {Color3} color
  14114. * @param {number} alpha
  14115. * @param {string} [suffix] Suffix to add to the uniform name.
  14116. */
  14117. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  14118. /**
  14119. * Uniform buffer objects.
  14120. *
  14121. * Handles blocks of uniform on the GPU.
  14122. *
  14123. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  14124. *
  14125. * For more information, please refer to :
  14126. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  14127. */
  14128. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  14129. /**
  14130. * Indicates if the buffer is using the WebGL2 UBO implementation,
  14131. * or just falling back on setUniformXXX calls.
  14132. */
  14133. readonly useUbo: boolean;
  14134. /**
  14135. * Indicates if the WebGL underlying uniform buffer is in sync
  14136. * with the javascript cache data.
  14137. */
  14138. readonly isSync: boolean;
  14139. /**
  14140. * Indicates if the WebGL underlying uniform buffer is dynamic.
  14141. * Also, a dynamic UniformBuffer will disable cache verification and always
  14142. * update the underlying WebGL uniform buffer to the GPU.
  14143. */
  14144. isDynamic(): boolean;
  14145. /**
  14146. * The data cache on JS side.
  14147. */
  14148. getData(): Float32Array;
  14149. /**
  14150. * The underlying WebGL Uniform buffer.
  14151. */
  14152. getBuffer(): Nullable<WebGLBuffer>;
  14153. /**
  14154. * std140 layout specifies how to align data within an UBO structure.
  14155. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  14156. * for specs.
  14157. */
  14158. private _fillAlignment(size);
  14159. /**
  14160. * Adds an uniform in the buffer.
  14161. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  14162. * for the layout to be correct !
  14163. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14164. * @param {number|number[]} size Data size, or data directly.
  14165. */
  14166. addUniform(name: string, size: number | number[]): void;
  14167. /**
  14168. * Wrapper for addUniform.
  14169. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14170. * @param {Matrix} mat A 4x4 matrix.
  14171. */
  14172. addMatrix(name: string, mat: Matrix): void;
  14173. /**
  14174. * Wrapper for addUniform.
  14175. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14176. * @param {number} x
  14177. * @param {number} y
  14178. */
  14179. addFloat2(name: string, x: number, y: number): void;
  14180. /**
  14181. * Wrapper for addUniform.
  14182. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14183. * @param {number} x
  14184. * @param {number} y
  14185. * @param {number} z
  14186. */
  14187. addFloat3(name: string, x: number, y: number, z: number): void;
  14188. /**
  14189. * Wrapper for addUniform.
  14190. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14191. * @param {Color3} color
  14192. */
  14193. addColor3(name: string, color: Color3): void;
  14194. /**
  14195. * Wrapper for addUniform.
  14196. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14197. * @param {Color3} color
  14198. * @param {number} alpha
  14199. */
  14200. addColor4(name: string, color: Color3, alpha: number): void;
  14201. /**
  14202. * Wrapper for addUniform.
  14203. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14204. * @param {Vector3} vector
  14205. */
  14206. addVector3(name: string, vector: Vector3): void;
  14207. /**
  14208. * Wrapper for addUniform.
  14209. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14210. */
  14211. addMatrix3x3(name: string): void;
  14212. /**
  14213. * Wrapper for addUniform.
  14214. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14215. */
  14216. addMatrix2x2(name: string): void;
  14217. /**
  14218. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  14219. */
  14220. create(): void;
  14221. _rebuild(): void;
  14222. /**
  14223. * Updates the WebGL Uniform Buffer on the GPU.
  14224. * If the `dynamic` flag is set to true, no cache comparison is done.
  14225. * Otherwise, the buffer will be updated only if the cache differs.
  14226. */
  14227. update(): void;
  14228. /**
  14229. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  14230. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  14231. * @param {number[]|Float32Array} data Flattened data
  14232. * @param {number} size Size of the data.
  14233. */
  14234. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  14235. private _updateMatrix3x3ForUniform(name, matrix);
  14236. private _updateMatrix3x3ForEffect(name, matrix);
  14237. private _updateMatrix2x2ForEffect(name, matrix);
  14238. private _updateMatrix2x2ForUniform(name, matrix);
  14239. private _updateFloatForEffect(name, x);
  14240. private _updateFloatForUniform(name, x);
  14241. private _updateFloat2ForEffect(name, x, y, suffix?);
  14242. private _updateFloat2ForUniform(name, x, y, suffix?);
  14243. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  14244. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  14245. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  14246. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  14247. private _updateMatrixForEffect(name, mat);
  14248. private _updateMatrixForUniform(name, mat);
  14249. private _updateVector3ForEffect(name, vector);
  14250. private _updateVector3ForUniform(name, vector);
  14251. private _updateVector4ForEffect(name, vector);
  14252. private _updateVector4ForUniform(name, vector);
  14253. private _updateColor3ForEffect(name, color, suffix?);
  14254. private _updateColor3ForUniform(name, color, suffix?);
  14255. private _updateColor4ForEffect(name, color, alpha, suffix?);
  14256. private _updateColor4ForUniform(name, color, alpha, suffix?);
  14257. /**
  14258. * Sets a sampler uniform on the effect.
  14259. * @param {string} name Name of the sampler.
  14260. * @param {Texture} texture
  14261. */
  14262. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  14263. /**
  14264. * Directly updates the value of the uniform in the cache AND on the GPU.
  14265. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  14266. * @param {number[]|Float32Array} data Flattened data
  14267. */
  14268. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  14269. /**
  14270. * Binds this uniform buffer to an effect.
  14271. * @param {Effect} effect
  14272. * @param {string} name Name of the uniform block in the shader.
  14273. */
  14274. bindToEffect(effect: Effect, name: string): void;
  14275. /**
  14276. * Disposes the uniform buffer.
  14277. */
  14278. dispose(): void;
  14279. }
  14280. }
  14281. declare module BABYLON {
  14282. class Scalar {
  14283. /**
  14284. * Two pi constants convenient for computation.
  14285. */
  14286. static TwoPi: number;
  14287. /**
  14288. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  14289. */
  14290. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  14291. /**
  14292. * Returns a string : the upper case translation of the number i to hexadecimal.
  14293. */
  14294. static ToHex(i: number): string;
  14295. /**
  14296. * Returns -1 if value is negative and +1 is value is positive.
  14297. * Returns the value itself if it's equal to zero.
  14298. */
  14299. static Sign(value: number): number;
  14300. /**
  14301. * Returns the value itself if it's between min and max.
  14302. * Returns min if the value is lower than min.
  14303. * Returns max if the value is greater than max.
  14304. */
  14305. static Clamp(value: number, min?: number, max?: number): number;
  14306. /**
  14307. * Returns the log2 of value.
  14308. */
  14309. static Log2(value: number): number;
  14310. /**
  14311. * Loops the value, so that it is never larger than length and never smaller than 0.
  14312. *
  14313. * This is similar to the modulo operator but it works with floating point numbers.
  14314. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  14315. * With t = 5 and length = 2.5, the result would be 0.0.
  14316. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  14317. */
  14318. static Repeat(value: number, length: number): number;
  14319. /**
  14320. * Normalize the value between 0.0 and 1.0 using min and max values
  14321. */
  14322. static Normalize(value: number, min: number, max: number): number;
  14323. /**
  14324. * Denormalize the value from 0.0 and 1.0 using min and max values
  14325. */
  14326. static Denormalize(normalized: number, min: number, max: number): number;
  14327. /**
  14328. * Calculates the shortest difference between two given angles given in degrees.
  14329. */
  14330. static DeltaAngle(current: number, target: number): number;
  14331. /**
  14332. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  14333. *
  14334. * The returned value will move back and forth between 0 and length
  14335. */
  14336. static PingPong(tx: number, length: number): number;
  14337. /**
  14338. * Interpolates between min and max with smoothing at the limits.
  14339. *
  14340. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  14341. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  14342. */
  14343. static SmoothStep(from: number, to: number, tx: number): number;
  14344. /**
  14345. * Moves a value current towards target.
  14346. *
  14347. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  14348. * Negative values of maxDelta pushes the value away from target.
  14349. */
  14350. static MoveTowards(current: number, target: number, maxDelta: number): number;
  14351. /**
  14352. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  14353. *
  14354. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  14355. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  14356. */
  14357. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  14358. /**
  14359. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  14360. */
  14361. static Lerp(start: number, end: number, amount: number): number;
  14362. /**
  14363. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  14364. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  14365. */
  14366. static LerpAngle(start: number, end: number, amount: number): number;
  14367. /**
  14368. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  14369. */
  14370. static InverseLerp(a: number, b: number, value: number): number;
  14371. /**
  14372. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  14373. */
  14374. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  14375. /**
  14376. * Returns a random float number between and min and max values
  14377. */
  14378. static RandomRange(min: number, max: number): number;
  14379. /**
  14380. * This function returns percentage of a number in a given range.
  14381. *
  14382. * RangeToPercent(40,20,60) will return 0.5 (50%)
  14383. * RangeToPercent(34,0,100) will return 0.34 (34%)
  14384. */
  14385. static RangeToPercent(number: number, min: number, max: number): number;
  14386. /**
  14387. * This function returns number that corresponds to the percentage in a given range.
  14388. *
  14389. * PercentToRange(0.34,0,100) will return 34.
  14390. */
  14391. static PercentToRange(percent: number, min: number, max: number): number;
  14392. /**
  14393. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  14394. * @param angle The angle to normalize in radian.
  14395. * @return The converted angle.
  14396. */
  14397. static NormalizeRadians(angle: number): number;
  14398. }
  14399. }
  14400. declare module BABYLON {
  14401. const ToGammaSpace: number;
  14402. const ToLinearSpace = 2.2;
  14403. const Epsilon = 0.001;
  14404. /**
  14405. * Class used to hold a RBG color
  14406. */
  14407. class Color3 {
  14408. /**
  14409. * Defines the red component (between 0 and 1, default is 0)
  14410. */
  14411. r: number;
  14412. /**
  14413. * Defines the green component (between 0 and 1, default is 0)
  14414. */
  14415. g: number;
  14416. /**
  14417. * Defines the blue component (between 0 and 1, default is 0)
  14418. */
  14419. b: number;
  14420. /**
  14421. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  14422. * @param r defines the red component (between 0 and 1, default is 0)
  14423. * @param g defines the green component (between 0 and 1, default is 0)
  14424. * @param b defines the blue component (between 0 and 1, default is 0)
  14425. */
  14426. constructor(
  14427. /**
  14428. * Defines the red component (between 0 and 1, default is 0)
  14429. */
  14430. r?: number,
  14431. /**
  14432. * Defines the green component (between 0 and 1, default is 0)
  14433. */
  14434. g?: number,
  14435. /**
  14436. * Defines the blue component (between 0 and 1, default is 0)
  14437. */
  14438. b?: number);
  14439. /**
  14440. * Creates a string with the Color3 current values
  14441. * @returns the string representation of the Color3 object
  14442. */
  14443. toString(): string;
  14444. /**
  14445. * Returns the string "Color3"
  14446. * @returns "Color3"
  14447. */
  14448. getClassName(): string;
  14449. /**
  14450. * Compute the Color3 hash code
  14451. * @returns an unique number that can be used to hash Color3 objects
  14452. */
  14453. getHashCode(): number;
  14454. /**
  14455. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  14456. * @param array defines the array where to store the r,g,b components
  14457. * @param index defines an optional index in the target array to define where to start storing values
  14458. * @returns the current Color3 object
  14459. */
  14460. toArray(array: FloatArray, index?: number): Color3;
  14461. /**
  14462. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  14463. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  14464. * @returns a new {BABYLON.Color4} object
  14465. */
  14466. toColor4(alpha?: number): Color4;
  14467. /**
  14468. * Returns a new array populated with 3 numeric elements : red, green and blue values
  14469. * @returns the new array
  14470. */
  14471. asArray(): number[];
  14472. /**
  14473. * Returns the luminance value
  14474. * @returns a float value
  14475. */
  14476. toLuminance(): number;
  14477. /**
  14478. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  14479. * @param otherColor defines the second operand
  14480. * @returns the new Color3 object
  14481. */
  14482. multiply(otherColor: Color3): Color3;
  14483. /**
  14484. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  14485. * @param otherColor defines the second operand
  14486. * @param result defines the Color3 object where to store the result
  14487. * @returns the current Color3
  14488. */
  14489. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  14490. /**
  14491. * Determines equality between Color3 objects
  14492. * @param otherColor defines the second operand
  14493. * @returns true if the rgb values are equal to the given ones
  14494. */
  14495. equals(otherColor: Color3): boolean;
  14496. /**
  14497. * Determines equality between the current Color3 object and a set of r,b,g values
  14498. * @param r defines the red component to check
  14499. * @param g defines the green component to check
  14500. * @param b defines the blue component to check
  14501. * @returns true if the rgb values are equal to the given ones
  14502. */
  14503. equalsFloats(r: number, g: number, b: number): boolean;
  14504. /**
  14505. * Multiplies in place each rgb value by scale
  14506. * @param scale defines the scaling factor
  14507. * @returns the updated Color3
  14508. */
  14509. scale(scale: number): Color3;
  14510. /**
  14511. * Multiplies the rgb values by scale and stores the result into "result"
  14512. * @param scale defines the scaling factor
  14513. * @param result defines the Color3 object where to store the result
  14514. * @returns the unmodified current Color3
  14515. */
  14516. scaleToRef(scale: number, result: Color3): Color3;
  14517. /**
  14518. * Scale the current Color3 values by a factor and add the result to a given Color3
  14519. * @param scale defines the scale factor
  14520. * @param result defines color to store the result into
  14521. * @returns the unmodified current Color3
  14522. */
  14523. scaleAndAddToRef(scale: number, result: Color3): Color3;
  14524. /**
  14525. * Clamps the rgb values by the min and max values and stores the result into "result"
  14526. * @param min defines minimum clamping value (default is 0)
  14527. * @param max defines maximum clamping value (default is 1)
  14528. * @param result defines color to store the result into
  14529. * @returns the original Color3
  14530. */
  14531. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  14532. /**
  14533. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  14534. * @param otherColor defines the second operand
  14535. * @returns the new Color3
  14536. */
  14537. add(otherColor: Color3): Color3;
  14538. /**
  14539. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  14540. * @param otherColor defines the second operand
  14541. * @param result defines Color3 object to store the result into
  14542. * @returns the unmodified current Color3
  14543. */
  14544. addToRef(otherColor: Color3, result: Color3): Color3;
  14545. /**
  14546. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  14547. * @param otherColor defines the second operand
  14548. * @returns the new Color3
  14549. */
  14550. subtract(otherColor: Color3): Color3;
  14551. /**
  14552. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  14553. * @param otherColor defines the second operand
  14554. * @param result defines Color3 object to store the result into
  14555. * @returns the unmodified current Color3
  14556. */
  14557. subtractToRef(otherColor: Color3, result: Color3): Color3;
  14558. /**
  14559. * Copy the current object
  14560. * @returns a new Color3 copied the current one
  14561. */
  14562. clone(): Color3;
  14563. /**
  14564. * Copies the rgb values from the source in the current Color3
  14565. * @param source defines the source Color3 object
  14566. * @returns the updated Color3 object
  14567. */
  14568. copyFrom(source: Color3): Color3;
  14569. /**
  14570. * Updates the Color3 rgb values from the given floats
  14571. * @param r defines the red component to read from
  14572. * @param g defines the green component to read from
  14573. * @param b defines the blue component to read from
  14574. * @returns the current Color3 object
  14575. */
  14576. copyFromFloats(r: number, g: number, b: number): Color3;
  14577. /**
  14578. * Updates the Color3 rgb values from the given floats
  14579. * @param r defines the red component to read from
  14580. * @param g defines the green component to read from
  14581. * @param b defines the blue component to read from
  14582. * @returns the current Color3 object
  14583. */
  14584. set(r: number, g: number, b: number): Color3;
  14585. /**
  14586. * Compute the Color3 hexadecimal code as a string
  14587. * @returns a string containing the hexadecimal representation of the Color3 object
  14588. */
  14589. toHexString(): string;
  14590. /**
  14591. * Computes a new Color3 converted from the current one to linear space
  14592. * @returns a new Color3 object
  14593. */
  14594. toLinearSpace(): Color3;
  14595. /**
  14596. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  14597. * @param convertedColor defines the Color3 object where to store the linear space version
  14598. * @returns the unmodified Color3
  14599. */
  14600. toLinearSpaceToRef(convertedColor: Color3): Color3;
  14601. /**
  14602. * Computes a new Color3 converted from the current one to gamma space
  14603. * @returns a new Color3 object
  14604. */
  14605. toGammaSpace(): Color3;
  14606. /**
  14607. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  14608. * @param convertedColor defines the Color3 object where to store the gamma space version
  14609. * @returns the unmodified Color3
  14610. */
  14611. toGammaSpaceToRef(convertedColor: Color3): Color3;
  14612. /**
  14613. * Creates a new Color3 from the string containing valid hexadecimal values
  14614. * @param hex defines a string containing valid hexadecimal values
  14615. * @returns a new Color3 object
  14616. */
  14617. static FromHexString(hex: string): Color3;
  14618. /**
  14619. * Creates a new Vector3 from the starting index of the given array
  14620. * @param array defines the source array
  14621. * @param offset defines an offset in the source array
  14622. * @returns a new Color3 object
  14623. */
  14624. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  14625. /**
  14626. * Creates a new Color3 from integer values (< 256)
  14627. * @param r defines the red component to read from (value between 0 and 255)
  14628. * @param g defines the green component to read from (value between 0 and 255)
  14629. * @param b defines the blue component to read from (value between 0 and 255)
  14630. * @returns a new Color3 object
  14631. */
  14632. static FromInts(r: number, g: number, b: number): Color3;
  14633. /**
  14634. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  14635. * @param start defines the start Color3 value
  14636. * @param end defines the end Color3 value
  14637. * @param amount defines the gradient value between start and end
  14638. * @returns a new Color3 object
  14639. */
  14640. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  14641. /**
  14642. * Returns a Color3 value containing a red color
  14643. * @returns a new Color3 object
  14644. */
  14645. static Red(): Color3;
  14646. /**
  14647. * Returns a Color3 value containing a green color
  14648. * @returns a new Color3 object
  14649. */
  14650. static Green(): Color3;
  14651. /**
  14652. * Returns a Color3 value containing a blue color
  14653. * @returns a new Color3 object
  14654. */
  14655. static Blue(): Color3;
  14656. /**
  14657. * Returns a Color3 value containing a black color
  14658. * @returns a new Color3 object
  14659. */
  14660. static Black(): Color3;
  14661. /**
  14662. * Returns a Color3 value containing a white color
  14663. * @returns a new Color3 object
  14664. */
  14665. static White(): Color3;
  14666. /**
  14667. * Returns a Color3 value containing a purple color
  14668. * @returns a new Color3 object
  14669. */
  14670. static Purple(): Color3;
  14671. /**
  14672. * Returns a Color3 value containing a magenta color
  14673. * @returns a new Color3 object
  14674. */
  14675. static Magenta(): Color3;
  14676. /**
  14677. * Returns a Color3 value containing a yellow color
  14678. * @returns a new Color3 object
  14679. */
  14680. static Yellow(): Color3;
  14681. /**
  14682. * Returns a Color3 value containing a gray color
  14683. * @returns a new Color3 object
  14684. */
  14685. static Gray(): Color3;
  14686. /**
  14687. * Returns a Color3 value containing a teal color
  14688. * @returns a new Color3 object
  14689. */
  14690. static Teal(): Color3;
  14691. /**
  14692. * Returns a Color3 value containing a random color
  14693. * @returns a new Color3 object
  14694. */
  14695. static Random(): Color3;
  14696. }
  14697. /**
  14698. * Class used to hold a RBGA color
  14699. */
  14700. class Color4 {
  14701. /**
  14702. * Defines the red component (between 0 and 1, default is 0)
  14703. */
  14704. r: number;
  14705. /**
  14706. * Defines the green component (between 0 and 1, default is 0)
  14707. */
  14708. g: number;
  14709. /**
  14710. * Defines the blue component (between 0 and 1, default is 0)
  14711. */
  14712. b: number;
  14713. /**
  14714. * Defines the alpha component (between 0 and 1, default is 1)
  14715. */
  14716. a: number;
  14717. /**
  14718. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  14719. * @param r defines the red component (between 0 and 1, default is 0)
  14720. * @param g defines the green component (between 0 and 1, default is 0)
  14721. * @param b defines the blue component (between 0 and 1, default is 0)
  14722. * @param a defines the alpha component (between 0 and 1, default is 1)
  14723. */
  14724. constructor(
  14725. /**
  14726. * Defines the red component (between 0 and 1, default is 0)
  14727. */
  14728. r?: number,
  14729. /**
  14730. * Defines the green component (between 0 and 1, default is 0)
  14731. */
  14732. g?: number,
  14733. /**
  14734. * Defines the blue component (between 0 and 1, default is 0)
  14735. */
  14736. b?: number,
  14737. /**
  14738. * Defines the alpha component (between 0 and 1, default is 1)
  14739. */
  14740. a?: number);
  14741. /**
  14742. * Adds in place the given Color4 values to the current Color4 object
  14743. * @param right defines the second operand
  14744. * @returns the current updated Color4 object
  14745. */
  14746. addInPlace(right: Color4): Color4;
  14747. /**
  14748. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  14749. * @returns the new array
  14750. */
  14751. asArray(): number[];
  14752. /**
  14753. * Stores from the starting index in the given array the Color4 successive values
  14754. * @param array defines the array where to store the r,g,b components
  14755. * @param index defines an optional index in the target array to define where to start storing values
  14756. * @returns the current Color4 object
  14757. */
  14758. toArray(array: number[], index?: number): Color4;
  14759. /**
  14760. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  14761. * @param right defines the second operand
  14762. * @returns a new Color4 object
  14763. */
  14764. add(right: Color4): Color4;
  14765. /**
  14766. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  14767. * @param right defines the second operand
  14768. * @returns a new Color4 object
  14769. */
  14770. subtract(right: Color4): Color4;
  14771. /**
  14772. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  14773. * @param right defines the second operand
  14774. * @param result defines the Color4 object where to store the result
  14775. * @returns the current Color4 object
  14776. */
  14777. subtractToRef(right: Color4, result: Color4): Color4;
  14778. /**
  14779. * Creates a new Color4 with the current Color4 values multiplied by scale
  14780. * @param scale defines the scaling factor to apply
  14781. * @returns a new Color4 object
  14782. */
  14783. scale(scale: number): Color4;
  14784. /**
  14785. * Multiplies the current Color4 values by scale and stores the result in "result"
  14786. * @param scale defines the scaling factor to apply
  14787. * @param result defines the Color4 object where to store the result
  14788. * @returns the current unmodified Color4
  14789. */
  14790. scaleToRef(scale: number, result: Color4): Color4;
  14791. /**
  14792. * Scale the current Color4 values by a factor and add the result to a given Color4
  14793. * @param scale defines the scale factor
  14794. * @param result defines the Color4 object where to store the result
  14795. * @returns the unmodified current Color4
  14796. */
  14797. scaleAndAddToRef(scale: number, result: Color4): Color4;
  14798. /**
  14799. * Clamps the rgb values by the min and max values and stores the result into "result"
  14800. * @param min defines minimum clamping value (default is 0)
  14801. * @param max defines maximum clamping value (default is 1)
  14802. * @param result defines color to store the result into.
  14803. * @returns the cuurent Color4
  14804. */
  14805. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  14806. /**
  14807. * Multipy an Color4 value by another and return a new Color4 object
  14808. * @param color defines the Color4 value to multiply by
  14809. * @returns a new Color4 object
  14810. */
  14811. multiply(color: Color4): Color4;
  14812. /**
  14813. * Multipy a Color4 value by another and push the result in a reference value
  14814. * @param color defines the Color4 value to multiply by
  14815. * @param result defines the Color4 to fill the result in
  14816. * @returns the result Color4
  14817. */
  14818. multiplyToRef(color: Color4, result: Color4): Color4;
  14819. /**
  14820. * Creates a string with the Color4 current values
  14821. * @returns the string representation of the Color4 object
  14822. */
  14823. toString(): string;
  14824. /**
  14825. * Returns the string "Color4"
  14826. * @returns "Color4"
  14827. */
  14828. getClassName(): string;
  14829. /**
  14830. * Compute the Color4 hash code
  14831. * @returns an unique number that can be used to hash Color4 objects
  14832. */
  14833. getHashCode(): number;
  14834. /**
  14835. * Creates a new Color4 copied from the current one
  14836. * @returns a new Color4 object
  14837. */
  14838. clone(): Color4;
  14839. /**
  14840. * Copies the given Color4 values into the current one
  14841. * @param source defines the source Color4 object
  14842. * @returns the current updated Color4 object
  14843. */
  14844. copyFrom(source: Color4): Color4;
  14845. /**
  14846. * Copies the given float values into the current one
  14847. * @param r defines the red component to read from
  14848. * @param g defines the green component to read from
  14849. * @param b defines the blue component to read from
  14850. * @param a defines the alpha component to read from
  14851. * @returns the current updated Color4 object
  14852. */
  14853. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  14854. /**
  14855. * Copies the given float values into the current one
  14856. * @param r defines the red component to read from
  14857. * @param g defines the green component to read from
  14858. * @param b defines the blue component to read from
  14859. * @param a defines the alpha component to read from
  14860. * @returns the current updated Color4 object
  14861. */
  14862. set(r: number, g: number, b: number, a: number): Color4;
  14863. /**
  14864. * Compute the Color4 hexadecimal code as a string
  14865. * @returns a string containing the hexadecimal representation of the Color4 object
  14866. */
  14867. toHexString(): string;
  14868. /**
  14869. * Computes a new Color4 converted from the current one to linear space
  14870. * @returns a new Color4 object
  14871. */
  14872. toLinearSpace(): Color4;
  14873. /**
  14874. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  14875. * @param convertedColor defines the Color4 object where to store the linear space version
  14876. * @returns the unmodified Color4
  14877. */
  14878. toLinearSpaceToRef(convertedColor: Color4): Color4;
  14879. /**
  14880. * Computes a new Color4 converted from the current one to gamma space
  14881. * @returns a new Color4 object
  14882. */
  14883. toGammaSpace(): Color4;
  14884. /**
  14885. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  14886. * @param convertedColor defines the Color4 object where to store the gamma space version
  14887. * @returns the unmodified Color4
  14888. */
  14889. toGammaSpaceToRef(convertedColor: Color4): Color4;
  14890. /**
  14891. * Creates a new Color4 from the string containing valid hexadecimal values
  14892. * @param hex defines a string containing valid hexadecimal values
  14893. * @returns a new Color4 object
  14894. */
  14895. static FromHexString(hex: string): Color4;
  14896. /**
  14897. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  14898. * @param left defines the start value
  14899. * @param right defines the end value
  14900. * @param amount defines the gradient factor
  14901. * @returns a new Color4 object
  14902. */
  14903. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  14904. /**
  14905. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  14906. * @param left defines the start value
  14907. * @param right defines the end value
  14908. * @param amount defines the gradient factor
  14909. * @param result defines the Color4 object where to store data
  14910. */
  14911. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  14912. /**
  14913. * Creates a new Color4 from the starting index element of the given array
  14914. * @param array defines the source array to read from
  14915. * @param offset defines the offset in the source array
  14916. * @returns a new Color4 object
  14917. */
  14918. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  14919. /**
  14920. * Creates a new Color3 from integer values (< 256)
  14921. * @param r defines the red component to read from (value between 0 and 255)
  14922. * @param g defines the green component to read from (value between 0 and 255)
  14923. * @param b defines the blue component to read from (value between 0 and 255)
  14924. * @param a defines the alpha component to read from (value between 0 and 255)
  14925. * @returns a new Color3 object
  14926. */
  14927. static FromInts(r: number, g: number, b: number, a: number): Color4;
  14928. /**
  14929. * Check the content of a given array and convert it to an array containing RGBA data
  14930. * If the original array was already containing count * 4 values then it is returned directly
  14931. * @param colors defines the array to check
  14932. * @param count defines the number of RGBA data to expect
  14933. * @returns an array containing count * 4 values (RGBA)
  14934. */
  14935. static CheckColors4(colors: number[], count: number): number[];
  14936. }
  14937. /**
  14938. * Class representing a vector containing 2 coordinates
  14939. */
  14940. class Vector2 {
  14941. /** defines the first coordinate */
  14942. x: number;
  14943. /** defines the second coordinate */
  14944. y: number;
  14945. /**
  14946. * Creates a new Vector2 from the given x and y coordinates
  14947. * @param x defines the first coordinate
  14948. * @param y defines the second coordinate
  14949. */
  14950. constructor(
  14951. /** defines the first coordinate */
  14952. x: number,
  14953. /** defines the second coordinate */
  14954. y: number);
  14955. /**
  14956. * Gets a string with the Vector2 coordinates
  14957. * @returns a string with the Vector2 coordinates
  14958. */
  14959. toString(): string;
  14960. /**
  14961. * Gets class name
  14962. * @returns the string "Vector2"
  14963. */
  14964. getClassName(): string;
  14965. /**
  14966. * Gets current vector hash code
  14967. * @returns the Vector2 hash code as a number
  14968. */
  14969. getHashCode(): number;
  14970. /**
  14971. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  14972. * @param array defines the source array
  14973. * @param index defines the offset in source array
  14974. * @returns the current Vector2
  14975. */
  14976. toArray(array: FloatArray, index?: number): Vector2;
  14977. /**
  14978. * Copy the current vector to an array
  14979. * @returns a new array with 2 elements: the Vector2 coordinates.
  14980. */
  14981. asArray(): number[];
  14982. /**
  14983. * Sets the Vector2 coordinates with the given Vector2 coordinates
  14984. * @param source defines the source Vector2
  14985. * @returns the current updated Vector2
  14986. */
  14987. copyFrom(source: Vector2): Vector2;
  14988. /**
  14989. * Sets the Vector2 coordinates with the given floats
  14990. * @param x defines the first coordinate
  14991. * @param y defines the second coordinate
  14992. * @returns the current updated Vector2
  14993. */
  14994. copyFromFloats(x: number, y: number): Vector2;
  14995. /**
  14996. * Sets the Vector2 coordinates with the given floats
  14997. * @param x defines the first coordinate
  14998. * @param y defines the second coordinate
  14999. * @returns the current updated Vector2
  15000. */
  15001. set(x: number, y: number): Vector2;
  15002. /**
  15003. * Add another vector with the current one
  15004. * @param otherVector defines the other vector
  15005. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  15006. */
  15007. add(otherVector: Vector2): Vector2;
  15008. /**
  15009. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  15010. * @param otherVector defines the other vector
  15011. * @param result defines the target vector
  15012. * @returns the unmodified current Vector2
  15013. */
  15014. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  15015. /**
  15016. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  15017. * @param otherVector defines the other vector
  15018. * @returns the current updated Vector2
  15019. */
  15020. addInPlace(otherVector: Vector2): Vector2;
  15021. /**
  15022. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  15023. * @param otherVector defines the other vector
  15024. * @returns a new Vector2
  15025. */
  15026. addVector3(otherVector: Vector3): Vector2;
  15027. /**
  15028. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  15029. * @param otherVector defines the other vector
  15030. * @returns a new Vector2
  15031. */
  15032. subtract(otherVector: Vector2): Vector2;
  15033. /**
  15034. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  15035. * @param otherVector defines the other vector
  15036. * @param result defines the target vector
  15037. * @returns the unmodified current Vector2
  15038. */
  15039. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  15040. /**
  15041. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  15042. * @param otherVector defines the other vector
  15043. * @returns the current updated Vector2
  15044. */
  15045. subtractInPlace(otherVector: Vector2): Vector2;
  15046. /**
  15047. * Multiplies in place the current Vector2 coordinates by the given ones
  15048. * @param otherVector defines the other vector
  15049. * @returns the current updated Vector2
  15050. */
  15051. multiplyInPlace(otherVector: Vector2): Vector2;
  15052. /**
  15053. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  15054. * @param otherVector defines the other vector
  15055. * @returns a new Vector2
  15056. */
  15057. multiply(otherVector: Vector2): Vector2;
  15058. /**
  15059. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  15060. * @param otherVector defines the other vector
  15061. * @param result defines the target vector
  15062. * @returns the unmodified current Vector2
  15063. */
  15064. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  15065. /**
  15066. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  15067. * @param x defines the first coordinate
  15068. * @param y defines the second coordinate
  15069. * @returns a new Vector2
  15070. */
  15071. multiplyByFloats(x: number, y: number): Vector2;
  15072. /**
  15073. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  15074. * @param otherVector defines the other vector
  15075. * @returns a new Vector2
  15076. */
  15077. divide(otherVector: Vector2): Vector2;
  15078. /**
  15079. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  15080. * @param otherVector defines the other vector
  15081. * @param result defines the target vector
  15082. * @returns the unmodified current Vector2
  15083. */
  15084. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  15085. /**
  15086. * Divides the current Vector3 coordinates by the given ones
  15087. * @param otherVector defines the other vector
  15088. * @returns the current updated Vector2
  15089. */
  15090. divideInPlace(otherVector: Vector2): Vector2;
  15091. /**
  15092. * Gets a new Vector2 with current Vector2 negated coordinates
  15093. * @returns a new Vector2
  15094. */
  15095. negate(): Vector2;
  15096. /**
  15097. * Multiply the Vector2 coordinates by scale
  15098. * @param scale defines the scaling factor
  15099. * @returns the current updated Vector2
  15100. */
  15101. scaleInPlace(scale: number): Vector2;
  15102. /**
  15103. * Returns a new Vector2 scaled by "scale" from the current Vector2
  15104. * @param scale defines the scaling factor
  15105. * @returns a new Vector2
  15106. */
  15107. scale(scale: number): Vector2;
  15108. /**
  15109. * Scale the current Vector2 values by a factor to a given Vector2
  15110. * @param scale defines the scale factor
  15111. * @param result defines the Vector2 object where to store the result
  15112. * @returns the unmodified current Vector2
  15113. */
  15114. scaleToRef(scale: number, result: Vector2): Vector2;
  15115. /**
  15116. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  15117. * @param scale defines the scale factor
  15118. * @param result defines the Vector2 object where to store the result
  15119. * @returns the unmodified current Vector2
  15120. */
  15121. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  15122. /**
  15123. * Gets a boolean if two vectors are equals
  15124. * @param otherVector defines the other vector
  15125. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  15126. */
  15127. equals(otherVector: Vector2): boolean;
  15128. /**
  15129. * Gets a boolean if two vectors are equals (using an epsilon value)
  15130. * @param otherVector defines the other vector
  15131. * @param epsilon defines the minimal distance to consider equality
  15132. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  15133. */
  15134. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  15135. /**
  15136. * Gets the length of the vector
  15137. * @returns the vector length (float)
  15138. */
  15139. length(): number;
  15140. /**
  15141. * Gets the vector squared length
  15142. * @returns the vector squared length (float)
  15143. */
  15144. lengthSquared(): number;
  15145. /**
  15146. * Normalize the vector
  15147. * @returns the current updated Vector2
  15148. */
  15149. normalize(): Vector2;
  15150. /**
  15151. * Gets a new Vector2 copied from the Vector2
  15152. * @returns a new Vector2
  15153. */
  15154. clone(): Vector2;
  15155. /**
  15156. * Gets a new Vector2(0, 0)
  15157. * @returns a new Vector2
  15158. */
  15159. static Zero(): Vector2;
  15160. /**
  15161. * Gets a new Vector2(1, 1)
  15162. * @returns a new Vector2
  15163. */
  15164. static One(): Vector2;
  15165. /**
  15166. * Gets a new Vector2 set from the given index element of the given array
  15167. * @param array defines the data source
  15168. * @param offset defines the offset in the data source
  15169. * @returns a new Vector2
  15170. */
  15171. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  15172. /**
  15173. * Sets "result" from the given index element of the given array
  15174. * @param array defines the data source
  15175. * @param offset defines the offset in the data source
  15176. * @param result defines the target vector
  15177. */
  15178. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  15179. /**
  15180. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  15181. * @param value1 defines 1st point of control
  15182. * @param value2 defines 2nd point of control
  15183. * @param value3 defines 3rd point of control
  15184. * @param value4 defines 4th point of control
  15185. * @param amount defines the interpolation factor
  15186. * @returns a new Vector2
  15187. */
  15188. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  15189. /**
  15190. * 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".
  15191. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  15192. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  15193. * @param value defines the value to clamp
  15194. * @param min defines the lower limit
  15195. * @param max defines the upper limit
  15196. * @returns a new Vector2
  15197. */
  15198. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  15199. /**
  15200. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  15201. * @param value1 defines the 1st control point
  15202. * @param tangent1 defines the outgoing tangent
  15203. * @param value2 defines the 2nd control point
  15204. * @param tangent2 defines the incoming tangent
  15205. * @param amount defines the interpolation factor
  15206. * @returns a new Vector2
  15207. */
  15208. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  15209. /**
  15210. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  15211. * @param start defines the start vector
  15212. * @param end defines the end vector
  15213. * @param amount defines the interpolation factor
  15214. * @returns a new Vector2
  15215. */
  15216. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  15217. /**
  15218. * Gets the dot product of the vector "left" and the vector "right"
  15219. * @param left defines first vector
  15220. * @param right defines second vector
  15221. * @returns the dot product (float)
  15222. */
  15223. static Dot(left: Vector2, right: Vector2): number;
  15224. /**
  15225. * Returns a new Vector2 equal to the normalized given vector
  15226. * @param vector defines the vector to normalize
  15227. * @returns a new Vector2
  15228. */
  15229. static Normalize(vector: Vector2): Vector2;
  15230. /**
  15231. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  15232. * @param left defines 1st vector
  15233. * @param right defines 2nd vector
  15234. * @returns a new Vector2
  15235. */
  15236. static Minimize(left: Vector2, right: Vector2): Vector2;
  15237. /**
  15238. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  15239. * @param left defines 1st vector
  15240. * @param right defines 2nd vector
  15241. * @returns a new Vector2
  15242. */
  15243. static Maximize(left: Vector2, right: Vector2): Vector2;
  15244. /**
  15245. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  15246. * @param vector defines the vector to transform
  15247. * @param transformation defines the matrix to apply
  15248. * @returns a new Vector2
  15249. */
  15250. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  15251. /**
  15252. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  15253. * @param vector defines the vector to transform
  15254. * @param transformation defines the matrix to apply
  15255. * @param result defines the target vector
  15256. */
  15257. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  15258. /**
  15259. * Determines if a given vector is included in a triangle
  15260. * @param p defines the vector to test
  15261. * @param p0 defines 1st triangle point
  15262. * @param p1 defines 2nd triangle point
  15263. * @param p2 defines 3rd triangle point
  15264. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  15265. */
  15266. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  15267. /**
  15268. * Gets the distance between the vectors "value1" and "value2"
  15269. * @param value1 defines first vector
  15270. * @param value2 defines second vector
  15271. * @returns the distance between vectors
  15272. */
  15273. static Distance(value1: Vector2, value2: Vector2): number;
  15274. /**
  15275. * Returns the squared distance between the vectors "value1" and "value2"
  15276. * @param value1 defines first vector
  15277. * @param value2 defines second vector
  15278. * @returns the squared distance between vectors
  15279. */
  15280. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  15281. /**
  15282. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  15283. * @param value1 defines first vector
  15284. * @param value2 defines second vector
  15285. * @returns a new Vector2
  15286. */
  15287. static Center(value1: Vector2, value2: Vector2): Vector2;
  15288. /**
  15289. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  15290. * @param p defines the middle point
  15291. * @param segA defines one point of the segment
  15292. * @param segB defines the other point of the segment
  15293. * @returns the shortest distance
  15294. */
  15295. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  15296. }
  15297. /**
  15298. * Classed used to store (x,y,z) vector representation
  15299. * A Vector3 is the main object used in 3D geometry
  15300. * It can represent etiher the coordinates of a point the space, either a direction
  15301. * Reminder: Babylon.js uses a left handed forward facing system
  15302. */
  15303. class Vector3 {
  15304. /**
  15305. * Defines the first coordinates (on X axis)
  15306. */
  15307. x: number;
  15308. /**
  15309. * Defines the second coordinates (on Y axis)
  15310. */
  15311. y: number;
  15312. /**
  15313. * Defines the third coordinates (on Z axis)
  15314. */
  15315. z: number;
  15316. /**
  15317. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  15318. * @param x defines the first coordinates (on X axis)
  15319. * @param y defines the second coordinates (on Y axis)
  15320. * @param z defines the third coordinates (on Z axis)
  15321. */
  15322. constructor(
  15323. /**
  15324. * Defines the first coordinates (on X axis)
  15325. */
  15326. x: number,
  15327. /**
  15328. * Defines the second coordinates (on Y axis)
  15329. */
  15330. y: number,
  15331. /**
  15332. * Defines the third coordinates (on Z axis)
  15333. */
  15334. z: number);
  15335. /**
  15336. * Creates a string representation of the Vector3
  15337. * @returns a string with the Vector3 coordinates.
  15338. */
  15339. toString(): string;
  15340. /**
  15341. * Gets the class name
  15342. * @returns the string "Vector3"
  15343. */
  15344. getClassName(): string;
  15345. /**
  15346. * Creates the Vector3 hash code
  15347. * @returns a number which tends to be unique between Vector3 instances
  15348. */
  15349. getHashCode(): number;
  15350. /**
  15351. * Creates an array containing three elements : the coordinates of the Vector3
  15352. * @returns a new array of numbers
  15353. */
  15354. asArray(): number[];
  15355. /**
  15356. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  15357. * @param array defines the destination array
  15358. * @param index defines the offset in the destination array
  15359. * @returns the current Vector3
  15360. */
  15361. toArray(array: FloatArray, index?: number): Vector3;
  15362. /**
  15363. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  15364. * @returns a new Quaternion object, computed from the Vector3 coordinates
  15365. */
  15366. toQuaternion(): Quaternion;
  15367. /**
  15368. * Adds the given vector to the current Vector3
  15369. * @param otherVector defines the second operand
  15370. * @returns the current updated Vector3
  15371. */
  15372. addInPlace(otherVector: Vector3): Vector3;
  15373. /**
  15374. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  15375. * @param otherVector defines the second operand
  15376. * @returns the resulting Vector3
  15377. */
  15378. add(otherVector: Vector3): Vector3;
  15379. /**
  15380. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  15381. * @param otherVector defines the second operand
  15382. * @param result defines the Vector3 object where to store the result
  15383. * @returns the current Vector3
  15384. */
  15385. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  15386. /**
  15387. * Subtract the given vector from the current Vector3
  15388. * @param otherVector defines the second operand
  15389. * @returns the current updated Vector3
  15390. */
  15391. subtractInPlace(otherVector: Vector3): Vector3;
  15392. /**
  15393. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  15394. * @param otherVector defines the second operand
  15395. * @returns the resulting Vector3
  15396. */
  15397. subtract(otherVector: Vector3): Vector3;
  15398. /**
  15399. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  15400. * @param otherVector defines the second operand
  15401. * @param result defines the Vector3 object where to store the result
  15402. * @returns the current Vector3
  15403. */
  15404. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  15405. /**
  15406. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  15407. * @param x defines the x coordinate of the operand
  15408. * @param y defines the y coordinate of the operand
  15409. * @param z defines the z coordinate of the operand
  15410. * @returns the resulting Vector3
  15411. */
  15412. subtractFromFloats(x: number, y: number, z: number): Vector3;
  15413. /**
  15414. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  15415. * @param x defines the x coordinate of the operand
  15416. * @param y defines the y coordinate of the operand
  15417. * @param z defines the z coordinate of the operand
  15418. * @param result defines the Vector3 object where to store the result
  15419. * @returns the current Vector3
  15420. */
  15421. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  15422. /**
  15423. * Gets a new Vector3 set with the current Vector3 negated coordinates
  15424. * @returns a new Vector3
  15425. */
  15426. negate(): Vector3;
  15427. /**
  15428. * Multiplies the Vector3 coordinates by the float "scale"
  15429. * @param scale defines the multiplier factor
  15430. * @returns the current updated Vector3
  15431. */
  15432. scaleInPlace(scale: number): Vector3;
  15433. /**
  15434. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  15435. * @param scale defines the multiplier factor
  15436. * @returns a new Vector3
  15437. */
  15438. scale(scale: number): Vector3;
  15439. /**
  15440. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  15441. * @param scale defines the multiplier factor
  15442. * @param result defines the Vector3 object where to store the result
  15443. * @returns the current Vector3
  15444. */
  15445. scaleToRef(scale: number, result: Vector3): Vector3;
  15446. /**
  15447. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  15448. * @param scale defines the scale factor
  15449. * @param result defines the Vector3 object where to store the result
  15450. * @returns the unmodified current Vector3
  15451. */
  15452. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  15453. /**
  15454. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  15455. * @param otherVector defines the second operand
  15456. * @returns true if both vectors are equals
  15457. */
  15458. equals(otherVector: Vector3): boolean;
  15459. /**
  15460. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  15461. * @param otherVector defines the second operand
  15462. * @param epsilon defines the minimal distance to define values as equals
  15463. * @returns true if both vectors are distant less than epsilon
  15464. */
  15465. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  15466. /**
  15467. * Returns true if the current Vector3 coordinates equals the given floats
  15468. * @param x defines the x coordinate of the operand
  15469. * @param y defines the y coordinate of the operand
  15470. * @param z defines the z coordinate of the operand
  15471. * @returns true if both vectors are equals
  15472. */
  15473. equalsToFloats(x: number, y: number, z: number): boolean;
  15474. /**
  15475. * Multiplies the current Vector3 coordinates by the given ones
  15476. * @param otherVector defines the second operand
  15477. * @returns the current updated Vector3
  15478. */
  15479. multiplyInPlace(otherVector: Vector3): Vector3;
  15480. /**
  15481. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  15482. * @param otherVector defines the second operand
  15483. * @returns the new Vector3
  15484. */
  15485. multiply(otherVector: Vector3): Vector3;
  15486. /**
  15487. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  15488. * @param otherVector defines the second operand
  15489. * @param result defines the Vector3 object where to store the result
  15490. * @returns the current Vector3
  15491. */
  15492. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  15493. /**
  15494. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  15495. * @param x defines the x coordinate of the operand
  15496. * @param y defines the y coordinate of the operand
  15497. * @param z defines the z coordinate of the operand
  15498. * @returns the new Vector3
  15499. */
  15500. multiplyByFloats(x: number, y: number, z: number): Vector3;
  15501. /**
  15502. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  15503. * @param otherVector defines the second operand
  15504. * @returns the new Vector3
  15505. */
  15506. divide(otherVector: Vector3): Vector3;
  15507. /**
  15508. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  15509. * @param otherVector defines the second operand
  15510. * @param result defines the Vector3 object where to store the result
  15511. * @returns the current Vector3
  15512. */
  15513. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  15514. /**
  15515. * Divides the current Vector3 coordinates by the given ones.
  15516. * @param otherVector defines the second operand
  15517. * @returns the current updated Vector3
  15518. */
  15519. divideInPlace(otherVector: Vector3): Vector3;
  15520. /**
  15521. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  15522. * @param other defines the second operand
  15523. * @returns the current updated Vector3
  15524. */
  15525. minimizeInPlace(other: Vector3): Vector3;
  15526. /**
  15527. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  15528. * @param other defines the second operand
  15529. * @returns the current updated Vector3
  15530. */
  15531. maximizeInPlace(other: Vector3): Vector3;
  15532. /**
  15533. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  15534. */
  15535. readonly isNonUniform: boolean;
  15536. /**
  15537. * Gets the length of the Vector3
  15538. * @returns the length of the Vecto3
  15539. */
  15540. length(): number;
  15541. /**
  15542. * Gets the squared length of the Vector3
  15543. * @returns squared length of the Vector3
  15544. */
  15545. lengthSquared(): number;
  15546. /**
  15547. * Normalize the current Vector3.
  15548. * Please note that this is an in place operation.
  15549. * @returns the current updated Vector3
  15550. */
  15551. normalize(): Vector3;
  15552. /**
  15553. * Normalize the current Vector3 to a new vector
  15554. * @returns the new Vector3
  15555. */
  15556. normalizeToNew(): Vector3;
  15557. /**
  15558. * Normalize the current Vector3 to the reference
  15559. * @param reference define the Vector3 to update
  15560. * @returns the updated Vector3
  15561. */
  15562. normalizeToRef(reference: Vector3): Vector3;
  15563. /**
  15564. * Creates a new Vector3 copied from the current Vector3
  15565. * @returns the new Vector3
  15566. */
  15567. clone(): Vector3;
  15568. /**
  15569. * Copies the given vector coordinates to the current Vector3 ones
  15570. * @param source defines the source Vector3
  15571. * @returns the current updated Vector3
  15572. */
  15573. copyFrom(source: Vector3): Vector3;
  15574. /**
  15575. * Copies the given floats to the current Vector3 coordinates
  15576. * @param x defines the x coordinate of the operand
  15577. * @param y defines the y coordinate of the operand
  15578. * @param z defines the z coordinate of the operand
  15579. * @returns the current updated Vector3
  15580. */
  15581. copyFromFloats(x: number, y: number, z: number): Vector3;
  15582. /**
  15583. * Copies the given floats to the current Vector3 coordinates
  15584. * @param x defines the x coordinate of the operand
  15585. * @param y defines the y coordinate of the operand
  15586. * @param z defines the z coordinate of the operand
  15587. * @returns the current updated Vector3
  15588. */
  15589. set(x: number, y: number, z: number): Vector3;
  15590. /**
  15591. * Get the clip factor between two vectors
  15592. * @param vector0 defines the first operand
  15593. * @param vector1 defines the second operand
  15594. * @param axis defines the axis to use
  15595. * @param size defines the size along the axis
  15596. * @returns the clip factor
  15597. */
  15598. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  15599. /**
  15600. * Get angle between two vectors
  15601. * @param vector0 angle between vector0 and vector1
  15602. * @param vector1 angle between vector0 and vector1
  15603. * @param normal direction of the normal
  15604. * @return the angle between vector0 and vector1
  15605. */
  15606. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  15607. /**
  15608. * Returns a new Vector3 set from the index "offset" of the given array
  15609. * @param array defines the source array
  15610. * @param offset defines the offset in the source array
  15611. * @returns the new Vector3
  15612. */
  15613. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  15614. /**
  15615. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  15616. * This function is deprecated. Use FromArray instead
  15617. * @param array defines the source array
  15618. * @param offset defines the offset in the source array
  15619. * @returns the new Vector3
  15620. */
  15621. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  15622. /**
  15623. * Sets the given vector "result" with the element values from the index "offset" of the given array
  15624. * @param array defines the source array
  15625. * @param offset defines the offset in the source array
  15626. * @param result defines the Vector3 where to store the result
  15627. */
  15628. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  15629. /**
  15630. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  15631. * This function is deprecated. Use FromArrayToRef instead.
  15632. * @param array defines the source array
  15633. * @param offset defines the offset in the source array
  15634. * @param result defines the Vector3 where to store the result
  15635. */
  15636. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  15637. /**
  15638. * Sets the given vector "result" with the given floats.
  15639. * @param x defines the x coordinate of the source
  15640. * @param y defines the y coordinate of the source
  15641. * @param z defines the z coordinate of the source
  15642. * @param result defines the Vector3 where to store the result
  15643. */
  15644. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  15645. /**
  15646. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  15647. * @returns a new empty Vector3
  15648. */
  15649. static Zero(): Vector3;
  15650. /**
  15651. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  15652. * @returns a new unit Vector3
  15653. */
  15654. static One(): Vector3;
  15655. /**
  15656. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  15657. * @returns a new up Vector3
  15658. */
  15659. static Up(): Vector3;
  15660. /**
  15661. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  15662. * @returns a new forward Vector3
  15663. */
  15664. static Forward(): Vector3;
  15665. /**
  15666. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  15667. * @returns a new right Vector3
  15668. */
  15669. static Right(): Vector3;
  15670. /**
  15671. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  15672. * @returns a new left Vector3
  15673. */
  15674. static Left(): Vector3;
  15675. /**
  15676. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  15677. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  15678. * @param vector defines the Vector3 to transform
  15679. * @param transformation defines the transformation matrix
  15680. * @returns the transformed Vector3
  15681. */
  15682. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  15683. /**
  15684. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  15685. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  15686. * @param vector defines the Vector3 to transform
  15687. * @param transformation defines the transformation matrix
  15688. * @param result defines the Vector3 where to store the result
  15689. */
  15690. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  15691. /**
  15692. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  15693. * This method computes tranformed coordinates only, not transformed direction vectors
  15694. * @param x define the x coordinate of the source vector
  15695. * @param y define the y coordinate of the source vector
  15696. * @param z define the z coordinate of the source vector
  15697. * @param transformation defines the transformation matrix
  15698. * @param result defines the Vector3 where to store the result
  15699. */
  15700. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  15701. /**
  15702. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  15703. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  15704. * @param vector defines the Vector3 to transform
  15705. * @param transformation defines the transformation matrix
  15706. * @returns the new Vector3
  15707. */
  15708. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  15709. /**
  15710. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  15711. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  15712. * @param vector defines the Vector3 to transform
  15713. * @param transformation defines the transformation matrix
  15714. * @param result defines the Vector3 where to store the result
  15715. */
  15716. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  15717. /**
  15718. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  15719. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  15720. * @param x define the x coordinate of the source vector
  15721. * @param y define the y coordinate of the source vector
  15722. * @param z define the z coordinate of the source vector
  15723. * @param transformation defines the transformation matrix
  15724. * @param result defines the Vector3 where to store the result
  15725. */
  15726. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  15727. /**
  15728. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  15729. * @param value1 defines the first control point
  15730. * @param value2 defines the second control point
  15731. * @param value3 defines the third control point
  15732. * @param value4 defines the fourth control point
  15733. * @param amount defines the amount on the spline to use
  15734. * @returns the new Vector3
  15735. */
  15736. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  15737. /**
  15738. * 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"
  15739. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  15740. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  15741. * @param value defines the current value
  15742. * @param min defines the lower range value
  15743. * @param max defines the upper range value
  15744. * @returns the new Vector3
  15745. */
  15746. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  15747. /**
  15748. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  15749. * @param value1 defines the first control point
  15750. * @param tangent1 defines the first tangent vector
  15751. * @param value2 defines the second control point
  15752. * @param tangent2 defines the second tangent vector
  15753. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  15754. * @returns the new Vector3
  15755. */
  15756. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  15757. /**
  15758. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  15759. * @param start defines the start value
  15760. * @param end defines the end value
  15761. * @param amount max defines amount between both (between 0 and 1)
  15762. * @returns the new Vector3
  15763. */
  15764. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  15765. /**
  15766. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  15767. * @param start defines the start value
  15768. * @param end defines the end value
  15769. * @param amount max defines amount between both (between 0 and 1)
  15770. * @param result defines the Vector3 where to store the result
  15771. */
  15772. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  15773. /**
  15774. * Returns the dot product (float) between the vectors "left" and "right"
  15775. * @param left defines the left operand
  15776. * @param right defines the right operand
  15777. * @returns the dot product
  15778. */
  15779. static Dot(left: Vector3, right: Vector3): number;
  15780. /**
  15781. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  15782. * The cross product is then orthogonal to both "left" and "right"
  15783. * @param left defines the left operand
  15784. * @param right defines the right operand
  15785. * @returns the cross product
  15786. */
  15787. static Cross(left: Vector3, right: Vector3): Vector3;
  15788. /**
  15789. * Sets the given vector "result" with the cross product of "left" and "right"
  15790. * The cross product is then orthogonal to both "left" and "right"
  15791. * @param left defines the left operand
  15792. * @param right defines the right operand
  15793. * @param result defines the Vector3 where to store the result
  15794. */
  15795. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  15796. /**
  15797. * Returns a new Vector3 as the normalization of the given vector
  15798. * @param vector defines the Vector3 to normalize
  15799. * @returns the new Vector3
  15800. */
  15801. static Normalize(vector: Vector3): Vector3;
  15802. /**
  15803. * Sets the given vector "result" with the normalization of the given first vector
  15804. * @param vector defines the Vector3 to normalize
  15805. * @param result defines the Vector3 where to store the result
  15806. */
  15807. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  15808. private static _viewportMatrixCache;
  15809. /**
  15810. * Project a Vector3 onto screen space
  15811. * @param vector defines the Vector3 to project
  15812. * @param world defines the world matrix to use
  15813. * @param transform defines the transform (view x projection) matrix to use
  15814. * @param viewport defines the screen viewport to use
  15815. * @returns the new Vector3
  15816. */
  15817. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  15818. /**
  15819. * Unproject from screen space to object space
  15820. * @param source defines the screen space Vector3 to use
  15821. * @param viewportWidth defines the current width of the viewport
  15822. * @param viewportHeight defines the current height of the viewport
  15823. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  15824. * @param transform defines the transform (view x projection) matrix to use
  15825. * @returns the new Vector3
  15826. */
  15827. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  15828. /**
  15829. * Unproject from screen space to object space
  15830. * @param source defines the screen space Vector3 to use
  15831. * @param viewportWidth defines the current width of the viewport
  15832. * @param viewportHeight defines the current height of the viewport
  15833. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  15834. * @param view defines the view matrix to use
  15835. * @param projection defines the projection matrix to use
  15836. * @returns the new Vector3
  15837. */
  15838. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  15839. /**
  15840. * Unproject from screen space to object space
  15841. * @param source defines the screen space Vector3 to use
  15842. * @param viewportWidth defines the current width of the viewport
  15843. * @param viewportHeight defines the current height of the viewport
  15844. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  15845. * @param view defines the view matrix to use
  15846. * @param projection defines the projection matrix to use
  15847. * @param result defines the Vector3 where to store the result
  15848. */
  15849. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  15850. /**
  15851. * Unproject from screen space to object space
  15852. * @param sourceX defines the screen space x coordinate to use
  15853. * @param sourceY defines the screen space y coordinate to use
  15854. * @param sourceZ defines the screen space z coordinate to use
  15855. * @param viewportWidth defines the current width of the viewport
  15856. * @param viewportHeight defines the current height of the viewport
  15857. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  15858. * @param view defines the view matrix to use
  15859. * @param projection defines the projection matrix to use
  15860. * @param result defines the Vector3 where to store the result
  15861. */
  15862. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  15863. /**
  15864. * Gets the minimal coordinate values between two Vector3
  15865. * @param left defines the first operand
  15866. * @param right defines the second operand
  15867. * @returns the new Vector3
  15868. */
  15869. static Minimize(left: Vector3, right: Vector3): Vector3;
  15870. /**
  15871. * Gets the maximal coordinate values between two Vector3
  15872. * @param left defines the first operand
  15873. * @param right defines the second operand
  15874. * @returns the new Vector3
  15875. */
  15876. static Maximize(left: Vector3, right: Vector3): Vector3;
  15877. /**
  15878. * Returns the distance between the vectors "value1" and "value2"
  15879. * @param value1 defines the first operand
  15880. * @param value2 defines the second operand
  15881. * @returns the distance
  15882. */
  15883. static Distance(value1: Vector3, value2: Vector3): number;
  15884. /**
  15885. * Returns the squared distance between the vectors "value1" and "value2"
  15886. * @param value1 defines the first operand
  15887. * @param value2 defines the second operand
  15888. * @returns the squared distance
  15889. */
  15890. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  15891. /**
  15892. * Returns a new Vector3 located at the center between "value1" and "value2"
  15893. * @param value1 defines the first operand
  15894. * @param value2 defines the second operand
  15895. * @returns the new Vector3
  15896. */
  15897. static Center(value1: Vector3, value2: Vector3): Vector3;
  15898. /**
  15899. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  15900. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  15901. * to something in order to rotate it from its local system to the given target system
  15902. * Note: axis1, axis2 and axis3 are normalized during this operation
  15903. * @param axis1 defines the first axis
  15904. * @param axis2 defines the second axis
  15905. * @param axis3 defines the third axis
  15906. * @returns a new Vector3
  15907. */
  15908. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  15909. /**
  15910. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  15911. * @param axis1 defines the first axis
  15912. * @param axis2 defines the second axis
  15913. * @param axis3 defines the third axis
  15914. * @param ref defines the Vector3 where to store the result
  15915. */
  15916. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  15917. }
  15918. class Vector4 {
  15919. x: number;
  15920. y: number;
  15921. z: number;
  15922. w: number;
  15923. /**
  15924. * Creates a Vector4 object from the given floats.
  15925. */
  15926. constructor(x: number, y: number, z: number, w: number);
  15927. /**
  15928. * Returns the string with the Vector4 coordinates.
  15929. */
  15930. toString(): string;
  15931. /**
  15932. * Returns the string "Vector4".
  15933. */
  15934. getClassName(): string;
  15935. /**
  15936. * Returns the Vector4 hash code.
  15937. */
  15938. getHashCode(): number;
  15939. /**
  15940. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  15941. */
  15942. asArray(): number[];
  15943. /**
  15944. * Populates the given array from the given index with the Vector4 coordinates.
  15945. * Returns the Vector4.
  15946. */
  15947. toArray(array: FloatArray, index?: number): Vector4;
  15948. /**
  15949. * Adds the given vector to the current Vector4.
  15950. * Returns the updated Vector4.
  15951. */
  15952. addInPlace(otherVector: Vector4): Vector4;
  15953. /**
  15954. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  15955. */
  15956. add(otherVector: Vector4): Vector4;
  15957. /**
  15958. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  15959. * Returns the current Vector4.
  15960. */
  15961. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  15962. /**
  15963. * Subtract in place the given vector from the current Vector4.
  15964. * Returns the updated Vector4.
  15965. */
  15966. subtractInPlace(otherVector: Vector4): Vector4;
  15967. /**
  15968. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  15969. */
  15970. subtract(otherVector: Vector4): Vector4;
  15971. /**
  15972. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  15973. * Returns the current Vector4.
  15974. */
  15975. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  15976. /**
  15977. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  15978. */
  15979. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  15980. /**
  15981. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  15982. * Returns the current Vector4.
  15983. */
  15984. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  15985. /**
  15986. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  15987. */
  15988. negate(): Vector4;
  15989. /**
  15990. * Multiplies the current Vector4 coordinates by scale (float).
  15991. * Returns the updated Vector4.
  15992. */
  15993. scaleInPlace(scale: number): Vector4;
  15994. /**
  15995. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  15996. */
  15997. scale(scale: number): Vector4;
  15998. /**
  15999. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  16000. * Returns the current Vector4.
  16001. */
  16002. scaleToRef(scale: number, result: Vector4): Vector4;
  16003. /**
  16004. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  16005. * @param scale defines the scale factor
  16006. * @param result defines the Vector4 object where to store the result
  16007. * @returns the unmodified current Vector4
  16008. */
  16009. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  16010. /**
  16011. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  16012. */
  16013. equals(otherVector: Vector4): boolean;
  16014. /**
  16015. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  16016. */
  16017. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  16018. /**
  16019. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  16020. */
  16021. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  16022. /**
  16023. * Multiplies in place the current Vector4 by the given one.
  16024. * Returns the updated Vector4.
  16025. */
  16026. multiplyInPlace(otherVector: Vector4): Vector4;
  16027. /**
  16028. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  16029. */
  16030. multiply(otherVector: Vector4): Vector4;
  16031. /**
  16032. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  16033. * Returns the current Vector4.
  16034. */
  16035. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  16036. /**
  16037. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  16038. */
  16039. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  16040. /**
  16041. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  16042. */
  16043. divide(otherVector: Vector4): Vector4;
  16044. /**
  16045. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  16046. * Returns the current Vector4.
  16047. */
  16048. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  16049. /**
  16050. * Divides the current Vector3 coordinates by the given ones.
  16051. * @returns the updated Vector3.
  16052. */
  16053. divideInPlace(otherVector: Vector4): Vector4;
  16054. /**
  16055. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  16056. * @param other defines the second operand
  16057. * @returns the current updated Vector4
  16058. */
  16059. minimizeInPlace(other: Vector4): Vector4;
  16060. /**
  16061. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  16062. * @param other defines the second operand
  16063. * @returns the current updated Vector4
  16064. */
  16065. maximizeInPlace(other: Vector4): Vector4;
  16066. /**
  16067. * Returns the Vector4 length (float).
  16068. */
  16069. length(): number;
  16070. /**
  16071. * Returns the Vector4 squared length (float).
  16072. */
  16073. lengthSquared(): number;
  16074. /**
  16075. * Normalizes in place the Vector4.
  16076. * Returns the updated Vector4.
  16077. */
  16078. normalize(): Vector4;
  16079. /**
  16080. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  16081. */
  16082. toVector3(): Vector3;
  16083. /**
  16084. * Returns a new Vector4 copied from the current one.
  16085. */
  16086. clone(): Vector4;
  16087. /**
  16088. * Updates the current Vector4 with the given one coordinates.
  16089. * Returns the updated Vector4.
  16090. */
  16091. copyFrom(source: Vector4): Vector4;
  16092. /**
  16093. * Updates the current Vector4 coordinates with the given floats.
  16094. * Returns the updated Vector4.
  16095. */
  16096. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16097. /**
  16098. * Updates the current Vector4 coordinates with the given floats.
  16099. * Returns the updated Vector4.
  16100. */
  16101. set(x: number, y: number, z: number, w: number): Vector4;
  16102. /**
  16103. * Returns a new Vector4 set from the starting index of the given array.
  16104. */
  16105. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  16106. /**
  16107. * Updates the given vector "result" from the starting index of the given array.
  16108. */
  16109. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  16110. /**
  16111. * Updates the given vector "result" from the starting index of the given Float32Array.
  16112. */
  16113. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  16114. /**
  16115. * Updates the given vector "result" coordinates from the given floats.
  16116. */
  16117. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  16118. /**
  16119. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  16120. */
  16121. static Zero(): Vector4;
  16122. /**
  16123. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  16124. */
  16125. static One(): Vector4;
  16126. /**
  16127. * Returns a new normalized Vector4 from the given one.
  16128. */
  16129. static Normalize(vector: Vector4): Vector4;
  16130. /**
  16131. * Updates the given vector "result" from the normalization of the given one.
  16132. */
  16133. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  16134. static Minimize(left: Vector4, right: Vector4): Vector4;
  16135. static Maximize(left: Vector4, right: Vector4): Vector4;
  16136. /**
  16137. * Returns the distance (float) between the vectors "value1" and "value2".
  16138. */
  16139. static Distance(value1: Vector4, value2: Vector4): number;
  16140. /**
  16141. * Returns the squared distance (float) between the vectors "value1" and "value2".
  16142. */
  16143. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  16144. /**
  16145. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  16146. */
  16147. static Center(value1: Vector4, value2: Vector4): Vector4;
  16148. /**
  16149. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  16150. * This methods computes transformed normalized direction vectors only.
  16151. */
  16152. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  16153. /**
  16154. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  16155. * This methods computes transformed normalized direction vectors only.
  16156. */
  16157. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  16158. /**
  16159. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  16160. * This methods computes transformed normalized direction vectors only.
  16161. */
  16162. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  16163. }
  16164. interface ISize {
  16165. width: number;
  16166. height: number;
  16167. }
  16168. class Size implements ISize {
  16169. width: number;
  16170. height: number;
  16171. /**
  16172. * Creates a Size object from the given width and height (floats).
  16173. */
  16174. constructor(width: number, height: number);
  16175. toString(): string;
  16176. /**
  16177. * Returns the string "Size"
  16178. */
  16179. getClassName(): string;
  16180. /**
  16181. * Returns the Size hash code.
  16182. */
  16183. getHashCode(): number;
  16184. /**
  16185. * Updates the current size from the given one.
  16186. * Returns the updated Size.
  16187. */
  16188. copyFrom(src: Size): void;
  16189. /**
  16190. * Updates in place the current Size from the given floats.
  16191. * Returns the updated Size.
  16192. */
  16193. copyFromFloats(width: number, height: number): Size;
  16194. /**
  16195. * Updates in place the current Size from the given floats.
  16196. * Returns the updated Size.
  16197. */
  16198. set(width: number, height: number): Size;
  16199. /**
  16200. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  16201. */
  16202. multiplyByFloats(w: number, h: number): Size;
  16203. /**
  16204. * Returns a new Size copied from the given one.
  16205. */
  16206. clone(): Size;
  16207. /**
  16208. * Boolean : True if the current Size and the given one width and height are strictly equal.
  16209. */
  16210. equals(other: Size): boolean;
  16211. /**
  16212. * Returns the surface of the Size : width * height (float).
  16213. */
  16214. readonly surface: number;
  16215. /**
  16216. * Returns a new Size set to (0.0, 0.0)
  16217. */
  16218. static Zero(): Size;
  16219. /**
  16220. * Returns a new Size set as the addition result of the current Size and the given one.
  16221. */
  16222. add(otherSize: Size): Size;
  16223. /**
  16224. * Returns a new Size set as the subtraction result of the given one from the current Size.
  16225. */
  16226. subtract(otherSize: Size): Size;
  16227. /**
  16228. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  16229. */
  16230. static Lerp(start: Size, end: Size, amount: number): Size;
  16231. }
  16232. /**
  16233. * Class used to store quaternion data
  16234. * @see https://en.wikipedia.org/wiki/Quaternion
  16235. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  16236. */
  16237. class Quaternion {
  16238. /** defines the first component (0 by default) */
  16239. x: number;
  16240. /** defines the second component (0 by default) */
  16241. y: number;
  16242. /** defines the third component (0 by default) */
  16243. z: number;
  16244. /** defines the fourth component (1.0 by default) */
  16245. w: number;
  16246. /**
  16247. * Creates a new Quaternion from the given floats
  16248. * @param x defines the first component (0 by default)
  16249. * @param y defines the second component (0 by default)
  16250. * @param z defines the third component (0 by default)
  16251. * @param w defines the fourth component (1.0 by default)
  16252. */
  16253. constructor(
  16254. /** defines the first component (0 by default) */
  16255. x?: number,
  16256. /** defines the second component (0 by default) */
  16257. y?: number,
  16258. /** defines the third component (0 by default) */
  16259. z?: number,
  16260. /** defines the fourth component (1.0 by default) */
  16261. w?: number);
  16262. /**
  16263. * Gets a string representation for the current quaternion
  16264. * @returns a string with the Quaternion coordinates
  16265. */
  16266. toString(): string;
  16267. /**
  16268. * Gets the class name of the quaternion
  16269. * @returns the string "Quaternion"
  16270. */
  16271. getClassName(): string;
  16272. /**
  16273. * Gets a hash code for this quaternion
  16274. * @returns the quaternion hash code
  16275. */
  16276. getHashCode(): number;
  16277. /**
  16278. * Copy the quaternion to an array
  16279. * @returns a new array populated with 4 elements from the quaternion coordinates
  16280. */
  16281. asArray(): number[];
  16282. /**
  16283. * Check if two quaternions are equals
  16284. * @param otherQuaternion defines the second operand
  16285. * @return true if the current quaternion and the given one coordinates are strictly equals
  16286. */
  16287. equals(otherQuaternion: Quaternion): boolean;
  16288. /**
  16289. * Clone the current quaternion
  16290. * @returns a new quaternion copied from the current one
  16291. */
  16292. clone(): Quaternion;
  16293. /**
  16294. * Copy a quaternion to the current one
  16295. * @param other defines the other quaternion
  16296. * @returns the updated current quaternion
  16297. */
  16298. copyFrom(other: Quaternion): Quaternion;
  16299. /**
  16300. * Updates the current quaternion with the given float coordinates
  16301. * @param x defines the x coordinate
  16302. * @param y defines the y coordinate
  16303. * @param z defines the z coordinate
  16304. * @param w defines the w coordinate
  16305. * @returns the updated current quaternion
  16306. */
  16307. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  16308. /**
  16309. * Updates the current quaternion from the given float coordinates
  16310. * @param x defines the x coordinate
  16311. * @param y defines the y coordinate
  16312. * @param z defines the z coordinate
  16313. * @param w defines the w coordinate
  16314. * @returns the updated current quaternion
  16315. */
  16316. set(x: number, y: number, z: number, w: number): Quaternion;
  16317. /**
  16318. * Adds two quaternions
  16319. * @param other defines the second operand
  16320. * @returns a new quaternion as the addition result of the given one and the current quaternion
  16321. */
  16322. add(other: Quaternion): Quaternion;
  16323. /**
  16324. * Add a quaternion to the current one
  16325. * @param other defines the quaternion to add
  16326. * @returns the current quaternion
  16327. */
  16328. addInPlace(other: Quaternion): Quaternion;
  16329. /**
  16330. * Subtract two quaternions
  16331. * @param other defines the second operand
  16332. * @returns a new quaternion as the subtraction result of the given one from the current one
  16333. */
  16334. subtract(other: Quaternion): Quaternion;
  16335. /**
  16336. * Multiplies the current quaternion by a scale factor
  16337. * @param value defines the scale factor
  16338. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  16339. */
  16340. scale(value: number): Quaternion;
  16341. /**
  16342. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  16343. * @param scale defines the scale factor
  16344. * @param result defines the Quaternion object where to store the result
  16345. * @returns the unmodified current quaternion
  16346. */
  16347. scaleToRef(scale: number, result: Quaternion): Quaternion;
  16348. /**
  16349. * Multiplies in place the current quaternion by a scale factor
  16350. * @param value defines the scale factor
  16351. * @returns the current modified quaternion
  16352. */
  16353. scaleInPlace(value: number): Quaternion;
  16354. /**
  16355. * Scale the current quaternion values by a factor and add the result to a given quaternion
  16356. * @param scale defines the scale factor
  16357. * @param result defines the Quaternion object where to store the result
  16358. * @returns the unmodified current quaternion
  16359. */
  16360. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  16361. /**
  16362. * Multiplies two quaternions
  16363. * @param q1 defines the second operand
  16364. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  16365. */
  16366. multiply(q1: Quaternion): Quaternion;
  16367. /**
  16368. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  16369. * @param q1 defines the second operand
  16370. * @param result defines the target quaternion
  16371. * @returns the current quaternion
  16372. */
  16373. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  16374. /**
  16375. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  16376. * @param q1 defines the second operand
  16377. * @returns the currentupdated quaternion
  16378. */
  16379. multiplyInPlace(q1: Quaternion): Quaternion;
  16380. /**
  16381. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  16382. * @param ref defines the target quaternion
  16383. * @returns the current quaternion
  16384. */
  16385. conjugateToRef(ref: Quaternion): Quaternion;
  16386. /**
  16387. * Conjugates in place (1-q) the current quaternion
  16388. * @returns the current updated quaternion
  16389. */
  16390. conjugateInPlace(): Quaternion;
  16391. /**
  16392. * Conjugates in place (1-q) the current quaternion
  16393. * @returns a new quaternion
  16394. */
  16395. conjugate(): Quaternion;
  16396. /**
  16397. * Gets length of current quaternion
  16398. * @returns the quaternion length (float)
  16399. */
  16400. length(): number;
  16401. /**
  16402. * Normalize in place the current quaternion
  16403. * @returns the current updated quaternion
  16404. */
  16405. normalize(): Quaternion;
  16406. /**
  16407. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  16408. * @param order is a reserved parameter and is ignore for now
  16409. * @returns a new Vector3 containing the Euler angles
  16410. */
  16411. toEulerAngles(order?: string): Vector3;
  16412. /**
  16413. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  16414. * @param result defines the vector which will be filled with the Euler angles
  16415. * @param order is a reserved parameter and is ignore for now
  16416. * @returns the current unchanged quaternion
  16417. */
  16418. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  16419. /**
  16420. * Updates the given rotation matrix with the current quaternion values
  16421. * @param result defines the target matrix
  16422. * @returns the current unchanged quaternion
  16423. */
  16424. toRotationMatrix(result: Matrix): Quaternion;
  16425. /**
  16426. * Updates the current quaternion from the given rotation matrix values
  16427. * @param matrix defines the source matrix
  16428. * @returns the current updated quaternion
  16429. */
  16430. fromRotationMatrix(matrix: Matrix): Quaternion;
  16431. /**
  16432. * Creates a new quaternion from a rotation matrix
  16433. * @param matrix defines the source matrix
  16434. * @returns a new quaternion created from the given rotation matrix values
  16435. */
  16436. static FromRotationMatrix(matrix: Matrix): Quaternion;
  16437. /**
  16438. * Updates the given quaternion with the given rotation matrix values
  16439. * @param matrix defines the source matrix
  16440. * @param result defines the target quaternion
  16441. */
  16442. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  16443. /**
  16444. * Returns the dot product (float) between the quaternions "left" and "right"
  16445. * @param left defines the left operand
  16446. * @param right defines the right operand
  16447. * @returns the dot product
  16448. */
  16449. static Dot(left: Quaternion, right: Quaternion): number;
  16450. /**
  16451. * Checks if the two quaternions are close to each other
  16452. * @param quat0 defines the first quaternion to check
  16453. * @param quat1 defines the second quaternion to check
  16454. * @returns true if the two quaternions are close to each other
  16455. */
  16456. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  16457. /**
  16458. * Creates an empty quaternion
  16459. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  16460. */
  16461. static Zero(): Quaternion;
  16462. /**
  16463. * Inverse a given quaternion
  16464. * @param q defines the source quaternion
  16465. * @returns a new quaternion as the inverted current quaternion
  16466. */
  16467. static Inverse(q: Quaternion): Quaternion;
  16468. /**
  16469. * Creates an identity quaternion
  16470. * @returns the identity quaternion
  16471. */
  16472. static Identity(): Quaternion;
  16473. /**
  16474. * Gets a boolean indicating if the given quaternion is identity
  16475. * @param quaternion defines the quaternion to check
  16476. * @returns true if the quaternion is identity
  16477. */
  16478. static IsIdentity(quaternion: Quaternion): boolean;
  16479. /**
  16480. * Creates a quaternion from a rotation around an axis
  16481. * @param axis defines the axis to use
  16482. * @param angle defines the angle to use
  16483. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  16484. */
  16485. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  16486. /**
  16487. * Creates a rotation around an axis and stores it into the given quaternion
  16488. * @param axis defines the axis to use
  16489. * @param angle defines the angle to use
  16490. * @param result defines the target quaternion
  16491. * @returns the target quaternion
  16492. */
  16493. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  16494. /**
  16495. * Creates a new quaternion from data stored into an array
  16496. * @param array defines the data source
  16497. * @param offset defines the offset in the source array where the data starts
  16498. * @returns a new quaternion
  16499. */
  16500. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  16501. /**
  16502. * Creates a new quaternion from the given Euler float angles (y, x, z)
  16503. * @param yaw defines the rotation around Y axis
  16504. * @param pitch defines the rotation around X axis
  16505. * @param roll defines the rotation around Z axis
  16506. * @returns the new quaternion
  16507. */
  16508. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  16509. /**
  16510. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  16511. * @param yaw defines the rotation around Y axis
  16512. * @param pitch defines the rotation around X axis
  16513. * @param roll defines the rotation around Z axis
  16514. * @param result defines the target quaternion
  16515. */
  16516. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  16517. /**
  16518. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  16519. * @param alpha defines the rotation around first axis
  16520. * @param beta defines the rotation around second axis
  16521. * @param gamma defines the rotation around third axis
  16522. * @returns the new quaternion
  16523. */
  16524. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  16525. /**
  16526. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  16527. * @param alpha defines the rotation around first axis
  16528. * @param beta defines the rotation around second axis
  16529. * @param gamma defines the rotation around third axis
  16530. * @param result defines the target quaternion
  16531. */
  16532. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  16533. /**
  16534. * 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)
  16535. * @param axis1 defines the first axis
  16536. * @param axis2 defines the second axis
  16537. * @param axis3 defines the third axis
  16538. * @returns the new quaternion
  16539. */
  16540. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  16541. /**
  16542. * 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
  16543. * @param axis1 defines the first axis
  16544. * @param axis2 defines the second axis
  16545. * @param axis3 defines the third axis
  16546. * @param ref defines the target quaternion
  16547. */
  16548. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  16549. /**
  16550. * Interpolates between two quaternions
  16551. * @param left defines first quaternion
  16552. * @param right defines second quaternion
  16553. * @param amount defines the gradient to use
  16554. * @returns the new interpolated quaternion
  16555. */
  16556. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  16557. /**
  16558. * Interpolates between two quaternions and stores it into a target quaternion
  16559. * @param left defines first quaternion
  16560. * @param right defines second quaternion
  16561. * @param amount defines the gradient to use
  16562. * @param result defines the target quaternion
  16563. */
  16564. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  16565. /**
  16566. * Interpolate between two quaternions using Hermite interpolation
  16567. * @param value1 defines first quaternion
  16568. * @param tangent1 defines the incoming tangent
  16569. * @param value2 defines second quaternion
  16570. * @param tangent2 defines the outgoing tangent
  16571. * @param amount defines the target quaternion
  16572. * @returns the new interpolated quaternion
  16573. */
  16574. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  16575. }
  16576. /**
  16577. * Class used to store matrix data (4x4)
  16578. */
  16579. class Matrix {
  16580. private static _tempQuaternion;
  16581. private static _xAxis;
  16582. private static _yAxis;
  16583. private static _zAxis;
  16584. private static _updateFlagSeed;
  16585. private static _identityReadOnly;
  16586. private _isIdentity;
  16587. private _isIdentityDirty;
  16588. /**
  16589. * Gets the update flag of the matrix which is an unique number for the matrix.
  16590. * It will be incremented every time the matrix data change.
  16591. * You can use it to speed the comparison between two versions of the same matrix.
  16592. */
  16593. updateFlag: number;
  16594. /**
  16595. * Gets or sets the internal data of the matrix
  16596. */
  16597. m: Float32Array;
  16598. /** @hidden */
  16599. _markAsUpdated(): void;
  16600. /**
  16601. * Creates an empty matrix (filled with zeros)
  16602. */
  16603. constructor();
  16604. /**
  16605. * Check if the current matrix is indentity
  16606. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  16607. * @returns true is the matrix is the identity matrix
  16608. */
  16609. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  16610. /**
  16611. * Gets the determinant of the matrix
  16612. * @returns the matrix determinant
  16613. */
  16614. determinant(): number;
  16615. /**
  16616. * Returns the matrix as a Float32Array
  16617. * @returns the matrix underlying array
  16618. */
  16619. toArray(): Float32Array;
  16620. /**
  16621. * Returns the matrix as a Float32Array
  16622. * @returns the matrix underlying array.
  16623. */
  16624. asArray(): Float32Array;
  16625. /**
  16626. * Inverts the current matrix in place
  16627. * @returns the current inverted matrix
  16628. */
  16629. invert(): Matrix;
  16630. /**
  16631. * Sets all the matrix elements to zero
  16632. * @returns the current matrix
  16633. */
  16634. reset(): Matrix;
  16635. /**
  16636. * Adds the current matrix with a second one
  16637. * @param other defines the matrix to add
  16638. * @returns a new matrix as the addition of the current matrix and the given one
  16639. */
  16640. add(other: Matrix): Matrix;
  16641. /**
  16642. * Sets the given matrix "result" to the addition of the current matrix and the given one
  16643. * @param other defines the matrix to add
  16644. * @param result defines the target matrix
  16645. * @returns the current matrix
  16646. */
  16647. addToRef(other: Matrix, result: Matrix): Matrix;
  16648. /**
  16649. * Adds in place the given matrix to the current matrix
  16650. * @param other defines the second operand
  16651. * @returns the current updated matrix
  16652. */
  16653. addToSelf(other: Matrix): Matrix;
  16654. /**
  16655. * Sets the given matrix to the current inverted Matrix
  16656. * @param other defines the target matrix
  16657. * @returns the unmodified current matrix
  16658. */
  16659. invertToRef(other: Matrix): Matrix;
  16660. /**
  16661. * Inserts the translation vector (using 3 floats) in the current matrix
  16662. * @param x defines the 1st component of the translation
  16663. * @param y defines the 2nd component of the translation
  16664. * @param z defines the 3rd component of the translation
  16665. * @returns the current updated matrix
  16666. */
  16667. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  16668. /**
  16669. * Inserts the translation vector in the current matrix
  16670. * @param vector3 defines the translation to insert
  16671. * @returns the current updated matrix
  16672. */
  16673. setTranslation(vector3: Vector3): Matrix;
  16674. /**
  16675. * Gets the translation value of the current matrix
  16676. * @returns a new Vector3 as the extracted translation from the matrix
  16677. */
  16678. getTranslation(): Vector3;
  16679. /**
  16680. * Fill a Vector3 with the extracted translation from the matrix
  16681. * @param result defines the Vector3 where to store the translation
  16682. * @returns the current matrix
  16683. */
  16684. getTranslationToRef(result: Vector3): Matrix;
  16685. /**
  16686. * Remove rotation and scaling part from the matrix
  16687. * @returns the updated matrix
  16688. */
  16689. removeRotationAndScaling(): Matrix;
  16690. /**
  16691. * Multiply two matrices
  16692. * @param other defines the second operand
  16693. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  16694. */
  16695. multiply(other: Matrix): Matrix;
  16696. /**
  16697. * Copy the current matrix from the given one
  16698. * @param other defines the source matrix
  16699. * @returns the current updated matrix
  16700. */
  16701. copyFrom(other: Matrix): Matrix;
  16702. /**
  16703. * Populates the given array from the starting index with the current matrix values
  16704. * @param array defines the target array
  16705. * @param offset defines the offset in the target array where to start storing values
  16706. * @returns the current matrix
  16707. */
  16708. copyToArray(array: Float32Array, offset?: number): Matrix;
  16709. /**
  16710. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  16711. * @param other defines the second operand
  16712. * @param result defines the matrix where to store the multiplication
  16713. * @returns the current matrix
  16714. */
  16715. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  16716. /**
  16717. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  16718. * @param other defines the second operand
  16719. * @param result defines the array where to store the multiplication
  16720. * @param offset defines the offset in the target array where to start storing values
  16721. * @returns the current matrix
  16722. */
  16723. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  16724. /**
  16725. * Check equality between this matrix and a second one
  16726. * @param value defines the second matrix to compare
  16727. * @returns true is the current matrix and the given one values are strictly equal
  16728. */
  16729. equals(value: Matrix): boolean;
  16730. /**
  16731. * Clone the current matrix
  16732. * @returns a new matrix from the current matrix
  16733. */
  16734. clone(): Matrix;
  16735. /**
  16736. * Returns the name of the current matrix class
  16737. * @returns the string "Matrix"
  16738. */
  16739. getClassName(): string;
  16740. /**
  16741. * Gets the hash code of the current matrix
  16742. * @returns the hash code
  16743. */
  16744. getHashCode(): number;
  16745. /**
  16746. * Decomposes the current Matrix into a translation, rotation and scaling components
  16747. * @param scale defines the scale vector3 given as a reference to update
  16748. * @param rotation defines the rotation quaternion given as a reference to update
  16749. * @param translation defines the translation vector3 given as a reference to update
  16750. * @returns true if operation was successful
  16751. */
  16752. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  16753. /**
  16754. * Gets specific row of the matrix
  16755. * @param index defines the number of the row to get
  16756. * @returns the index-th row of the current matrix as a new Vector4
  16757. */
  16758. getRow(index: number): Nullable<Vector4>;
  16759. /**
  16760. * Sets the index-th row of the current matrix to the vector4 values
  16761. * @param index defines the number of the row to set
  16762. * @param row defines the target vector4
  16763. * @returns the updated current matrix
  16764. */
  16765. setRow(index: number, row: Vector4): Matrix;
  16766. /**
  16767. * Compute the transpose of the matrix
  16768. * @returns the new transposed matrix
  16769. */
  16770. transpose(): Matrix;
  16771. /**
  16772. * Compute the transpose of the matrix and store it in a given matrix
  16773. * @param result defines the target matrix
  16774. * @returns the current matrix
  16775. */
  16776. transposeToRef(result: Matrix): Matrix;
  16777. /**
  16778. * Sets the index-th row of the current matrix with the given 4 x float values
  16779. * @param index defines the row index
  16780. * @param x defines the x component to set
  16781. * @param y defines the y component to set
  16782. * @param z defines the z component to set
  16783. * @param w defines the w component to set
  16784. * @returns the updated current matrix
  16785. */
  16786. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  16787. /**
  16788. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  16789. * @param scale defines the scale factor
  16790. * @returns a new matrix
  16791. */
  16792. scale(scale: number): Matrix;
  16793. /**
  16794. * Scale the current matrix values by a factor to a given result matrix
  16795. * @param scale defines the scale factor
  16796. * @param result defines the matrix to store the result
  16797. * @returns the current matrix
  16798. */
  16799. scaleToRef(scale: number, result: Matrix): Matrix;
  16800. /**
  16801. * Scale the current matrix values by a factor and add the result to a given matrix
  16802. * @param scale defines the scale factor
  16803. * @param result defines the Matrix to store the result
  16804. * @returns the current matrix
  16805. */
  16806. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  16807. /**
  16808. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  16809. * @param ref matrix to store the result
  16810. */
  16811. toNormalMatrix(ref: Matrix): void;
  16812. /**
  16813. * Gets only rotation part of the current matrix
  16814. * @returns a new matrix sets to the extracted rotation matrix from the current one
  16815. */
  16816. getRotationMatrix(): Matrix;
  16817. /**
  16818. * Extracts the rotation matrix from the current one and sets it as the given "result"
  16819. * @param result defines the target matrix to store data to
  16820. * @returns the current matrix
  16821. */
  16822. getRotationMatrixToRef(result: Matrix): Matrix;
  16823. /**
  16824. * Creates a matrix from an array
  16825. * @param array defines the source array
  16826. * @param offset defines an offset in the source array
  16827. * @returns a new Matrix set from the starting index of the given array
  16828. */
  16829. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  16830. /**
  16831. * Copy the content of an array into a given matrix
  16832. * @param array defines the source array
  16833. * @param offset defines an offset in the source array
  16834. * @param result defines the target matrix
  16835. */
  16836. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  16837. /**
  16838. * Stores an array into a matrix after having multiplied each component by a given factor
  16839. * @param array defines the source array
  16840. * @param offset defines the offset in the source array
  16841. * @param scale defines the scaling factor
  16842. * @param result defines the target matrix
  16843. */
  16844. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  16845. /**
  16846. * Stores a list of values (16) inside a given matrix
  16847. * @param initialM11 defines 1st value of 1st row
  16848. * @param initialM12 defines 2nd value of 1st row
  16849. * @param initialM13 defines 3rd value of 1st row
  16850. * @param initialM14 defines 4th value of 1st row
  16851. * @param initialM21 defines 1st value of 2nd row
  16852. * @param initialM22 defines 2nd value of 2nd row
  16853. * @param initialM23 defines 3rd value of 2nd row
  16854. * @param initialM24 defines 4th value of 2nd row
  16855. * @param initialM31 defines 1st value of 3rd row
  16856. * @param initialM32 defines 2nd value of 3rd row
  16857. * @param initialM33 defines 3rd value of 3rd row
  16858. * @param initialM34 defines 4th value of 3rd row
  16859. * @param initialM41 defines 1st value of 4th row
  16860. * @param initialM42 defines 2nd value of 4th row
  16861. * @param initialM43 defines 3rd value of 4th row
  16862. * @param initialM44 defines 4th value of 4th row
  16863. * @param result defines the target matrix
  16864. */
  16865. 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;
  16866. /**
  16867. * Gets an identity matrix that must not be updated
  16868. */
  16869. static readonly IdentityReadOnly: Matrix;
  16870. /**
  16871. * Creates new matrix from a list of values (16)
  16872. * @param initialM11 defines 1st value of 1st row
  16873. * @param initialM12 defines 2nd value of 1st row
  16874. * @param initialM13 defines 3rd value of 1st row
  16875. * @param initialM14 defines 4th value of 1st row
  16876. * @param initialM21 defines 1st value of 2nd row
  16877. * @param initialM22 defines 2nd value of 2nd row
  16878. * @param initialM23 defines 3rd value of 2nd row
  16879. * @param initialM24 defines 4th value of 2nd row
  16880. * @param initialM31 defines 1st value of 3rd row
  16881. * @param initialM32 defines 2nd value of 3rd row
  16882. * @param initialM33 defines 3rd value of 3rd row
  16883. * @param initialM34 defines 4th value of 3rd row
  16884. * @param initialM41 defines 1st value of 4th row
  16885. * @param initialM42 defines 2nd value of 4th row
  16886. * @param initialM43 defines 3rd value of 4th row
  16887. * @param initialM44 defines 4th value of 4th row
  16888. * @returns the new matrix
  16889. */
  16890. 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;
  16891. /**
  16892. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  16893. * @param scale defines the scale vector3
  16894. * @param rotation defines the rotation quaternion
  16895. * @param translation defines the translation vector3
  16896. * @returns a new matrix
  16897. */
  16898. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  16899. /**
  16900. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  16901. * @param scale defines the scale vector3
  16902. * @param rotation defines the rotation quaternion
  16903. * @param translation defines the translation vector3
  16904. * @param result defines the target matrix
  16905. */
  16906. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  16907. /**
  16908. * Creates a new identity matrix
  16909. * @returns a new identity matrix
  16910. */
  16911. static Identity(): Matrix;
  16912. /**
  16913. * Creates a new identity matrix and stores the result in a given matrix
  16914. * @param result defines the target matrix
  16915. */
  16916. static IdentityToRef(result: Matrix): void;
  16917. /**
  16918. * Creates a new zero matrix
  16919. * @returns a new zero matrix
  16920. */
  16921. static Zero(): Matrix;
  16922. /**
  16923. * Creates a new rotation matrix for "angle" radians around the X axis
  16924. * @param angle defines the angle (in radians) to use
  16925. * @return the new matrix
  16926. */
  16927. static RotationX(angle: number): Matrix;
  16928. /**
  16929. * Creates a new matrix as the invert of a given matrix
  16930. * @param source defines the source matrix
  16931. * @returns the new matrix
  16932. */
  16933. static Invert(source: Matrix): Matrix;
  16934. /**
  16935. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  16936. * @param angle defines the angle (in radians) to use
  16937. * @param result defines the target matrix
  16938. */
  16939. static RotationXToRef(angle: number, result: Matrix): void;
  16940. /**
  16941. * Creates a new rotation matrix for "angle" radians around the Y axis
  16942. * @param angle defines the angle (in radians) to use
  16943. * @return the new matrix
  16944. */
  16945. static RotationY(angle: number): Matrix;
  16946. /**
  16947. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  16948. * @param angle defines the angle (in radians) to use
  16949. * @param result defines the target matrix
  16950. */
  16951. static RotationYToRef(angle: number, result: Matrix): void;
  16952. /**
  16953. * Creates a new rotation matrix for "angle" radians around the Z axis
  16954. * @param angle defines the angle (in radians) to use
  16955. * @return the new matrix
  16956. */
  16957. static RotationZ(angle: number): Matrix;
  16958. /**
  16959. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  16960. * @param angle defines the angle (in radians) to use
  16961. * @param result defines the target matrix
  16962. */
  16963. static RotationZToRef(angle: number, result: Matrix): void;
  16964. /**
  16965. * Creates a new rotation matrix for "angle" radians around the given axis
  16966. * @param axis defines the axis to use
  16967. * @param angle defines the angle (in radians) to use
  16968. * @return the new matrix
  16969. */
  16970. static RotationAxis(axis: Vector3, angle: number): Matrix;
  16971. /**
  16972. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  16973. * @param axis defines the axis to use
  16974. * @param angle defines the angle (in radians) to use
  16975. * @param result defines the target matrix
  16976. */
  16977. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  16978. /**
  16979. * Creates a rotation matrix
  16980. * @param yaw defines the yaw angle in radians (Y axis)
  16981. * @param pitch defines the pitch angle in radians (X axis)
  16982. * @param roll defines the roll angle in radians (X axis)
  16983. * @returns the new rotation matrix
  16984. */
  16985. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  16986. /**
  16987. * Creates a rotation matrix and stores it in a given matrix
  16988. * @param yaw defines the yaw angle in radians (Y axis)
  16989. * @param pitch defines the pitch angle in radians (X axis)
  16990. * @param roll defines the roll angle in radians (X axis)
  16991. * @param result defines the target matrix
  16992. */
  16993. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  16994. /**
  16995. * Creates a scaling matrix
  16996. * @param x defines the scale factor on X axis
  16997. * @param y defines the scale factor on Y axis
  16998. * @param z defines the scale factor on Z axis
  16999. * @returns the new matrix
  17000. */
  17001. static Scaling(x: number, y: number, z: number): Matrix;
  17002. /**
  17003. * Creates a scaling matrix and stores it in a given matrix
  17004. * @param x defines the scale factor on X axis
  17005. * @param y defines the scale factor on Y axis
  17006. * @param z defines the scale factor on Z axis
  17007. * @param result defines the target matrix
  17008. */
  17009. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  17010. /**
  17011. * Creates a translation matrix
  17012. * @param x defines the translation on X axis
  17013. * @param y defines the translation on Y axis
  17014. * @param z defines the translationon Z axis
  17015. * @returns the new matrix
  17016. */
  17017. static Translation(x: number, y: number, z: number): Matrix;
  17018. /**
  17019. * Creates a translation matrix and stores it in a given matrix
  17020. * @param x defines the translation on X axis
  17021. * @param y defines the translation on Y axis
  17022. * @param z defines the translationon Z axis
  17023. * @param result defines the target matrix
  17024. */
  17025. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  17026. /**
  17027. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17028. * @param startValue defines the start value
  17029. * @param endValue defines the end value
  17030. * @param gradient defines the gradient factor
  17031. * @returns the new matrix
  17032. */
  17033. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  17034. /**
  17035. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17036. * @param startValue defines the start value
  17037. * @param endValue defines the end value
  17038. * @param gradient defines the gradient factor
  17039. * @param result defines the Matrix object where to store data
  17040. */
  17041. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  17042. /**
  17043. * Builds a new matrix whose values are computed by:
  17044. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  17045. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  17046. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  17047. * @param startValue defines the first matrix
  17048. * @param endValue defines the second matrix
  17049. * @param gradient defines the gradient between the two matrices
  17050. * @returns the new matrix
  17051. */
  17052. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  17053. /**
  17054. * Update a matrix to values which are computed by:
  17055. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  17056. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  17057. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  17058. * @param startValue defines the first matrix
  17059. * @param endValue defines the second matrix
  17060. * @param gradient defines the gradient between the two matrices
  17061. * @param result defines the target matrix
  17062. */
  17063. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  17064. /**
  17065. * 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"
  17066. * This function works in left handed mode
  17067. * @param eye defines the final position of the entity
  17068. * @param target defines where the entity should look at
  17069. * @param up defines the up vector for the entity
  17070. * @returns the new matrix
  17071. */
  17072. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  17073. /**
  17074. * 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".
  17075. * This function works in left handed mode
  17076. * @param eye defines the final position of the entity
  17077. * @param target defines where the entity should look at
  17078. * @param up defines the up vector for the entity
  17079. * @param result defines the target matrix
  17080. */
  17081. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  17082. /**
  17083. * 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"
  17084. * This function works in right handed mode
  17085. * @param eye defines the final position of the entity
  17086. * @param target defines where the entity should look at
  17087. * @param up defines the up vector for the entity
  17088. * @returns the new matrix
  17089. */
  17090. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  17091. /**
  17092. * 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".
  17093. * This function works in right handed mode
  17094. * @param eye defines the final position of the entity
  17095. * @param target defines where the entity should look at
  17096. * @param up defines the up vector for the entity
  17097. * @param result defines the target matrix
  17098. */
  17099. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  17100. /**
  17101. * Create a left-handed orthographic projection matrix
  17102. * @param width defines the viewport width
  17103. * @param height defines the viewport height
  17104. * @param znear defines the near clip plane
  17105. * @param zfar defines the far clip plane
  17106. * @returns a new matrix as a left-handed orthographic projection matrix
  17107. */
  17108. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  17109. /**
  17110. * Store a left-handed orthographic projection to a given matrix
  17111. * @param width defines the viewport width
  17112. * @param height defines the viewport height
  17113. * @param znear defines the near clip plane
  17114. * @param zfar defines the far clip plane
  17115. * @param result defines the target matrix
  17116. */
  17117. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  17118. /**
  17119. * Create a left-handed orthographic projection matrix
  17120. * @param left defines the viewport left coordinate
  17121. * @param right defines the viewport right coordinate
  17122. * @param bottom defines the viewport bottom coordinate
  17123. * @param top defines the viewport top coordinate
  17124. * @param znear defines the near clip plane
  17125. * @param zfar defines the far clip plane
  17126. * @returns a new matrix as a left-handed orthographic projection matrix
  17127. */
  17128. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  17129. /**
  17130. * Stores a left-handed orthographic projection into a given matrix
  17131. * @param left defines the viewport left coordinate
  17132. * @param right defines the viewport right coordinate
  17133. * @param bottom defines the viewport bottom coordinate
  17134. * @param top defines the viewport top coordinate
  17135. * @param znear defines the near clip plane
  17136. * @param zfar defines the far clip plane
  17137. * @param result defines the target matrix
  17138. */
  17139. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  17140. /**
  17141. * Creates a right-handed orthographic projection matrix
  17142. * @param left defines the viewport left coordinate
  17143. * @param right defines the viewport right coordinate
  17144. * @param bottom defines the viewport bottom coordinate
  17145. * @param top defines the viewport top coordinate
  17146. * @param znear defines the near clip plane
  17147. * @param zfar defines the far clip plane
  17148. * @returns a new matrix as a right-handed orthographic projection matrix
  17149. */
  17150. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  17151. /**
  17152. * Stores a right-handed orthographic projection into a given matrix
  17153. * @param left defines the viewport left coordinate
  17154. * @param right defines the viewport right coordinate
  17155. * @param bottom defines the viewport bottom coordinate
  17156. * @param top defines the viewport top coordinate
  17157. * @param znear defines the near clip plane
  17158. * @param zfar defines the far clip plane
  17159. * @param result defines the target matrix
  17160. */
  17161. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  17162. /**
  17163. * Creates a left-handed perspective projection matrix
  17164. * @param width defines the viewport width
  17165. * @param height defines the viewport height
  17166. * @param znear defines the near clip plane
  17167. * @param zfar defines the far clip plane
  17168. * @returns a new matrix as a left-handed perspective projection matrix
  17169. */
  17170. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  17171. /**
  17172. * Creates a left-handed perspective projection matrix
  17173. * @param fov defines the horizontal field of view
  17174. * @param aspect defines the aspect ratio
  17175. * @param znear defines the near clip plane
  17176. * @param zfar defines the far clip plane
  17177. * @returns a new matrix as a left-handed perspective projection matrix
  17178. */
  17179. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  17180. /**
  17181. * Stores a left-handed perspective projection into a given matrix
  17182. * @param fov defines the horizontal field of view
  17183. * @param aspect defines the aspect ratio
  17184. * @param znear defines the near clip plane
  17185. * @param zfar defines the far clip plane
  17186. * @param result defines the target matrix
  17187. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  17188. */
  17189. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  17190. /**
  17191. * Creates a right-handed perspective projection matrix
  17192. * @param fov defines the horizontal field of view
  17193. * @param aspect defines the aspect ratio
  17194. * @param znear defines the near clip plane
  17195. * @param zfar defines the far clip plane
  17196. * @returns a new matrix as a right-handed perspective projection matrix
  17197. */
  17198. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  17199. /**
  17200. * Stores a right-handed perspective projection into a given matrix
  17201. * @param fov defines the horizontal field of view
  17202. * @param aspect defines the aspect ratio
  17203. * @param znear defines the near clip plane
  17204. * @param zfar defines the far clip plane
  17205. * @param result defines the target matrix
  17206. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  17207. */
  17208. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  17209. /**
  17210. * Stores a perspective projection for WebVR info a given matrix
  17211. * @param fov defines the field of view
  17212. * @param znear defines the near clip plane
  17213. * @param zfar defines the far clip plane
  17214. * @param result defines the target matrix
  17215. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  17216. */
  17217. static PerspectiveFovWebVRToRef(fov: {
  17218. upDegrees: number;
  17219. downDegrees: number;
  17220. leftDegrees: number;
  17221. rightDegrees: number;
  17222. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  17223. /**
  17224. * Computes a complete transformation matrix
  17225. * @param viewport defines the viewport to use
  17226. * @param world defines the world matrix
  17227. * @param view defines the view matrix
  17228. * @param projection defines the projection matrix
  17229. * @param zmin defines the near clip plane
  17230. * @param zmax defines the far clip plane
  17231. * @returns the transformation matrix
  17232. */
  17233. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  17234. /**
  17235. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  17236. * @param matrix defines the matrix to use
  17237. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  17238. */
  17239. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  17240. /**
  17241. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  17242. * @param matrix defines the matrix to use
  17243. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  17244. */
  17245. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  17246. /**
  17247. * Compute the transpose of a given matrix
  17248. * @param matrix defines the matrix to transpose
  17249. * @returns the new matrix
  17250. */
  17251. static Transpose(matrix: Matrix): Matrix;
  17252. /**
  17253. * Compute the transpose of a matrix and store it in a target matrix
  17254. * @param matrix defines the matrix to transpose
  17255. * @param result defines the target matrix
  17256. */
  17257. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  17258. /**
  17259. * Computes a reflection matrix from a plane
  17260. * @param plane defines the reflection plane
  17261. * @returns a new matrix
  17262. */
  17263. static Reflection(plane: Plane): Matrix;
  17264. /**
  17265. * Computes a reflection matrix from a plane
  17266. * @param plane defines the reflection plane
  17267. * @param result defines the target matrix
  17268. */
  17269. static ReflectionToRef(plane: Plane, result: Matrix): void;
  17270. /**
  17271. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  17272. * @param xaxis defines the value of the 1st axis
  17273. * @param yaxis defines the value of the 2nd axis
  17274. * @param zaxis defines the value of the 3rd axis
  17275. * @param result defines the target matrix
  17276. */
  17277. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  17278. /**
  17279. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  17280. * @param quat defines the quaternion to use
  17281. * @param result defines the target matrix
  17282. */
  17283. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  17284. }
  17285. class Plane {
  17286. normal: Vector3;
  17287. d: number;
  17288. /**
  17289. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  17290. */
  17291. constructor(a: number, b: number, c: number, d: number);
  17292. /**
  17293. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  17294. */
  17295. asArray(): number[];
  17296. /**
  17297. * Returns a new plane copied from the current Plane.
  17298. */
  17299. clone(): Plane;
  17300. /**
  17301. * Returns the string "Plane".
  17302. */
  17303. getClassName(): string;
  17304. /**
  17305. * Returns the Plane hash code.
  17306. */
  17307. getHashCode(): number;
  17308. /**
  17309. * Normalize the current Plane in place.
  17310. * Returns the updated Plane.
  17311. */
  17312. normalize(): Plane;
  17313. /**
  17314. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  17315. */
  17316. transform(transformation: Matrix): Plane;
  17317. /**
  17318. * Returns the dot product (float) of the point coordinates and the plane normal.
  17319. */
  17320. dotCoordinate(point: Vector3): number;
  17321. /**
  17322. * Updates the current Plane from the plane defined by the three given points.
  17323. * Returns the updated Plane.
  17324. */
  17325. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  17326. /**
  17327. * Boolean : True is the vector "direction" is the same side than the plane normal.
  17328. */
  17329. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  17330. /**
  17331. * Returns the signed distance (float) from the given point to the Plane.
  17332. */
  17333. signedDistanceTo(point: Vector3): number;
  17334. /**
  17335. * Returns a new Plane from the given array.
  17336. */
  17337. static FromArray(array: ArrayLike<number>): Plane;
  17338. /**
  17339. * Returns a new Plane defined by the three given points.
  17340. */
  17341. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  17342. /**
  17343. * Returns a new Plane the normal vector to this plane at the given origin point.
  17344. * Note : the vector "normal" is updated because normalized.
  17345. */
  17346. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  17347. /**
  17348. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  17349. */
  17350. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  17351. }
  17352. class Viewport {
  17353. x: number;
  17354. y: number;
  17355. width: number;
  17356. height: number;
  17357. /**
  17358. * Creates a Viewport object located at (x, y) and sized (width, height).
  17359. */
  17360. constructor(x: number, y: number, width: number, height: number);
  17361. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  17362. /**
  17363. * Returns a new Viewport copied from the current one.
  17364. */
  17365. clone(): Viewport;
  17366. }
  17367. class Frustum {
  17368. /**
  17369. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  17370. */
  17371. static GetPlanes(transform: Matrix): Plane[];
  17372. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17373. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17374. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17375. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17376. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17377. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17378. /**
  17379. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  17380. */
  17381. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  17382. }
  17383. /** Defines supported spaces */
  17384. enum Space {
  17385. /** Local (object) space */
  17386. LOCAL = 0,
  17387. /** World space */
  17388. WORLD = 1,
  17389. /** Bone space */
  17390. BONE = 2,
  17391. }
  17392. /** Defines the 3 main axes */
  17393. class Axis {
  17394. /** X axis */
  17395. static X: Vector3;
  17396. /** Y axis */
  17397. static Y: Vector3;
  17398. /** Z axis */
  17399. static Z: Vector3;
  17400. }
  17401. class BezierCurve {
  17402. /**
  17403. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  17404. */
  17405. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  17406. }
  17407. /**
  17408. * Defines potential orientation for back face culling
  17409. */
  17410. enum Orientation {
  17411. /**
  17412. * Clockwise
  17413. */
  17414. CW = 0,
  17415. /** Counter clockwise */
  17416. CCW = 1,
  17417. }
  17418. /**
  17419. * Defines angle representation
  17420. */
  17421. class Angle {
  17422. private _radians;
  17423. /**
  17424. * Creates an Angle object of "radians" radians (float).
  17425. */
  17426. constructor(radians: number);
  17427. /**
  17428. * Get value in degrees
  17429. * @returns the Angle value in degrees (float)
  17430. */
  17431. degrees(): number;
  17432. /**
  17433. * Get value in radians
  17434. * @returns the Angle value in radians (float)
  17435. */
  17436. radians(): number;
  17437. /**
  17438. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  17439. * @param a defines first vector
  17440. * @param b defines second vector
  17441. * @returns a new Angle
  17442. */
  17443. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  17444. /**
  17445. * Gets a new Angle object from the given float in radians
  17446. * @param radians defines the angle value in radians
  17447. * @returns a new Angle
  17448. */
  17449. static FromRadians(radians: number): Angle;
  17450. /**
  17451. * Gets a new Angle object from the given float in degrees
  17452. * @param degrees defines the angle value in degrees
  17453. * @returns a new Angle
  17454. */
  17455. static FromDegrees(degrees: number): Angle;
  17456. }
  17457. class Arc2 {
  17458. startPoint: Vector2;
  17459. midPoint: Vector2;
  17460. endPoint: Vector2;
  17461. centerPoint: Vector2;
  17462. radius: number;
  17463. angle: Angle;
  17464. startAngle: Angle;
  17465. orientation: Orientation;
  17466. /**
  17467. * Creates an Arc object from the three given points : start, middle and end.
  17468. */
  17469. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  17470. }
  17471. class Path2 {
  17472. private _points;
  17473. private _length;
  17474. closed: boolean;
  17475. /**
  17476. * Creates a Path2 object from the starting 2D coordinates x and y.
  17477. */
  17478. constructor(x: number, y: number);
  17479. /**
  17480. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  17481. * Returns the updated Path2.
  17482. */
  17483. addLineTo(x: number, y: number): Path2;
  17484. /**
  17485. * 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.
  17486. * Returns the updated Path2.
  17487. */
  17488. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  17489. /**
  17490. * Closes the Path2.
  17491. * Returns the Path2.
  17492. */
  17493. close(): Path2;
  17494. /**
  17495. * Returns the Path2 total length (float).
  17496. */
  17497. length(): number;
  17498. /**
  17499. * Returns the Path2 internal array of points.
  17500. */
  17501. getPoints(): Vector2[];
  17502. /**
  17503. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  17504. */
  17505. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  17506. /**
  17507. * Returns a new Path2 starting at the coordinates (x, y).
  17508. */
  17509. static StartingAt(x: number, y: number): Path2;
  17510. }
  17511. class Path3D {
  17512. path: Vector3[];
  17513. private _curve;
  17514. private _distances;
  17515. private _tangents;
  17516. private _normals;
  17517. private _binormals;
  17518. private _raw;
  17519. /**
  17520. * new Path3D(path, normal, raw)
  17521. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  17522. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  17523. * path : an array of Vector3, the curve axis of the Path3D
  17524. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  17525. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  17526. */
  17527. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  17528. /**
  17529. * Returns the Path3D array of successive Vector3 designing its curve.
  17530. */
  17531. getCurve(): Vector3[];
  17532. /**
  17533. * Returns an array populated with tangent vectors on each Path3D curve point.
  17534. */
  17535. getTangents(): Vector3[];
  17536. /**
  17537. * Returns an array populated with normal vectors on each Path3D curve point.
  17538. */
  17539. getNormals(): Vector3[];
  17540. /**
  17541. * Returns an array populated with binormal vectors on each Path3D curve point.
  17542. */
  17543. getBinormals(): Vector3[];
  17544. /**
  17545. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  17546. */
  17547. getDistances(): number[];
  17548. /**
  17549. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  17550. * Returns the same object updated.
  17551. */
  17552. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  17553. private _compute(firstNormal);
  17554. private _getFirstNonNullVector(index);
  17555. private _getLastNonNullVector(index);
  17556. private _normalVector(v0, vt, va);
  17557. }
  17558. class Curve3 {
  17559. private _points;
  17560. private _length;
  17561. /**
  17562. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  17563. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  17564. * @param v1 (Vector3) the control point
  17565. * @param v2 (Vector3) the end point of the Quadratic Bezier
  17566. * @param nbPoints (integer) the wanted number of points in the curve
  17567. */
  17568. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  17569. /**
  17570. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  17571. * @param v0 (Vector3) the origin point of the Cubic Bezier
  17572. * @param v1 (Vector3) the first control point
  17573. * @param v2 (Vector3) the second control point
  17574. * @param v3 (Vector3) the end point of the Cubic Bezier
  17575. * @param nbPoints (integer) the wanted number of points in the curve
  17576. */
  17577. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  17578. /**
  17579. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  17580. * @param p1 (Vector3) the origin point of the Hermite Spline
  17581. * @param t1 (Vector3) the tangent vector at the origin point
  17582. * @param p2 (Vector3) the end point of the Hermite Spline
  17583. * @param t2 (Vector3) the tangent vector at the end point
  17584. * @param nbPoints (integer) the wanted number of points in the curve
  17585. */
  17586. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  17587. /**
  17588. * Returns a Curve3 object along a CatmullRom Spline curve :
  17589. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  17590. * @param nbPoints (integer) the wanted number of points between each curve control points
  17591. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  17592. */
  17593. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  17594. /**
  17595. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  17596. * A Curve3 is designed from a series of successive Vector3.
  17597. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  17598. */
  17599. constructor(points: Vector3[]);
  17600. /**
  17601. * Returns the Curve3 stored array of successive Vector3
  17602. */
  17603. getPoints(): Vector3[];
  17604. /**
  17605. * Returns the computed length (float) of the curve.
  17606. */
  17607. length(): number;
  17608. /**
  17609. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  17610. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  17611. * curveA and curveB keep unchanged.
  17612. */
  17613. continue(curve: Curve3): Curve3;
  17614. private _computeLength(path);
  17615. }
  17616. class PositionNormalVertex {
  17617. position: Vector3;
  17618. normal: Vector3;
  17619. constructor(position?: Vector3, normal?: Vector3);
  17620. clone(): PositionNormalVertex;
  17621. }
  17622. class PositionNormalTextureVertex {
  17623. position: Vector3;
  17624. normal: Vector3;
  17625. uv: Vector2;
  17626. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  17627. clone(): PositionNormalTextureVertex;
  17628. }
  17629. class Tmp {
  17630. static Color3: Color3[];
  17631. static Vector2: Vector2[];
  17632. static Vector3: Vector3[];
  17633. static Vector4: Vector4[];
  17634. static Quaternion: Quaternion[];
  17635. static Matrix: Matrix[];
  17636. }
  17637. }
  17638. declare module BABYLON {
  17639. class SphericalPolynomial {
  17640. x: Vector3;
  17641. y: Vector3;
  17642. z: Vector3;
  17643. xx: Vector3;
  17644. yy: Vector3;
  17645. zz: Vector3;
  17646. xy: Vector3;
  17647. yz: Vector3;
  17648. zx: Vector3;
  17649. addAmbient(color: Color3): void;
  17650. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  17651. scale(scale: number): void;
  17652. }
  17653. class SphericalHarmonics {
  17654. L00: Vector3;
  17655. L1_1: Vector3;
  17656. L10: Vector3;
  17657. L11: Vector3;
  17658. L2_2: Vector3;
  17659. L2_1: Vector3;
  17660. L20: Vector3;
  17661. L21: Vector3;
  17662. L22: Vector3;
  17663. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  17664. scale(scale: number): void;
  17665. convertIncidentRadianceToIrradiance(): void;
  17666. convertIrradianceToLambertianRadiance(): void;
  17667. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  17668. }
  17669. }
  17670. declare module BABYLON {
  17671. /**
  17672. * Class used to store all common mesh properties
  17673. */
  17674. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  17675. /** No occlusion */
  17676. static OCCLUSION_TYPE_NONE: number;
  17677. /** Occlusion set to optimisitic */
  17678. static OCCLUSION_TYPE_OPTIMISTIC: number;
  17679. /** Occlusion set to strict */
  17680. static OCCLUSION_TYPE_STRICT: number;
  17681. /** Use an accurante occlusion algorithm */
  17682. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  17683. /** Use a conservative occlusion algorithm */
  17684. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  17685. /**
  17686. * No billboard
  17687. */
  17688. static readonly BILLBOARDMODE_NONE: number;
  17689. /** Billboard on X axis */
  17690. static readonly BILLBOARDMODE_X: number;
  17691. /** Billboard on Y axis */
  17692. static readonly BILLBOARDMODE_Y: number;
  17693. /** Billboard on Z axis */
  17694. static readonly BILLBOARDMODE_Z: number;
  17695. /** Billboard on all axes */
  17696. static readonly BILLBOARDMODE_ALL: number;
  17697. private _facetPositions;
  17698. private _facetNormals;
  17699. private _facetPartitioning;
  17700. private _facetNb;
  17701. private _partitioningSubdivisions;
  17702. private _partitioningBBoxRatio;
  17703. private _facetDataEnabled;
  17704. private _facetParameters;
  17705. private _bbSize;
  17706. private _subDiv;
  17707. private _facetDepthSort;
  17708. private _facetDepthSortEnabled;
  17709. private _depthSortedIndices;
  17710. private _depthSortedFacets;
  17711. private _facetDepthSortFunction;
  17712. private _facetDepthSortFrom;
  17713. private _facetDepthSortOrigin;
  17714. private _invertedMatrix;
  17715. /**
  17716. * Gets the number of facets in the mesh
  17717. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  17718. */
  17719. readonly facetNb: number;
  17720. /**
  17721. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  17722. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  17723. */
  17724. partitioningSubdivisions: number;
  17725. /**
  17726. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  17727. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  17728. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  17729. */
  17730. partitioningBBoxRatio: number;
  17731. /**
  17732. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  17733. * Works only for updatable meshes.
  17734. * Doesn't work with multi-materials
  17735. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  17736. */
  17737. mustDepthSortFacets: boolean;
  17738. /**
  17739. * The location (Vector3) where the facet depth sort must be computed from.
  17740. * By default, the active camera position.
  17741. * Used only when facet depth sort is enabled
  17742. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  17743. */
  17744. facetDepthSortFrom: Vector3;
  17745. /**
  17746. * gets a boolean indicating if facetData is enabled
  17747. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  17748. */
  17749. readonly isFacetDataEnabled: boolean;
  17750. /** @hidden */
  17751. _updateNonUniformScalingState(value: boolean): boolean;
  17752. /**
  17753. * An event triggered when this mesh collides with another one
  17754. */
  17755. onCollideObservable: Observable<AbstractMesh>;
  17756. private _onCollideObserver;
  17757. /** Set a function to call when this mesh collides with another one */
  17758. onCollide: () => void;
  17759. /**
  17760. * An event triggered when the collision's position changes
  17761. */
  17762. onCollisionPositionChangeObservable: Observable<Vector3>;
  17763. private _onCollisionPositionChangeObserver;
  17764. /** Set a function to call when the collision's position changes */
  17765. onCollisionPositionChange: () => void;
  17766. /**
  17767. * An event triggered when material is changed
  17768. */
  17769. onMaterialChangedObservable: Observable<AbstractMesh>;
  17770. /**
  17771. * Gets or sets the orientation for POV movement & rotation
  17772. */
  17773. definedFacingForward: boolean;
  17774. /**
  17775. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  17776. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  17777. * * 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.
  17778. * @see http://doc.babylonjs.com/features/occlusionquery
  17779. */
  17780. occlusionQueryAlgorithmType: number;
  17781. /**
  17782. * 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:
  17783. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  17784. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  17785. * * 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.
  17786. * @see http://doc.babylonjs.com/features/occlusionquery
  17787. */
  17788. occlusionType: number;
  17789. /**
  17790. * 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.
  17791. * The default value is -1 which means don't break the query and wait till the result
  17792. * @see http://doc.babylonjs.com/features/occlusionquery
  17793. */
  17794. occlusionRetryCount: number;
  17795. private _occlusionInternalRetryCounter;
  17796. protected _isOccluded: boolean;
  17797. /**
  17798. * 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
  17799. * @see http://doc.babylonjs.com/features/occlusionquery
  17800. */
  17801. isOccluded: boolean;
  17802. private _isOcclusionQueryInProgress;
  17803. /**
  17804. * Flag to check the progress status of the query
  17805. * @see http://doc.babylonjs.com/features/occlusionquery
  17806. */
  17807. readonly isOcclusionQueryInProgress: boolean;
  17808. private _occlusionQuery;
  17809. private _visibility;
  17810. /**
  17811. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  17812. */
  17813. /**
  17814. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  17815. */
  17816. visibility: number;
  17817. /** Gets or sets the alpha index used to sort transparent meshes
  17818. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  17819. */
  17820. alphaIndex: number;
  17821. /**
  17822. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  17823. */
  17824. isVisible: boolean;
  17825. /**
  17826. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  17827. */
  17828. isPickable: boolean;
  17829. /**
  17830. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  17831. */
  17832. showBoundingBox: boolean;
  17833. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  17834. showSubMeshesBoundingBox: boolean;
  17835. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  17836. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  17837. */
  17838. isBlocker: boolean;
  17839. /**
  17840. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  17841. */
  17842. enablePointerMoveEvents: boolean;
  17843. /**
  17844. * Specifies the rendering group id for this mesh (0 by default)
  17845. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  17846. */
  17847. renderingGroupId: number;
  17848. private _material;
  17849. /** Gets or sets current material */
  17850. material: Nullable<Material>;
  17851. private _receiveShadows;
  17852. /**
  17853. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  17854. * @see http://doc.babylonjs.com/babylon101/shadows
  17855. */
  17856. receiveShadows: boolean;
  17857. /**
  17858. * Gets or sets a boolean indicating if the outline must be rendered as well
  17859. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  17860. */
  17861. renderOutline: boolean;
  17862. /** Defines color to use when rendering outline */
  17863. outlineColor: Color3;
  17864. /** Define width to use when rendering outline */
  17865. outlineWidth: number;
  17866. /**
  17867. * Gets or sets a boolean indicating if the overlay must be rendered as well
  17868. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  17869. */
  17870. renderOverlay: boolean;
  17871. /** Defines color to use when rendering overlay */
  17872. overlayColor: Color3;
  17873. /** Defines alpha to use when rendering overlay */
  17874. overlayAlpha: number;
  17875. private _hasVertexAlpha;
  17876. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  17877. hasVertexAlpha: boolean;
  17878. private _useVertexColors;
  17879. /** 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) */
  17880. useVertexColors: boolean;
  17881. private _computeBonesUsingShaders;
  17882. /**
  17883. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  17884. */
  17885. computeBonesUsingShaders: boolean;
  17886. private _numBoneInfluencers;
  17887. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  17888. numBoneInfluencers: number;
  17889. private _applyFog;
  17890. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  17891. applyFog: boolean;
  17892. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  17893. useOctreeForRenderingSelection: boolean;
  17894. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  17895. useOctreeForPicking: boolean;
  17896. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  17897. useOctreeForCollisions: boolean;
  17898. private _layerMask;
  17899. /**
  17900. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  17901. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  17902. */
  17903. layerMask: number;
  17904. /**
  17905. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  17906. */
  17907. alwaysSelectAsActiveMesh: boolean;
  17908. /**
  17909. * Gets or sets the current action manager
  17910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17911. */
  17912. actionManager: Nullable<ActionManager>;
  17913. /**
  17914. * Gets or sets impostor used for physic simulation
  17915. * @see http://doc.babylonjs.com/features/physics_engine
  17916. */
  17917. physicsImpostor: Nullable<PhysicsImpostor>;
  17918. private _checkCollisions;
  17919. private _collisionMask;
  17920. private _collisionGroup;
  17921. /**
  17922. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  17923. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  17924. */
  17925. ellipsoid: Vector3;
  17926. /**
  17927. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  17928. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  17929. */
  17930. ellipsoidOffset: Vector3;
  17931. private _collider;
  17932. private _oldPositionForCollisions;
  17933. private _diffPositionForCollisions;
  17934. /**
  17935. * Gets or sets a collision mask used to mask collisions (default is -1).
  17936. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  17937. */
  17938. collisionMask: number;
  17939. /**
  17940. * Gets or sets the current collision group mask (-1 by default).
  17941. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  17942. */
  17943. collisionGroup: number;
  17944. /**
  17945. * Defines edge width used when edgesRenderer is enabled
  17946. * @see https://www.babylonjs-playground.com/#10OJSG#13
  17947. */
  17948. edgesWidth: number;
  17949. /**
  17950. * Defines edge color used when edgesRenderer is enabled
  17951. * @see https://www.babylonjs-playground.com/#10OJSG#13
  17952. */
  17953. edgesColor: Color4;
  17954. /** @hidden */
  17955. _edgesRenderer: Nullable<EdgesRenderer>;
  17956. private _collisionsTransformMatrix;
  17957. private _collisionsScalingMatrix;
  17958. /** @hidden */
  17959. _masterMesh: Nullable<AbstractMesh>;
  17960. /** @hidden */
  17961. _boundingInfo: Nullable<BoundingInfo>;
  17962. /** @hidden */
  17963. _renderId: number;
  17964. /**
  17965. * Gets or sets the list of subMeshes
  17966. * @see http://doc.babylonjs.com/how_to/multi_materials
  17967. */
  17968. subMeshes: SubMesh[];
  17969. /** @hidden */
  17970. _submeshesOctree: Octree<SubMesh>;
  17971. /** @hidden */
  17972. _intersectionsInProgress: AbstractMesh[];
  17973. /** @hidden */
  17974. _unIndexed: boolean;
  17975. /** @hidden */
  17976. _lightSources: Light[];
  17977. /** @hidden */
  17978. readonly _positions: Nullable<Vector3[]>;
  17979. /** @hidden */
  17980. _waitingActions: any;
  17981. /** @hidden */
  17982. _waitingFreezeWorldMatrix: Nullable<boolean>;
  17983. private _skeleton;
  17984. /** @hidden */
  17985. _bonesTransformMatrices: Nullable<Float32Array>;
  17986. /**
  17987. * Gets or sets a skeleton to apply skining transformations
  17988. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  17989. */
  17990. skeleton: Nullable<Skeleton>;
  17991. /**
  17992. * Creates a new AbstractMesh
  17993. * @param name defines the name of the mesh
  17994. * @param scene defines the hosting scene
  17995. */
  17996. constructor(name: string, scene?: Nullable<Scene>);
  17997. /**
  17998. * Returns the string "AbstractMesh"
  17999. * @returns "AbstractMesh"
  18000. */
  18001. getClassName(): string;
  18002. /**
  18003. * Gets a string representation of the current mesh
  18004. * @param fullDetails defines a boolean indicating if full details must be included
  18005. * @returns a string representation of the current mesh
  18006. */
  18007. toString(fullDetails?: boolean): string;
  18008. /** @hidden */
  18009. _rebuild(): void;
  18010. /** @hidden */
  18011. _resyncLightSources(): void;
  18012. /** @hidden */
  18013. _resyncLighSource(light: Light): void;
  18014. /** @hidden */
  18015. _unBindEffect(): void;
  18016. /** @hidden */
  18017. _removeLightSource(light: Light): void;
  18018. private _markSubMeshesAsDirty(func);
  18019. /** @hidden */
  18020. _markSubMeshesAsLightDirty(): void;
  18021. /** @hidden */
  18022. _markSubMeshesAsAttributesDirty(): void;
  18023. /** @hidden */
  18024. _markSubMeshesAsMiscDirty(): void;
  18025. /**
  18026. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  18027. */
  18028. scaling: Vector3;
  18029. /**
  18030. * Disables the mesh edge rendering mode
  18031. * @returns the currentAbstractMesh
  18032. */
  18033. disableEdgesRendering(): AbstractMesh;
  18034. /**
  18035. * Enables the edge rendering mode on the mesh.
  18036. * This mode makes the mesh edges visible
  18037. * @param epsilon defines the maximal distance between two angles to detect a face
  18038. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  18039. * @returns the currentAbstractMesh
  18040. * @see https://www.babylonjs-playground.com/#19O9TU#0
  18041. */
  18042. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  18043. /**
  18044. * Returns true if the mesh is blocked. Implemented by child classes
  18045. */
  18046. readonly isBlocked: boolean;
  18047. /**
  18048. * Returns the mesh itself by default. Implemented by child classes
  18049. * @param camera defines the camera to use to pick the right LOD level
  18050. * @returns the currentAbstractMesh
  18051. */
  18052. getLOD(camera: Camera): AbstractMesh;
  18053. /**
  18054. * Returns 0 by default. Implemented by child classes
  18055. * @returns an integer
  18056. */
  18057. getTotalVertices(): number;
  18058. /**
  18059. * Returns null by default. Implemented by child classes
  18060. * @returns null
  18061. */
  18062. getIndices(): Nullable<IndicesArray>;
  18063. /**
  18064. * Returns the array of the requested vertex data kind. Implemented by child classes
  18065. * @param kind defines the vertex data kind to use
  18066. * @returns null
  18067. */
  18068. getVerticesData(kind: string): Nullable<FloatArray>;
  18069. /**
  18070. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18071. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18072. * Note that a new underlying VertexBuffer object is created each call.
  18073. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18074. * @param kind defines vertex data kind:
  18075. * * BABYLON.VertexBuffer.PositionKind
  18076. * * BABYLON.VertexBuffer.UVKind
  18077. * * BABYLON.VertexBuffer.UV2Kind
  18078. * * BABYLON.VertexBuffer.UV3Kind
  18079. * * BABYLON.VertexBuffer.UV4Kind
  18080. * * BABYLON.VertexBuffer.UV5Kind
  18081. * * BABYLON.VertexBuffer.UV6Kind
  18082. * * BABYLON.VertexBuffer.ColorKind
  18083. * * BABYLON.VertexBuffer.MatricesIndicesKind
  18084. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  18085. * * BABYLON.VertexBuffer.MatricesWeightsKind
  18086. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  18087. * @param data defines the data source
  18088. * @param updatable defines if the data must be flagged as updatable (or static)
  18089. * @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
  18090. * @returns the current mesh
  18091. */
  18092. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18093. /**
  18094. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18095. * If the mesh has no geometry, it is simply returned as it is.
  18096. * @param kind defines vertex data kind:
  18097. * * BABYLON.VertexBuffer.PositionKind
  18098. * * BABYLON.VertexBuffer.UVKind
  18099. * * BABYLON.VertexBuffer.UV2Kind
  18100. * * BABYLON.VertexBuffer.UV3Kind
  18101. * * BABYLON.VertexBuffer.UV4Kind
  18102. * * BABYLON.VertexBuffer.UV5Kind
  18103. * * BABYLON.VertexBuffer.UV6Kind
  18104. * * BABYLON.VertexBuffer.ColorKind
  18105. * * BABYLON.VertexBuffer.MatricesIndicesKind
  18106. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  18107. * * BABYLON.VertexBuffer.MatricesWeightsKind
  18108. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  18109. * @param data defines the data source
  18110. * @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
  18111. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  18112. * @returns the current mesh
  18113. */
  18114. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  18115. /**
  18116. * Sets the mesh indices,
  18117. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18118. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  18119. * @param totalVertices Defines the total number of vertices
  18120. * @returns the current mesh
  18121. */
  18122. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  18123. /**
  18124. * Gets a boolean indicating if specific vertex data is present
  18125. * @param kind defines the vertex data kind to use
  18126. * @returns true is data kind is present
  18127. */
  18128. isVerticesDataPresent(kind: string): boolean;
  18129. /**
  18130. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  18131. * @returns a BoundingInfo
  18132. */
  18133. getBoundingInfo(): BoundingInfo;
  18134. /**
  18135. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  18136. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  18137. * @returns the current mesh
  18138. */
  18139. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  18140. /**
  18141. * Overwrite the current bounding info
  18142. * @param boundingInfo defines the new bounding info
  18143. * @returns the current mesh
  18144. */
  18145. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  18146. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  18147. readonly useBones: boolean;
  18148. /** @hidden */
  18149. _preActivate(): void;
  18150. /** @hidden */
  18151. _preActivateForIntermediateRendering(renderId: number): void;
  18152. /** @hidden */
  18153. _activate(renderId: number): void;
  18154. /**
  18155. * Gets the current world matrix
  18156. * @returns a Matrix
  18157. */
  18158. getWorldMatrix(): Matrix;
  18159. /** @hidden */
  18160. _getWorldMatrixDeterminant(): number;
  18161. /**
  18162. * Perform relative position change from the point of view of behind the front of the mesh.
  18163. * This is performed taking into account the meshes current rotation, so you do not have to care.
  18164. * Supports definition of mesh facing forward or backward
  18165. * @param amountRight defines the distance on the right axis
  18166. * @param amountUp defines the distance on the up axis
  18167. * @param amountForward defines the distance on the forward axis
  18168. * @returns the current mesh
  18169. */
  18170. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  18171. /**
  18172. * Calculate relative position change from the point of view of behind the front of the mesh.
  18173. * This is performed taking into account the meshes current rotation, so you do not have to care.
  18174. * Supports definition of mesh facing forward or backward
  18175. * @param amountRight defines the distance on the right axis
  18176. * @param amountUp defines the distance on the up axis
  18177. * @param amountForward defines the distance on the forward axis
  18178. * @returns the new displacement vector
  18179. */
  18180. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  18181. /**
  18182. * Perform relative rotation change from the point of view of behind the front of the mesh.
  18183. * Supports definition of mesh facing forward or backward
  18184. * @param flipBack defines the flip
  18185. * @param twirlClockwise defines the twirl
  18186. * @param tiltRight defines the tilt
  18187. * @returns the current mesh
  18188. */
  18189. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  18190. /**
  18191. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  18192. * Supports definition of mesh facing forward or backward.
  18193. * @param flipBack defines the flip
  18194. * @param twirlClockwise defines the twirl
  18195. * @param tiltRight defines the tilt
  18196. * @returns the new rotation vector
  18197. */
  18198. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  18199. /**
  18200. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  18201. * @param includeDescendants Include bounding info from descendants as well (true by default)
  18202. * @returns the new bounding vectors
  18203. */
  18204. getHierarchyBoundingVectors(includeDescendants?: boolean): {
  18205. min: Vector3;
  18206. max: Vector3;
  18207. };
  18208. /** @hidden */
  18209. _updateBoundingInfo(): AbstractMesh;
  18210. /** @hidden */
  18211. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  18212. /** @hidden */
  18213. protected _afterComputeWorldMatrix(): void;
  18214. /**
  18215. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  18216. * A mesh is in the frustum if its bounding box intersects the frustum
  18217. * @param frustumPlanes defines the frustum to test
  18218. * @returns true if the mesh is in the frustum planes
  18219. */
  18220. isInFrustum(frustumPlanes: Plane[]): boolean;
  18221. /**
  18222. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  18223. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  18224. * @param frustumPlanes defines the frustum to test
  18225. * @returns true if the mesh is completely in the frustum planes
  18226. */
  18227. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  18228. /**
  18229. * True if the mesh intersects another mesh or a SolidParticle object
  18230. * @param mesh defines a target mesh or SolidParticle to test
  18231. * @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)
  18232. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  18233. * @returns true if there is an intersection
  18234. */
  18235. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  18236. /**
  18237. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  18238. * @param point defines the point to test
  18239. * @returns true if there is an intersection
  18240. */
  18241. intersectsPoint(point: Vector3): boolean;
  18242. /**
  18243. * Gets the current physics impostor
  18244. * @see http://doc.babylonjs.com/features/physics_engine
  18245. * @returns a physics impostor or null
  18246. */
  18247. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  18248. /**
  18249. * Gets the position of the current mesh in camera space
  18250. * @param camera defines the camera to use
  18251. * @returns a position
  18252. */
  18253. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  18254. /**
  18255. * Returns the distance from the mesh to the active camera
  18256. * @param camera defines the camera to use
  18257. * @returns the distance
  18258. */
  18259. getDistanceToCamera(camera?: Nullable<Camera>): number;
  18260. /**
  18261. * Apply a physic impulse to the mesh
  18262. * @param force defines the force to apply
  18263. * @param contactPoint defines where to apply the force
  18264. * @returns the current mesh
  18265. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18266. */
  18267. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  18268. /**
  18269. * Creates a physic joint between two meshes
  18270. * @param otherMesh defines the other mesh to use
  18271. * @param pivot1 defines the pivot to use on this mesh
  18272. * @param pivot2 defines the pivot to use on the other mesh
  18273. * @param options defines additional options (can be plugin dependent)
  18274. * @returns the current mesh
  18275. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  18276. */
  18277. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  18278. /**
  18279. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  18280. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18281. */
  18282. checkCollisions: boolean;
  18283. /**
  18284. * Gets Collider object used to compute collisions (not physics)
  18285. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18286. */
  18287. readonly collider: Collider;
  18288. /**
  18289. * Move the mesh using collision engine
  18290. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18291. * @param displacement defines the requested displacement vector
  18292. * @returns the current mesh
  18293. */
  18294. moveWithCollisions(displacement: Vector3): AbstractMesh;
  18295. private _onCollisionPositionChange;
  18296. /**
  18297. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  18298. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18299. * @param maxCapacity defines the maximum size of each block (64 by default)
  18300. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  18301. * @returns the new octree
  18302. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  18303. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  18304. */
  18305. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  18306. /** @hidden */
  18307. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  18308. /** @hidden */
  18309. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  18310. /** @hidden */
  18311. _checkCollision(collider: Collider): AbstractMesh;
  18312. /** @hidden */
  18313. _generatePointsArray(): boolean;
  18314. /**
  18315. * Checks if the passed Ray intersects with the mesh
  18316. * @param ray defines the ray to use
  18317. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  18318. * @returns the picking info
  18319. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  18320. */
  18321. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  18322. /**
  18323. * Clones the current mesh
  18324. * @param name defines the mesh name
  18325. * @param newParent defines the new mesh parent
  18326. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  18327. * @returns the new mesh
  18328. */
  18329. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18330. /**
  18331. * Disposes all the submeshes of the current meshnp
  18332. * @returns the current mesh
  18333. */
  18334. releaseSubMeshes(): AbstractMesh;
  18335. /**
  18336. * Releases resources associated with this abstract mesh.
  18337. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18338. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18339. */
  18340. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18341. /**
  18342. * Adds the passed mesh as a child to the current mesh
  18343. * @param mesh defines the child mesh
  18344. * @returns the current mesh
  18345. */
  18346. addChild(mesh: AbstractMesh): AbstractMesh;
  18347. /**
  18348. * Removes the passed mesh from the current mesh children list
  18349. * @param mesh defines the child mesh
  18350. * @returns the current mesh
  18351. */
  18352. removeChild(mesh: AbstractMesh): AbstractMesh;
  18353. /** @hidden */
  18354. private _initFacetData();
  18355. /**
  18356. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  18357. * This method can be called within the render loop.
  18358. * 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
  18359. * @returns the current mesh
  18360. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18361. */
  18362. updateFacetData(): AbstractMesh;
  18363. /**
  18364. * Returns the facetLocalNormals array.
  18365. * The normals are expressed in the mesh local spac
  18366. * @returns an array of Vector3
  18367. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18368. */
  18369. getFacetLocalNormals(): Vector3[];
  18370. /**
  18371. * Returns the facetLocalPositions array.
  18372. * The facet positions are expressed in the mesh local space
  18373. * @returns an array of Vector3
  18374. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18375. */
  18376. getFacetLocalPositions(): Vector3[];
  18377. /**
  18378. * Returns the facetLocalPartioning array
  18379. * @returns an array of array of numbers
  18380. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18381. */
  18382. getFacetLocalPartitioning(): number[][];
  18383. /**
  18384. * Returns the i-th facet position in the world system.
  18385. * This method allocates a new Vector3 per call
  18386. * @param i defines the facet index
  18387. * @returns a new Vector3
  18388. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18389. */
  18390. getFacetPosition(i: number): Vector3;
  18391. /**
  18392. * Sets the reference Vector3 with the i-th facet position in the world system
  18393. * @param i defines the facet index
  18394. * @param ref defines the target vector
  18395. * @returns the current mesh
  18396. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18397. */
  18398. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  18399. /**
  18400. * Returns the i-th facet normal in the world system.
  18401. * This method allocates a new Vector3 per call
  18402. * @param i defines the facet index
  18403. * @returns a new Vector3
  18404. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18405. */
  18406. getFacetNormal(i: number): Vector3;
  18407. /**
  18408. * Sets the reference Vector3 with the i-th facet normal in the world system
  18409. * @param i defines the facet index
  18410. * @param ref defines the target vector
  18411. * @returns the current mesh
  18412. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18413. */
  18414. getFacetNormalToRef(i: number, ref: Vector3): this;
  18415. /**
  18416. * 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)
  18417. * @param x defines x coordinate
  18418. * @param y defines y coordinate
  18419. * @param z defines z coordinate
  18420. * @returns the array of facet indexes
  18421. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18422. */
  18423. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  18424. /**
  18425. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  18426. * @param projected sets as the (x,y,z) world projection on the facet
  18427. * @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
  18428. * @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
  18429. * @param x defines x coordinate
  18430. * @param y defines y coordinate
  18431. * @param z defines z coordinate
  18432. * @returns the face index if found (or null instead)
  18433. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18434. */
  18435. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  18436. /**
  18437. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  18438. * @param projected sets as the (x,y,z) local projection on the facet
  18439. * @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
  18440. * @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
  18441. * @param x defines x coordinate
  18442. * @param y defines y coordinate
  18443. * @param z defines z coordinate
  18444. * @returns the face index if found (or null instead)
  18445. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18446. */
  18447. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  18448. /**
  18449. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  18450. * @returns the parameters
  18451. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18452. */
  18453. getFacetDataParameters(): any;
  18454. /**
  18455. * Disables the feature FacetData and frees the related memory
  18456. * @returns the current mesh
  18457. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18458. */
  18459. disableFacetData(): AbstractMesh;
  18460. /**
  18461. * Updates the AbstractMesh indices array
  18462. * @param indices defines the data source
  18463. * @returns the current mesh
  18464. */
  18465. updateIndices(indices: IndicesArray): AbstractMesh;
  18466. /**
  18467. * Creates new normals data for the mesh
  18468. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  18469. * @returns the current mesh
  18470. */
  18471. createNormals(updatable: boolean): AbstractMesh;
  18472. /**
  18473. * Align the mesh with a normal
  18474. * @param normal defines the normal to use
  18475. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  18476. * @returns the current mesh
  18477. */
  18478. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  18479. /** @hidden */
  18480. protected _checkOcclusionQuery(): void;
  18481. }
  18482. }
  18483. declare module BABYLON {
  18484. class Buffer {
  18485. private _engine;
  18486. private _buffer;
  18487. private _data;
  18488. private _updatable;
  18489. private _instanced;
  18490. /**
  18491. * Gets the byte stride.
  18492. */
  18493. readonly byteStride: number;
  18494. /**
  18495. * Constructor
  18496. * @param engine the engine
  18497. * @param data the data to use for this buffer
  18498. * @param updatable whether the data is updatable
  18499. * @param stride the stride (optional)
  18500. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  18501. * @param instanced whether the buffer is instanced (optional)
  18502. * @param useBytes set to true if the stride in in bytes (optional)
  18503. */
  18504. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  18505. /**
  18506. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  18507. * @param kind defines the vertex buffer kind (position, normal, etc.)
  18508. * @param offset defines offset in the buffer (0 by default)
  18509. * @param size defines the size in floats of attributes (position is 3 for instance)
  18510. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  18511. * @param instanced defines if the vertex buffer contains indexed data
  18512. * @param useBytes defines if the offset and stride are in bytes
  18513. * @returns the new vertex buffer
  18514. */
  18515. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  18516. isUpdatable(): boolean;
  18517. getData(): Nullable<DataArray>;
  18518. getBuffer(): Nullable<WebGLBuffer>;
  18519. /**
  18520. * Gets the stride in float32 units (i.e. byte stride / 4).
  18521. * May not be an integer if the byte stride is not divisible by 4.
  18522. * DEPRECATED. Use byteStride instead.
  18523. * @returns the stride in float32 units
  18524. */
  18525. getStrideSize(): number;
  18526. create(data?: Nullable<DataArray>): void;
  18527. _rebuild(): void;
  18528. update(data: DataArray): void;
  18529. /**
  18530. * Updates the data directly.
  18531. * @param data the new data
  18532. * @param offset the new offset
  18533. * @param vertexCount the vertex count (optional)
  18534. * @param useBytes set to true if the offset is in bytes
  18535. */
  18536. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  18537. dispose(): void;
  18538. }
  18539. }
  18540. declare module BABYLON {
  18541. class CSG {
  18542. private polygons;
  18543. matrix: Matrix;
  18544. position: Vector3;
  18545. rotation: Vector3;
  18546. rotationQuaternion: Nullable<Quaternion>;
  18547. scaling: Vector3;
  18548. static FromMesh(mesh: Mesh): CSG;
  18549. private static FromPolygons(polygons);
  18550. clone(): CSG;
  18551. union(csg: CSG): CSG;
  18552. unionInPlace(csg: CSG): void;
  18553. subtract(csg: CSG): CSG;
  18554. subtractInPlace(csg: CSG): void;
  18555. intersect(csg: CSG): CSG;
  18556. intersectInPlace(csg: CSG): void;
  18557. inverse(): CSG;
  18558. inverseInPlace(): void;
  18559. copyTransformAttributes(csg: CSG): CSG;
  18560. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  18561. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  18562. }
  18563. }
  18564. declare module BABYLON {
  18565. /**
  18566. * Class used to store geometry data (vertex buffers + index buffer)
  18567. */
  18568. class Geometry implements IGetSetVerticesData {
  18569. /**
  18570. * Gets or sets the unique ID of the geometry
  18571. */
  18572. id: string;
  18573. /**
  18574. * Gets the delay loading state of the geometry (none by default which means not delayed)
  18575. */
  18576. delayLoadState: number;
  18577. /**
  18578. * Gets the file containing the data to load when running in delay load state
  18579. */
  18580. delayLoadingFile: Nullable<string>;
  18581. /**
  18582. * Callback called when the geometry is updated
  18583. */
  18584. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  18585. private _scene;
  18586. private _engine;
  18587. private _meshes;
  18588. private _totalVertices;
  18589. private _indices;
  18590. private _vertexBuffers;
  18591. private _isDisposed;
  18592. private _extend;
  18593. private _boundingBias;
  18594. /** @hidden */
  18595. _delayInfo: Array<string>;
  18596. private _indexBuffer;
  18597. private _indexBufferIsUpdatable;
  18598. /** @hidden */
  18599. _boundingInfo: Nullable<BoundingInfo>;
  18600. /** @hidden */
  18601. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  18602. /** @hidden */
  18603. _softwareSkinningRenderId: number;
  18604. private _vertexArrayObjects;
  18605. private _updatable;
  18606. /** @hidden */
  18607. _positions: Nullable<Vector3[]>;
  18608. /**
  18609. * 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
  18610. */
  18611. /**
  18612. * 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
  18613. */
  18614. boundingBias: Vector2;
  18615. /**
  18616. * Static function used to attach a new empty geometry to a mesh
  18617. * @param mesh defines the mesh to attach the geometry to
  18618. * @returns the new {BABYLON.Geometry}
  18619. */
  18620. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  18621. /**
  18622. * Creates a new geometry
  18623. * @param id defines the unique ID
  18624. * @param scene defines the hosting scene
  18625. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  18626. * @param updatable defines if geometry must be updatable (false by default)
  18627. * @param mesh defines the mesh that will be associated with the geometry
  18628. */
  18629. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  18630. /**
  18631. * Gets the current extend of the geometry
  18632. */
  18633. readonly extend: {
  18634. minimum: Vector3;
  18635. maximum: Vector3;
  18636. };
  18637. /**
  18638. * Gets the hosting scene
  18639. * @returns the hosting {BABYLON.Scene}
  18640. */
  18641. getScene(): Scene;
  18642. /**
  18643. * Gets the hosting engine
  18644. * @returns the hosting {BABYLON.Engine}
  18645. */
  18646. getEngine(): Engine;
  18647. /**
  18648. * Defines if the geometry is ready to use
  18649. * @returns true if the geometry is ready to be used
  18650. */
  18651. isReady(): boolean;
  18652. /**
  18653. * Gets a value indicating that the geometry should not be serialized
  18654. */
  18655. readonly doNotSerialize: boolean;
  18656. /** @hidden */
  18657. _rebuild(): void;
  18658. /**
  18659. * Affects all gemetry data in one call
  18660. * @param vertexData defines the geometry data
  18661. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  18662. */
  18663. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  18664. /**
  18665. * Set specific vertex data
  18666. * @param kind defines the data kind (Position, normal, etc...)
  18667. * @param data defines the vertex data to use
  18668. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  18669. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  18670. */
  18671. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  18672. /**
  18673. * Removes a specific vertex data
  18674. * @param kind defines the data kind (Position, normal, etc...)
  18675. */
  18676. removeVerticesData(kind: string): void;
  18677. /**
  18678. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  18679. * @param buffer defines the vertex buffer to use
  18680. * @param totalVertices defines the total number of vertices for position kind (could be null)
  18681. */
  18682. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  18683. /**
  18684. * Update a specific vertex buffer
  18685. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  18686. * It will do nothing if the buffer is not updatable
  18687. * @param kind defines the data kind (Position, normal, etc...)
  18688. * @param data defines the data to use
  18689. * @param offset defines the offset in the target buffer where to store the data
  18690. * @param useBytes set to true if the offset is in bytes
  18691. */
  18692. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  18693. /**
  18694. * Update a specific vertex buffer
  18695. * This function will create a new buffer if the current one is not updatable
  18696. * @param kind defines the data kind (Position, normal, etc...)
  18697. * @param data defines the data to use
  18698. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  18699. */
  18700. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  18701. private _updateBoundingInfo(updateExtends, data);
  18702. /** @hidden */
  18703. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  18704. /**
  18705. * Gets total number of vertices
  18706. * @returns the total number of vertices
  18707. */
  18708. getTotalVertices(): number;
  18709. /**
  18710. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  18711. * @param kind defines the data kind (Position, normal, etc...)
  18712. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  18713. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  18714. * @returns a float array containing vertex data
  18715. */
  18716. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  18717. /**
  18718. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  18719. * @param kind defines the data kind (Position, normal, etc...)
  18720. * @returns true if the vertex buffer with the specified kind is updatable
  18721. */
  18722. isVertexBufferUpdatable(kind: string): boolean;
  18723. /**
  18724. * Gets a specific vertex buffer
  18725. * @param kind defines the data kind (Position, normal, etc...)
  18726. * @returns a {BABYLON.VertexBuffer}
  18727. */
  18728. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  18729. /**
  18730. * Returns all vertex buffers
  18731. * @return an object holding all vertex buffers indexed by kind
  18732. */
  18733. getVertexBuffers(): Nullable<{
  18734. [key: string]: VertexBuffer;
  18735. }>;
  18736. /**
  18737. * Gets a boolean indicating if specific vertex buffer is present
  18738. * @param kind defines the data kind (Position, normal, etc...)
  18739. * @returns true if data is present
  18740. */
  18741. isVerticesDataPresent(kind: string): boolean;
  18742. /**
  18743. * Gets a list of all attached data kinds (Position, normal, etc...)
  18744. * @returns a list of string containing all kinds
  18745. */
  18746. getVerticesDataKinds(): string[];
  18747. /**
  18748. * Update index buffer
  18749. * @param indices defines the indices to store in the index buffer
  18750. * @param offset defines the offset in the target buffer where to store the data
  18751. */
  18752. updateIndices(indices: IndicesArray, offset?: number): void;
  18753. /**
  18754. * Creates a new index buffer
  18755. * @param indices defines the indices to store in the index buffer
  18756. * @param totalVertices defines the total number of vertices (could be null)
  18757. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  18758. */
  18759. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  18760. /**
  18761. * Return the total number of indices
  18762. * @returns the total number of indices
  18763. */
  18764. getTotalIndices(): number;
  18765. /**
  18766. * Gets the index buffer array
  18767. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  18768. * @returns the index buffer array
  18769. */
  18770. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  18771. /**
  18772. * Gets the index buffer
  18773. * @return the index buffer
  18774. */
  18775. getIndexBuffer(): Nullable<WebGLBuffer>;
  18776. /** @hidden */
  18777. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  18778. /**
  18779. * Release the associated resources for a specific mesh
  18780. * @param mesh defines the source mesh
  18781. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  18782. */
  18783. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  18784. /**
  18785. * Apply current geometry to a given mesh
  18786. * @param mesh defines the mesh to apply geometry to
  18787. */
  18788. applyToMesh(mesh: Mesh): void;
  18789. private _updateExtend(data?);
  18790. private _applyToMesh(mesh);
  18791. private notifyUpdate(kind?);
  18792. /**
  18793. * Load the geometry if it was flagged as delay loaded
  18794. * @param scene defines the hosting scene
  18795. * @param onLoaded defines a callback called when the geometry is loaded
  18796. */
  18797. load(scene: Scene, onLoaded?: () => void): void;
  18798. private _queueLoad(scene, onLoaded?);
  18799. /**
  18800. * Invert the geometry to move from a right handed system to a left handed one.
  18801. */
  18802. toLeftHanded(): void;
  18803. /** @hidden */
  18804. _resetPointsArrayCache(): void;
  18805. /** @hidden */
  18806. _generatePointsArray(): boolean;
  18807. /**
  18808. * Gets a value indicating if the geometry is disposed
  18809. * @returns true if the geometry was disposed
  18810. */
  18811. isDisposed(): boolean;
  18812. private _disposeVertexArrayObjects();
  18813. /**
  18814. * Free all associated resources
  18815. */
  18816. dispose(): void;
  18817. /**
  18818. * Clone the current geometry into a new geometry
  18819. * @param id defines the unique ID of the new geometry
  18820. * @returns a new geometry object
  18821. */
  18822. copy(id: string): Geometry;
  18823. /**
  18824. * Serialize the current geometry info (and not the vertices data) into a JSON object
  18825. * @return a JSON representation of the current geometry data (without the vertices data)
  18826. */
  18827. serialize(): any;
  18828. private toNumberArray(origin);
  18829. /**
  18830. * Serialize all vertices data into a JSON oject
  18831. * @returns a JSON representation of the current geometry data
  18832. */
  18833. serializeVerticeData(): any;
  18834. /**
  18835. * Extracts a clone of a mesh geometry
  18836. * @param mesh defines the source mesh
  18837. * @param id defines the unique ID of the new geometry object
  18838. * @returns the new geometry object
  18839. */
  18840. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  18841. /**
  18842. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  18843. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  18844. * Be aware Math.random() could cause collisions, but:
  18845. * "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"
  18846. * @returns a string containing a new GUID
  18847. */
  18848. static RandomId(): string;
  18849. /** @hidden */
  18850. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  18851. private static _CleanMatricesWeights(parsedGeometry, mesh);
  18852. /**
  18853. * Create a new geometry from persisted data (Using .babylon file format)
  18854. * @param parsedVertexData defines the persisted data
  18855. * @param scene defines the hosting scene
  18856. * @param rootUrl defines the root url to use to load assets (like delayed data)
  18857. * @returns the new geometry object
  18858. */
  18859. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  18860. }
  18861. /**
  18862. * Abstract class used to provide common services for all typed geometries
  18863. * @hidden
  18864. */
  18865. class _PrimitiveGeometry extends Geometry {
  18866. private _canBeRegenerated;
  18867. private _beingRegenerated;
  18868. /**
  18869. * Creates a new typed geometry
  18870. * @param id defines the unique ID of the geometry
  18871. * @param scene defines the hosting scene
  18872. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  18873. * @param mesh defines the hosting mesh (can be null)
  18874. */
  18875. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  18876. /**
  18877. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  18878. * @returns true if the geometry can be regenerated
  18879. */
  18880. canBeRegenerated(): boolean;
  18881. /**
  18882. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  18883. */
  18884. regenerate(): void;
  18885. /**
  18886. * Clone the geometry
  18887. * @param id defines the unique ID of the new geometry
  18888. * @returns the new geometry
  18889. */
  18890. asNewGeometry(id: string): Geometry;
  18891. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  18892. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  18893. /** @hidden */
  18894. _regenerateVertexData(): VertexData;
  18895. copy(id: string): Geometry;
  18896. serialize(): any;
  18897. }
  18898. /**
  18899. * Creates a ribbon geometry
  18900. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  18901. */
  18902. class RibbonGeometry extends _PrimitiveGeometry {
  18903. /**
  18904. * Defines the array of paths to use
  18905. */
  18906. pathArray: Vector3[][];
  18907. /**
  18908. * Defines if the last and first points of each path in your pathArray must be joined
  18909. */
  18910. closeArray: boolean;
  18911. /**
  18912. * Defines if the last and first points of each path in your pathArray must be joined
  18913. */
  18914. closePath: boolean;
  18915. /**
  18916. * Defines the offset between points
  18917. */
  18918. offset: number;
  18919. /**
  18920. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18921. */
  18922. side: number;
  18923. /**
  18924. * Creates a ribbon geometry
  18925. * @param id defines the unique ID of the geometry
  18926. * @param scene defines the hosting scene
  18927. * @param pathArray defines the array of paths to use
  18928. * @param closeArray defines if the last path and the first path must be joined
  18929. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  18930. * @param offset defines the offset between points
  18931. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  18932. * @param mesh defines the hosting mesh (can be null)
  18933. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18934. */
  18935. constructor(id: string, scene: Scene,
  18936. /**
  18937. * Defines the array of paths to use
  18938. */
  18939. pathArray: Vector3[][],
  18940. /**
  18941. * Defines if the last and first points of each path in your pathArray must be joined
  18942. */
  18943. closeArray: boolean,
  18944. /**
  18945. * Defines if the last and first points of each path in your pathArray must be joined
  18946. */
  18947. closePath: boolean,
  18948. /**
  18949. * Defines the offset between points
  18950. */
  18951. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  18952. /**
  18953. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18954. */
  18955. side?: number);
  18956. /** @hidden */
  18957. _regenerateVertexData(): VertexData;
  18958. copy(id: string): Geometry;
  18959. }
  18960. /**
  18961. * Creates a box geometry
  18962. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  18963. */
  18964. class BoxGeometry extends _PrimitiveGeometry {
  18965. /**
  18966. * Defines the zise of the box (width, height and depth are the same)
  18967. */
  18968. size: number;
  18969. /**
  18970. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18971. */
  18972. side: number;
  18973. /**
  18974. * Creates a box geometry
  18975. * @param id defines the unique ID of the geometry
  18976. * @param scene defines the hosting scene
  18977. * @param size defines the zise of the box (width, height and depth are the same)
  18978. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  18979. * @param mesh defines the hosting mesh (can be null)
  18980. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18981. */
  18982. constructor(id: string, scene: Scene,
  18983. /**
  18984. * Defines the zise of the box (width, height and depth are the same)
  18985. */
  18986. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  18987. /**
  18988. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18989. */
  18990. side?: number);
  18991. _regenerateVertexData(): VertexData;
  18992. copy(id: string): Geometry;
  18993. serialize(): any;
  18994. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  18995. }
  18996. /**
  18997. * Creates a sphere geometry
  18998. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  18999. */
  19000. class SphereGeometry extends _PrimitiveGeometry {
  19001. /**
  19002. * Defines the number of segments to use to create the sphere
  19003. */
  19004. segments: number;
  19005. /**
  19006. * Defines the diameter of the sphere
  19007. */
  19008. diameter: number;
  19009. /**
  19010. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19011. */
  19012. side: number;
  19013. /**
  19014. * Create a new sphere geometry
  19015. * @param id defines the unique ID of the geometry
  19016. * @param scene defines the hosting scene
  19017. * @param segments defines the number of segments to use to create the sphere
  19018. * @param diameter defines the diameter of the sphere
  19019. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19020. * @param mesh defines the hosting mesh (can be null)
  19021. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19022. */
  19023. constructor(id: string, scene: Scene,
  19024. /**
  19025. * Defines the number of segments to use to create the sphere
  19026. */
  19027. segments: number,
  19028. /**
  19029. * Defines the diameter of the sphere
  19030. */
  19031. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19032. /**
  19033. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19034. */
  19035. side?: number);
  19036. _regenerateVertexData(): VertexData;
  19037. copy(id: string): Geometry;
  19038. serialize(): any;
  19039. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  19040. }
  19041. /**
  19042. * Creates a disc geometry
  19043. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  19044. */
  19045. class DiscGeometry extends _PrimitiveGeometry {
  19046. /**
  19047. * Defines the radius of the disc
  19048. */
  19049. radius: number;
  19050. /**
  19051. * Defines the tesselation factor to apply to the disc
  19052. */
  19053. tessellation: number;
  19054. /**
  19055. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19056. */
  19057. side: number;
  19058. /**
  19059. * Creates a new disc geometry
  19060. * @param id defines the unique ID of the geometry
  19061. * @param scene defines the hosting scene
  19062. * @param radius defines the radius of the disc
  19063. * @param tessellation defines the tesselation factor to apply to the disc
  19064. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19065. * @param mesh defines the hosting mesh (can be null)
  19066. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19067. */
  19068. constructor(id: string, scene: Scene,
  19069. /**
  19070. * Defines the radius of the disc
  19071. */
  19072. radius: number,
  19073. /**
  19074. * Defines the tesselation factor to apply to the disc
  19075. */
  19076. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19077. /**
  19078. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19079. */
  19080. side?: number);
  19081. _regenerateVertexData(): VertexData;
  19082. copy(id: string): Geometry;
  19083. }
  19084. /**
  19085. * Creates a new cylinder geometry
  19086. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  19087. */
  19088. class CylinderGeometry extends _PrimitiveGeometry {
  19089. /**
  19090. * Defines the height of the cylinder
  19091. */
  19092. height: number;
  19093. /**
  19094. * Defines the diameter of the cylinder's top cap
  19095. */
  19096. diameterTop: number;
  19097. /**
  19098. * Defines the diameter of the cylinder's bottom cap
  19099. */
  19100. diameterBottom: number;
  19101. /**
  19102. * Defines the tessellation factor to apply to the cylinder
  19103. */
  19104. tessellation: number;
  19105. /**
  19106. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  19107. */
  19108. subdivisions: number;
  19109. /**
  19110. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19111. */
  19112. side: number;
  19113. /**
  19114. * Creates a new cylinder geometry
  19115. * @param id defines the unique ID of the geometry
  19116. * @param scene defines the hosting scene
  19117. * @param height defines the height of the cylinder
  19118. * @param diameterTop defines the diameter of the cylinder's top cap
  19119. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  19120. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  19121. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  19122. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19123. * @param mesh defines the hosting mesh (can be null)
  19124. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19125. */
  19126. constructor(id: string, scene: Scene,
  19127. /**
  19128. * Defines the height of the cylinder
  19129. */
  19130. height: number,
  19131. /**
  19132. * Defines the diameter of the cylinder's top cap
  19133. */
  19134. diameterTop: number,
  19135. /**
  19136. * Defines the diameter of the cylinder's bottom cap
  19137. */
  19138. diameterBottom: number,
  19139. /**
  19140. * Defines the tessellation factor to apply to the cylinder
  19141. */
  19142. tessellation: number,
  19143. /**
  19144. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  19145. */
  19146. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19147. /**
  19148. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19149. */
  19150. side?: number);
  19151. _regenerateVertexData(): VertexData;
  19152. copy(id: string): Geometry;
  19153. serialize(): any;
  19154. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  19155. }
  19156. /**
  19157. * Creates a new torus geometry
  19158. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  19159. */
  19160. class TorusGeometry extends _PrimitiveGeometry {
  19161. /**
  19162. * Defines the diameter of the torus
  19163. */
  19164. diameter: number;
  19165. /**
  19166. * Defines the thickness of the torus (ie. internal diameter)
  19167. */
  19168. thickness: number;
  19169. /**
  19170. * Defines the tesselation factor to apply to the torus
  19171. */
  19172. tessellation: number;
  19173. /**
  19174. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19175. */
  19176. side: number;
  19177. /**
  19178. * Creates a new torus geometry
  19179. * @param id defines the unique ID of the geometry
  19180. * @param scene defines the hosting scene
  19181. * @param diameter defines the diameter of the torus
  19182. * @param thickness defines the thickness of the torus (ie. internal diameter)
  19183. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  19184. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19185. * @param mesh defines the hosting mesh (can be null)
  19186. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19187. */
  19188. constructor(id: string, scene: Scene,
  19189. /**
  19190. * Defines the diameter of the torus
  19191. */
  19192. diameter: number,
  19193. /**
  19194. * Defines the thickness of the torus (ie. internal diameter)
  19195. */
  19196. thickness: number,
  19197. /**
  19198. * Defines the tesselation factor to apply to the torus
  19199. */
  19200. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19201. /**
  19202. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19203. */
  19204. side?: number);
  19205. _regenerateVertexData(): VertexData;
  19206. copy(id: string): Geometry;
  19207. serialize(): any;
  19208. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  19209. }
  19210. /**
  19211. * Creates a new ground geometry
  19212. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  19213. */
  19214. class GroundGeometry extends _PrimitiveGeometry {
  19215. /**
  19216. * Defines the width of the ground
  19217. */
  19218. width: number;
  19219. /**
  19220. * Defines the height of the ground
  19221. */
  19222. height: number;
  19223. /**
  19224. * Defines the subdivisions to apply to the ground
  19225. */
  19226. subdivisions: number;
  19227. /**
  19228. * Creates a new ground geometry
  19229. * @param id defines the unique ID of the geometry
  19230. * @param scene defines the hosting scene
  19231. * @param width defines the width of the ground
  19232. * @param height defines the height of the ground
  19233. * @param subdivisions defines the subdivisions to apply to the ground
  19234. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19235. * @param mesh defines the hosting mesh (can be null)
  19236. */
  19237. constructor(id: string, scene: Scene,
  19238. /**
  19239. * Defines the width of the ground
  19240. */
  19241. width: number,
  19242. /**
  19243. * Defines the height of the ground
  19244. */
  19245. height: number,
  19246. /**
  19247. * Defines the subdivisions to apply to the ground
  19248. */
  19249. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  19250. _regenerateVertexData(): VertexData;
  19251. copy(id: string): Geometry;
  19252. serialize(): any;
  19253. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  19254. }
  19255. /**
  19256. * Creates a tiled ground geometry
  19257. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  19258. */
  19259. class TiledGroundGeometry extends _PrimitiveGeometry {
  19260. /**
  19261. * Defines the minimum value on X axis
  19262. */
  19263. xmin: number;
  19264. /**
  19265. * Defines the minimum value on Z axis
  19266. */
  19267. zmin: number;
  19268. /**
  19269. * Defines the maximum value on X axis
  19270. */
  19271. xmax: number;
  19272. /**
  19273. * Defines the maximum value on Z axis
  19274. */
  19275. zmax: number;
  19276. /**
  19277. * Defines the subdivisions to apply to the ground
  19278. */
  19279. subdivisions: {
  19280. w: number;
  19281. h: number;
  19282. };
  19283. /**
  19284. * Defines the precision to use when computing the tiles
  19285. */
  19286. precision: {
  19287. w: number;
  19288. h: number;
  19289. };
  19290. /**
  19291. * Creates a tiled ground geometry
  19292. * @param id defines the unique ID of the geometry
  19293. * @param scene defines the hosting scene
  19294. * @param xmin defines the minimum value on X axis
  19295. * @param zmin defines the minimum value on Z axis
  19296. * @param xmax defines the maximum value on X axis
  19297. * @param zmax defines the maximum value on Z axis
  19298. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  19299. * @param precision defines the precision to use when computing the tiles
  19300. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19301. * @param mesh defines the hosting mesh (can be null)
  19302. */
  19303. constructor(id: string, scene: Scene,
  19304. /**
  19305. * Defines the minimum value on X axis
  19306. */
  19307. xmin: number,
  19308. /**
  19309. * Defines the minimum value on Z axis
  19310. */
  19311. zmin: number,
  19312. /**
  19313. * Defines the maximum value on X axis
  19314. */
  19315. xmax: number,
  19316. /**
  19317. * Defines the maximum value on Z axis
  19318. */
  19319. zmax: number,
  19320. /**
  19321. * Defines the subdivisions to apply to the ground
  19322. */
  19323. subdivisions: {
  19324. w: number;
  19325. h: number;
  19326. },
  19327. /**
  19328. * Defines the precision to use when computing the tiles
  19329. */
  19330. precision: {
  19331. w: number;
  19332. h: number;
  19333. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  19334. _regenerateVertexData(): VertexData;
  19335. copy(id: string): Geometry;
  19336. }
  19337. /**
  19338. * Creates a plane geometry
  19339. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  19340. */
  19341. class PlaneGeometry extends _PrimitiveGeometry {
  19342. /**
  19343. * Defines the size of the plane (width === height)
  19344. */
  19345. size: number;
  19346. /**
  19347. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19348. */
  19349. side: number;
  19350. /**
  19351. * Creates a plane geometry
  19352. * @param id defines the unique ID of the geometry
  19353. * @param scene defines the hosting scene
  19354. * @param size defines the size of the plane (width === height)
  19355. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19356. * @param mesh defines the hosting mesh (can be null)
  19357. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19358. */
  19359. constructor(id: string, scene: Scene,
  19360. /**
  19361. * Defines the size of the plane (width === height)
  19362. */
  19363. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19364. /**
  19365. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19366. */
  19367. side?: number);
  19368. _regenerateVertexData(): VertexData;
  19369. copy(id: string): Geometry;
  19370. serialize(): any;
  19371. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  19372. }
  19373. /**
  19374. * Creates a torus knot geometry
  19375. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  19376. */
  19377. class TorusKnotGeometry extends _PrimitiveGeometry {
  19378. /**
  19379. * Defines the radius of the torus knot
  19380. */
  19381. radius: number;
  19382. /**
  19383. * Defines the thickness of the torus knot tube
  19384. */
  19385. tube: number;
  19386. /**
  19387. * Defines the number of radial segments
  19388. */
  19389. radialSegments: number;
  19390. /**
  19391. * Defines the number of tubular segments
  19392. */
  19393. tubularSegments: number;
  19394. /**
  19395. * Defines the first number of windings
  19396. */
  19397. p: number;
  19398. /**
  19399. * Defines the second number of windings
  19400. */
  19401. q: number;
  19402. /**
  19403. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19404. */
  19405. side: number;
  19406. /**
  19407. * Creates a torus knot geometry
  19408. * @param id defines the unique ID of the geometry
  19409. * @param scene defines the hosting scene
  19410. * @param radius defines the radius of the torus knot
  19411. * @param tube defines the thickness of the torus knot tube
  19412. * @param radialSegments defines the number of radial segments
  19413. * @param tubularSegments defines the number of tubular segments
  19414. * @param p defines the first number of windings
  19415. * @param q defines the second number of windings
  19416. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19417. * @param mesh defines the hosting mesh (can be null)
  19418. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19419. */
  19420. constructor(id: string, scene: Scene,
  19421. /**
  19422. * Defines the radius of the torus knot
  19423. */
  19424. radius: number,
  19425. /**
  19426. * Defines the thickness of the torus knot tube
  19427. */
  19428. tube: number,
  19429. /**
  19430. * Defines the number of radial segments
  19431. */
  19432. radialSegments: number,
  19433. /**
  19434. * Defines the number of tubular segments
  19435. */
  19436. tubularSegments: number,
  19437. /**
  19438. * Defines the first number of windings
  19439. */
  19440. p: number,
  19441. /**
  19442. * Defines the second number of windings
  19443. */
  19444. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19445. /**
  19446. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19447. */
  19448. side?: number);
  19449. _regenerateVertexData(): VertexData;
  19450. copy(id: string): Geometry;
  19451. serialize(): any;
  19452. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  19453. }
  19454. }
  19455. declare module BABYLON {
  19456. class GroundMesh extends Mesh {
  19457. generateOctree: boolean;
  19458. private _heightQuads;
  19459. _subdivisionsX: number;
  19460. _subdivisionsY: number;
  19461. _width: number;
  19462. _height: number;
  19463. _minX: number;
  19464. _maxX: number;
  19465. _minZ: number;
  19466. _maxZ: number;
  19467. constructor(name: string, scene: Scene);
  19468. getClassName(): string;
  19469. readonly subdivisions: number;
  19470. readonly subdivisionsX: number;
  19471. readonly subdivisionsY: number;
  19472. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19473. /**
  19474. * Returns a height (y) value in the Worl system :
  19475. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19476. * Returns the ground y position if (x, z) are outside the ground surface.
  19477. */
  19478. getHeightAtCoordinates(x: number, z: number): number;
  19479. /**
  19480. * Returns a normalized vector (Vector3) orthogonal to the ground
  19481. * at the ground coordinates (x, z) expressed in the World system.
  19482. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19483. */
  19484. getNormalAtCoordinates(x: number, z: number): Vector3;
  19485. /**
  19486. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19487. * at the ground coordinates (x, z) expressed in the World system.
  19488. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19489. * Returns the GroundMesh.
  19490. */
  19491. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19492. /**
  19493. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19494. * if the ground has been updated.
  19495. * This can be used in the render loop.
  19496. * Returns the GroundMesh.
  19497. */
  19498. updateCoordinateHeights(): GroundMesh;
  19499. private _getFacetAt(x, z);
  19500. private _initHeightQuads();
  19501. private _computeHeightQuads();
  19502. serialize(serializationObject: any): void;
  19503. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19504. }
  19505. }
  19506. declare module BABYLON {
  19507. /**
  19508. * Creates an instance based on a source mesh.
  19509. */
  19510. class InstancedMesh extends AbstractMesh {
  19511. private _sourceMesh;
  19512. private _currentLOD;
  19513. constructor(name: string, source: Mesh);
  19514. /**
  19515. * Returns the string "InstancedMesh".
  19516. */
  19517. getClassName(): string;
  19518. readonly receiveShadows: boolean;
  19519. readonly material: Nullable<Material>;
  19520. readonly visibility: number;
  19521. readonly skeleton: Nullable<Skeleton>;
  19522. renderingGroupId: number;
  19523. /**
  19524. * Returns the total number of vertices (integer).
  19525. */
  19526. getTotalVertices(): number;
  19527. readonly sourceMesh: Mesh;
  19528. /**
  19529. * Is this node ready to be used/rendered
  19530. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19531. * @return {boolean} is it ready
  19532. */
  19533. isReady(completeCheck?: boolean): boolean;
  19534. /**
  19535. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19536. */
  19537. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19538. /**
  19539. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19540. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19541. * The `data` are either a numeric array either a Float32Array.
  19542. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19543. * 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).
  19544. * Note that a new underlying VertexBuffer object is created each call.
  19545. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19546. *
  19547. * Possible `kind` values :
  19548. * - BABYLON.VertexBuffer.PositionKind
  19549. * - BABYLON.VertexBuffer.UVKind
  19550. * - BABYLON.VertexBuffer.UV2Kind
  19551. * - BABYLON.VertexBuffer.UV3Kind
  19552. * - BABYLON.VertexBuffer.UV4Kind
  19553. * - BABYLON.VertexBuffer.UV5Kind
  19554. * - BABYLON.VertexBuffer.UV6Kind
  19555. * - BABYLON.VertexBuffer.ColorKind
  19556. * - BABYLON.VertexBuffer.MatricesIndicesKind
  19557. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19558. * - BABYLON.VertexBuffer.MatricesWeightsKind
  19559. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19560. *
  19561. * Returns the Mesh.
  19562. */
  19563. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19564. /**
  19565. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19566. * If the mesh has no geometry, it is simply returned as it is.
  19567. * The `data` are either a numeric array either a Float32Array.
  19568. * No new underlying VertexBuffer object is created.
  19569. * 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.
  19570. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19571. *
  19572. * Possible `kind` values :
  19573. * - BABYLON.VertexBuffer.PositionKind
  19574. * - BABYLON.VertexBuffer.UVKind
  19575. * - BABYLON.VertexBuffer.UV2Kind
  19576. * - BABYLON.VertexBuffer.UV3Kind
  19577. * - BABYLON.VertexBuffer.UV4Kind
  19578. * - BABYLON.VertexBuffer.UV5Kind
  19579. * - BABYLON.VertexBuffer.UV6Kind
  19580. * - BABYLON.VertexBuffer.ColorKind
  19581. * - BABYLON.VertexBuffer.MatricesIndicesKind
  19582. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19583. * - BABYLON.VertexBuffer.MatricesWeightsKind
  19584. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19585. *
  19586. * Returns the Mesh.
  19587. */
  19588. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19589. /**
  19590. * Sets the mesh indices.
  19591. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19592. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19593. * This method creates a new index buffer each call.
  19594. * Returns the Mesh.
  19595. */
  19596. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19597. /**
  19598. * Boolean : True if the mesh owns the requested kind of data.
  19599. */
  19600. isVerticesDataPresent(kind: string): boolean;
  19601. /**
  19602. * Returns an array of indices (IndicesArray).
  19603. */
  19604. getIndices(): Nullable<IndicesArray>;
  19605. readonly _positions: Nullable<Vector3[]>;
  19606. /**
  19607. * Sets a new updated BoundingInfo to the mesh.
  19608. * Returns the mesh.
  19609. */
  19610. refreshBoundingInfo(): InstancedMesh;
  19611. _preActivate(): InstancedMesh;
  19612. _activate(renderId: number): InstancedMesh;
  19613. /**
  19614. * Returns the current associated LOD AbstractMesh.
  19615. */
  19616. getLOD(camera: Camera): AbstractMesh;
  19617. _syncSubMeshes(): InstancedMesh;
  19618. _generatePointsArray(): boolean;
  19619. /**
  19620. * Creates a new InstancedMesh from the current mesh.
  19621. * - name (string) : the cloned mesh name
  19622. * - newParent (optional Node) : the optional Node to parent the clone to.
  19623. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19624. *
  19625. * Returns the clone.
  19626. */
  19627. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  19628. /**
  19629. * Disposes the InstancedMesh.
  19630. * Returns nothing.
  19631. */
  19632. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19633. }
  19634. }
  19635. declare module BABYLON {
  19636. class LinesMesh extends Mesh {
  19637. useVertexColor: boolean | undefined;
  19638. useVertexAlpha: boolean | undefined;
  19639. color: Color3;
  19640. alpha: number;
  19641. /**
  19642. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19643. * This margin is expressed in world space coordinates, so its value may vary.
  19644. * Default value is 0.1
  19645. * @returns the intersection Threshold value.
  19646. */
  19647. /**
  19648. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19649. * This margin is expressed in world space coordinates, so its value may vary.
  19650. * @param value the new threshold to apply
  19651. */
  19652. intersectionThreshold: number;
  19653. private _intersectionThreshold;
  19654. private _colorShader;
  19655. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  19656. /**
  19657. * Returns the string "LineMesh"
  19658. */
  19659. getClassName(): string;
  19660. material: Material;
  19661. readonly checkCollisions: boolean;
  19662. createInstance(name: string): InstancedMesh;
  19663. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19664. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19665. dispose(doNotRecurse?: boolean): void;
  19666. /**
  19667. * Returns a new LineMesh object cloned from the current one.
  19668. */
  19669. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19670. }
  19671. }
  19672. declare module BABYLON {
  19673. /**
  19674. * @hidden
  19675. **/
  19676. class _InstancesBatch {
  19677. mustReturn: boolean;
  19678. visibleInstances: Nullable<InstancedMesh[]>[];
  19679. renderSelf: boolean[];
  19680. }
  19681. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  19682. static _FRONTSIDE: number;
  19683. static _BACKSIDE: number;
  19684. static _DOUBLESIDE: number;
  19685. static _DEFAULTSIDE: number;
  19686. static _NO_CAP: number;
  19687. static _CAP_START: number;
  19688. static _CAP_END: number;
  19689. static _CAP_ALL: number;
  19690. /**
  19691. * Mesh side orientation : usually the external or front surface
  19692. */
  19693. static readonly FRONTSIDE: number;
  19694. /**
  19695. * Mesh side orientation : usually the internal or back surface
  19696. */
  19697. static readonly BACKSIDE: number;
  19698. /**
  19699. * Mesh side orientation : both internal and external or front and back surfaces
  19700. */
  19701. static readonly DOUBLESIDE: number;
  19702. /**
  19703. * Mesh side orientation : by default, `FRONTSIDE`
  19704. */
  19705. static readonly DEFAULTSIDE: number;
  19706. /**
  19707. * Mesh cap setting : no cap
  19708. */
  19709. static readonly NO_CAP: number;
  19710. /**
  19711. * Mesh cap setting : one cap at the beginning of the mesh
  19712. */
  19713. static readonly CAP_START: number;
  19714. /**
  19715. * Mesh cap setting : one cap at the end of the mesh
  19716. */
  19717. static readonly CAP_END: number;
  19718. /**
  19719. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  19720. */
  19721. static readonly CAP_ALL: number;
  19722. /**
  19723. * An event triggered before rendering the mesh
  19724. */
  19725. onBeforeRenderObservable: Observable<Mesh>;
  19726. /**
  19727. * An event triggered after rendering the mesh
  19728. */
  19729. onAfterRenderObservable: Observable<Mesh>;
  19730. /**
  19731. * An event triggered before drawing the mesh
  19732. */
  19733. onBeforeDrawObservable: Observable<Mesh>;
  19734. private _onBeforeDrawObserver;
  19735. onBeforeDraw: () => void;
  19736. delayLoadState: number;
  19737. instances: InstancedMesh[];
  19738. delayLoadingFile: string;
  19739. _binaryInfo: any;
  19740. private _LODLevels;
  19741. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  19742. private _morphTargetManager;
  19743. morphTargetManager: Nullable<MorphTargetManager>;
  19744. _geometry: Nullable<Geometry>;
  19745. _delayInfo: Array<string>;
  19746. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  19747. _visibleInstances: any;
  19748. private _renderIdForInstances;
  19749. private _batchCache;
  19750. private _instancesBufferSize;
  19751. private _instancesBuffer;
  19752. private _instancesData;
  19753. private _overridenInstanceCount;
  19754. private _effectiveMaterial;
  19755. _shouldGenerateFlatShading: boolean;
  19756. private _preActivateId;
  19757. _originalBuilderSideOrientation: number;
  19758. overrideMaterialSideOrientation: Nullable<number>;
  19759. private _areNormalsFrozen;
  19760. private _sourcePositions;
  19761. private _sourceNormals;
  19762. private _source;
  19763. readonly source: Nullable<Mesh>;
  19764. isUnIndexed: boolean;
  19765. /**
  19766. * @constructor
  19767. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  19768. * @param {Scene} scene The scene to add this mesh to.
  19769. * @param {Node} parent The parent of this mesh, if it has one
  19770. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  19771. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19772. * When false, achieved by calling a clone(), also passing False.
  19773. * This will make creation of children, recursive.
  19774. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  19775. */
  19776. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  19777. /**
  19778. * Returns the string "Mesh".
  19779. */
  19780. getClassName(): string;
  19781. /**
  19782. * Returns a string.
  19783. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  19784. */
  19785. toString(fullDetails?: boolean): string;
  19786. _unBindEffect(): void;
  19787. /**
  19788. * True if the mesh has some Levels Of Details (LOD).
  19789. * Returns a boolean.
  19790. */
  19791. readonly hasLODLevels: boolean;
  19792. /**
  19793. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  19794. * @returns an array of {BABYLON.MeshLODLevel}
  19795. */
  19796. getLODLevels(): MeshLODLevel[];
  19797. private _sortLODLevels();
  19798. /**
  19799. * Add a mesh as LOD level triggered at the given distance.
  19800. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  19801. * @param {number} distance The distance from the center of the object to show this level
  19802. * @param {Mesh} mesh The mesh to be added as LOD level
  19803. * @return {Mesh} This mesh (for chaining)
  19804. */
  19805. addLODLevel(distance: number, mesh: Mesh): Mesh;
  19806. /**
  19807. * Returns the LOD level mesh at the passed distance or null if not found.
  19808. * It is related to the method `addLODLevel(distance, mesh)`.
  19809. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  19810. * Returns an object Mesh or `null`.
  19811. */
  19812. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  19813. /**
  19814. * Remove a mesh from the LOD array
  19815. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  19816. * @param {Mesh} mesh The mesh to be removed.
  19817. * @return {Mesh} This mesh (for chaining)
  19818. */
  19819. removeLODLevel(mesh: Mesh): Mesh;
  19820. /**
  19821. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  19822. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  19823. */
  19824. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  19825. /**
  19826. * Returns the mesh internal Geometry object.
  19827. */
  19828. readonly geometry: Nullable<Geometry>;
  19829. /**
  19830. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  19831. */
  19832. getTotalVertices(): number;
  19833. /**
  19834. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  19835. * 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.
  19836. * You can force the copy with forceCopy === true
  19837. * Returns null if the mesh has no geometry or no vertex buffer.
  19838. * Possible `kind` values :
  19839. * - BABYLON.VertexBuffer.PositionKind
  19840. * - BABYLON.VertexBuffer.UVKind
  19841. * - BABYLON.VertexBuffer.UV2Kind
  19842. * - BABYLON.VertexBuffer.UV3Kind
  19843. * - BABYLON.VertexBuffer.UV4Kind
  19844. * - BABYLON.VertexBuffer.UV5Kind
  19845. * - BABYLON.VertexBuffer.UV6Kind
  19846. * - BABYLON.VertexBuffer.ColorKind
  19847. * - BABYLON.VertexBuffer.MatricesIndicesKind
  19848. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19849. * - BABYLON.VertexBuffer.MatricesWeightsKind
  19850. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19851. */
  19852. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19853. /**
  19854. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  19855. * Returns `null` if the mesh has no geometry.
  19856. * Possible `kind` values :
  19857. * - BABYLON.VertexBuffer.PositionKind
  19858. * - BABYLON.VertexBuffer.UVKind
  19859. * - BABYLON.VertexBuffer.UV2Kind
  19860. * - BABYLON.VertexBuffer.UV3Kind
  19861. * - BABYLON.VertexBuffer.UV4Kind
  19862. * - BABYLON.VertexBuffer.UV5Kind
  19863. * - BABYLON.VertexBuffer.UV6Kind
  19864. * - BABYLON.VertexBuffer.ColorKind
  19865. * - BABYLON.VertexBuffer.MatricesIndicesKind
  19866. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19867. * - BABYLON.VertexBuffer.MatricesWeightsKind
  19868. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19869. */
  19870. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19871. isVerticesDataPresent(kind: string): boolean;
  19872. /**
  19873. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  19874. * Possible `kind` values :
  19875. * - BABYLON.VertexBuffer.PositionKind
  19876. * - BABYLON.VertexBuffer.UVKind
  19877. * - BABYLON.VertexBuffer.UV2Kind
  19878. * - BABYLON.VertexBuffer.UV3Kind
  19879. * - BABYLON.VertexBuffer.UV4Kind
  19880. * - BABYLON.VertexBuffer.UV5Kind
  19881. * - BABYLON.VertexBuffer.UV6Kind
  19882. * - BABYLON.VertexBuffer.ColorKind
  19883. * - BABYLON.VertexBuffer.MatricesIndicesKind
  19884. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19885. * - BABYLON.VertexBuffer.MatricesWeightsKind
  19886. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19887. */
  19888. isVertexBufferUpdatable(kind: string): boolean;
  19889. /**
  19890. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  19891. * Possible `kind` values :
  19892. * - BABYLON.VertexBuffer.PositionKind
  19893. * - BABYLON.VertexBuffer.UVKind
  19894. * - BABYLON.VertexBuffer.UV2Kind
  19895. * - BABYLON.VertexBuffer.UV3Kind
  19896. * - BABYLON.VertexBuffer.UV4Kind
  19897. * - BABYLON.VertexBuffer.UV5Kind
  19898. * - BABYLON.VertexBuffer.UV6Kind
  19899. * - BABYLON.VertexBuffer.ColorKind
  19900. * - BABYLON.VertexBuffer.MatricesIndicesKind
  19901. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19902. * - BABYLON.VertexBuffer.MatricesWeightsKind
  19903. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19904. */
  19905. getVerticesDataKinds(): string[];
  19906. /**
  19907. * Returns a positive integer : the total number of indices in this mesh geometry.
  19908. * Returns zero if the mesh has no geometry.
  19909. */
  19910. getTotalIndices(): number;
  19911. /**
  19912. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19913. * If the parameter `copyWhenShared` is true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  19914. * Returns an empty array if the mesh has no geometry.
  19915. */
  19916. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  19917. readonly isBlocked: boolean;
  19918. /**
  19919. * Determine if the current mesh is ready to be rendered
  19920. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19921. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  19922. * @returns true if all associated assets are ready (material, textures, shaders)
  19923. */
  19924. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  19925. /**
  19926. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  19927. * This property is pertinent only for updatable parametric shapes.
  19928. */
  19929. readonly areNormalsFrozen: boolean;
  19930. /**
  19931. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  19932. * It has no effect at all on other shapes.
  19933. * It prevents the mesh normals from being recomputed on next `positions` array update.
  19934. * Returns the Mesh.
  19935. */
  19936. freezeNormals(): Mesh;
  19937. /**
  19938. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  19939. * It has no effect at all on other shapes.
  19940. * It reactivates the mesh normals computation if it was previously frozen.
  19941. * Returns the Mesh.
  19942. */
  19943. unfreezeNormals(): Mesh;
  19944. /**
  19945. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  19946. */
  19947. overridenInstanceCount: number;
  19948. _preActivate(): Mesh;
  19949. _preActivateForIntermediateRendering(renderId: number): Mesh;
  19950. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  19951. /**
  19952. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19953. * This means the mesh underlying bounding box and sphere are recomputed.
  19954. * Returns the Mesh.
  19955. */
  19956. refreshBoundingInfo(): Mesh;
  19957. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  19958. private _getPositionData(applySkeleton);
  19959. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  19960. subdivide(count: number): void;
  19961. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19962. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  19963. /**
  19964. * Sets the mesh VertexBuffer.
  19965. * Returns the Mesh.
  19966. */
  19967. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  19968. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19969. /**
  19970. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  19971. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  19972. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  19973. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  19974. * Returns the Mesh.
  19975. */
  19976. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  19977. /**
  19978. * Creates a un-shared specific occurence of the geometry for the mesh.
  19979. * Returns the Mesh.
  19980. */
  19981. makeGeometryUnique(): Mesh;
  19982. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  19983. /**
  19984. * Update the current index buffer
  19985. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  19986. * Returns the Mesh.
  19987. */
  19988. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  19989. /**
  19990. * Invert the geometry to move from a right handed system to a left handed one.
  19991. * Returns the Mesh.
  19992. */
  19993. toLeftHanded(): Mesh;
  19994. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19995. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  19996. /**
  19997. * Registers for this mesh a javascript function called just before the rendering process.
  19998. * This function is passed the current mesh.
  19999. * Return the Mesh.
  20000. */
  20001. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20002. /**
  20003. * Disposes a previously registered javascript function called before the rendering.
  20004. * This function is passed the current mesh.
  20005. * Returns the Mesh.
  20006. */
  20007. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20008. /**
  20009. * Registers for this mesh a javascript function called just after the rendering is complete.
  20010. * This function is passed the current mesh.
  20011. * Returns the Mesh.
  20012. */
  20013. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20014. /**
  20015. * Disposes a previously registered javascript function called after the rendering.
  20016. * This function is passed the current mesh.
  20017. * Return the Mesh.
  20018. */
  20019. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20020. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20021. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20022. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20023. /**
  20024. * Triggers the draw call for the mesh.
  20025. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  20026. * Returns the Mesh.
  20027. */
  20028. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20029. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  20030. /**
  20031. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  20032. */
  20033. getEmittedParticleSystems(): IParticleSystem[];
  20034. /**
  20035. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  20036. */
  20037. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  20038. /**
  20039. * Normalize matrix weights so that all vertices have a total weight set to 1
  20040. */
  20041. cleanMatrixWeights(): void;
  20042. _checkDelayState(): Mesh;
  20043. private _queueLoad(scene);
  20044. /**
  20045. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  20046. */
  20047. isInFrustum(frustumPlanes: Plane[]): boolean;
  20048. /**
  20049. * Sets the mesh material by the material or multiMaterial `id` property.
  20050. * The material `id` is a string identifying the material or the multiMaterial.
  20051. * This method returns the Mesh.
  20052. */
  20053. setMaterialByID(id: string): Mesh;
  20054. /**
  20055. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20056. */
  20057. getAnimatables(): IAnimatable[];
  20058. /**
  20059. * Modifies the mesh geometry according to the passed transformation matrix.
  20060. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20061. * The mesh normals are modified accordingly the same transformation.
  20062. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  20063. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20064. * Returns the Mesh.
  20065. */
  20066. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20067. /**
  20068. * Modifies the mesh geometry according to its own current World Matrix.
  20069. * The mesh World Matrix is then reset.
  20070. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20071. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  20072. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20073. * Returns the Mesh.
  20074. */
  20075. bakeCurrentTransformIntoVertices(): Mesh;
  20076. readonly _positions: Nullable<Vector3[]>;
  20077. _resetPointsArrayCache(): Mesh;
  20078. _generatePointsArray(): boolean;
  20079. /**
  20080. * Returns a new Mesh object generated from the current mesh properties.
  20081. * This method must not get confused with createInstance().
  20082. * The parameter `name` is a string, the name given to the new mesh.
  20083. * The optional parameter `newParent` can be any Node object (default `null`).
  20084. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  20085. * 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.
  20086. */
  20087. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20088. /**
  20089. * Releases resources associated with this mesh.
  20090. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20091. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20092. */
  20093. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20094. /**
  20095. * Modifies the mesh geometry according to a displacement map.
  20096. * 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.
  20097. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20098. * This method returns nothing.
  20099. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  20100. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  20101. * The parameter `onSuccess` is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  20102. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  20103. * The parameter `uvScale` is an optional vector2 used to scale UV.
  20104. *
  20105. * Returns the Mesh.
  20106. */
  20107. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  20108. /**
  20109. * Modifies the mesh geometry according to a displacementMap buffer.
  20110. * 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.
  20111. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20112. * This method returns nothing.
  20113. * The parameter `buffer` is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20114. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  20115. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  20116. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  20117. * The parameter `uvScale` is an optional vector2 used to scale UV.
  20118. *
  20119. * Returns the Mesh.
  20120. */
  20121. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  20122. /**
  20123. * Modify the mesh to get a flat shading rendering.
  20124. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20125. * This method returns the Mesh.
  20126. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20127. */
  20128. convertToFlatShadedMesh(): Mesh;
  20129. /**
  20130. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20131. * In other words, more vertices, no more indices and a single bigger VBO.
  20132. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20133. * Returns the Mesh.
  20134. */
  20135. convertToUnIndexedMesh(): Mesh;
  20136. /**
  20137. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  20138. * This method returns the Mesh.
  20139. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20140. */
  20141. flipFaces(flipNormals?: boolean): Mesh;
  20142. /**
  20143. * Creates a new InstancedMesh object from the mesh model.
  20144. * An instance shares the same properties and the same material than its model.
  20145. * Only these properties of each instance can then be set individually :
  20146. * - position
  20147. * - rotation
  20148. * - rotationQuaternion
  20149. * - setPivotMatrix
  20150. * - scaling
  20151. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  20152. * Warning : this method is not supported for Line mesh and LineSystem
  20153. */
  20154. createInstance(name: string): InstancedMesh;
  20155. /**
  20156. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20157. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20158. * This method returns the Mesh.
  20159. */
  20160. synchronizeInstances(): Mesh;
  20161. /**
  20162. * Simplify the mesh according to the given array of settings.
  20163. * Function will return immediately and will simplify async. It returns the Mesh.
  20164. * @param settings a collection of simplification settings.
  20165. * @param parallelProcessing should all levels calculate parallel or one after the other.
  20166. * @param type the type of simplification to run.
  20167. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  20168. */
  20169. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  20170. /**
  20171. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20172. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20173. * This should be used together with the simplification to avoid disappearing triangles.
  20174. * Returns the Mesh.
  20175. * @param successCallback an optional success callback to be called after the optimization finished.
  20176. */
  20177. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20178. serialize(serializationObject: any): void;
  20179. _syncGeometryWithMorphTargetManager(): void;
  20180. /**
  20181. * Returns a new Mesh object parsed from the source provided.
  20182. * The parameter `parsedMesh` is the source.
  20183. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  20184. */
  20185. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20186. /**
  20187. * Creates a ribbon mesh.
  20188. * Please consider using the same method from the MeshBuilder class instead.
  20189. * The ribbon is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  20190. *
  20191. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  20192. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20193. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  20194. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  20195. * 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.
  20196. * 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.
  20197. * 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
  20198. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20199. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20200. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20201. */
  20202. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20203. /**
  20204. * Creates a plane polygonal mesh. By default, this is a disc.
  20205. * Please consider using the same method from the MeshBuilder class instead.
  20206. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  20207. * 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.
  20208. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20209. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20210. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20211. */
  20212. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20213. /**
  20214. * Creates a box mesh.
  20215. * Please consider using the same method from the MeshBuilder class instead.
  20216. * The parameter `size` sets the size (float) of each box side (default 1).
  20217. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20218. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20219. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20220. */
  20221. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20222. /**
  20223. * Creates a sphere mesh.
  20224. * Please consider using the same method from the MeshBuilder class instead.
  20225. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  20226. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  20227. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20228. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20229. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20230. */
  20231. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20232. /**
  20233. * Creates a cylinder or a cone mesh.
  20234. * Please consider using the same method from the MeshBuilder class instead.
  20235. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  20236. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  20237. * 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.
  20238. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  20239. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  20240. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20241. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20242. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20243. */
  20244. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  20245. /**
  20246. * Creates a torus mesh.
  20247. * Please consider using the same method from the MeshBuilder class instead.
  20248. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  20249. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  20250. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  20251. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20252. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20253. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20254. */
  20255. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20256. /**
  20257. * Creates a torus knot mesh.
  20258. * Please consider using the same method from the MeshBuilder class instead.
  20259. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  20260. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  20261. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  20262. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  20263. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20264. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20265. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20266. */
  20267. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20268. /**
  20269. * Creates a line mesh.
  20270. * Please consider using the same method from the MeshBuilder class instead.
  20271. * 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.
  20272. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  20273. * The parameter `points` is an array successive Vector3.
  20274. * 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
  20275. * When updating an instance, remember that only point positions can change, not the number of points.
  20276. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20277. */
  20278. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  20279. /**
  20280. * Creates a dashed line mesh.
  20281. * Please consider using the same method from the MeshBuilder class instead.
  20282. * 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.
  20283. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  20284. * The parameter `points` is an array successive Vector3.
  20285. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  20286. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  20287. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  20288. * 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
  20289. * When updating an instance, remember that only point positions can change, not the number of points.
  20290. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20291. */
  20292. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  20293. /**
  20294. * Creates a polygon mesh.
  20295. * Please consider using the same method from the MeshBuilder class instead.
  20296. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  20297. * 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.
  20298. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20299. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20300. * Remember you can only change the shape positions, not their number when updating a polygon.
  20301. */
  20302. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  20303. /**
  20304. * Creates an extruded polygon mesh, with depth in the Y direction.
  20305. * Please consider using the same method from the MeshBuilder class instead.
  20306. */
  20307. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  20308. /**
  20309. * Creates an extruded shape mesh.
  20310. * The extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  20311. * Please consider using the same method from the MeshBuilder class instead.
  20312. *
  20313. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20314. * 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
  20315. * extruded along the Z axis.
  20316. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  20317. * 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.
  20318. * The parameter `scale` (float, default 1) is the value to scale the shape.
  20319. * 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
  20320. * 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
  20321. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  20322. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20323. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20324. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20325. */
  20326. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20327. /**
  20328. * Creates an custom extruded shape mesh.
  20329. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  20330. * Please consider using the same method from the MeshBuilder class instead.
  20331. *
  20332. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20333. * 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
  20334. * extruded along the Z axis.
  20335. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  20336. * 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
  20337. * and the distance of this point from the begining of the path :
  20338. * ```javascript
  20339. * var rotationFunction = function(i, distance) {
  20340. * // do things
  20341. * return rotationValue; }
  20342. * ```
  20343. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  20344. * 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
  20345. * and the distance of this point from the begining of the path :
  20346. * ```javascript
  20347. * var scaleFunction = function(i, distance) {
  20348. * // do things
  20349. * return scaleValue;}
  20350. * ```
  20351. * It must returns a float value that will be the scale value applied to the shape on each path point.
  20352. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  20353. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  20354. * 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
  20355. * 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
  20356. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  20357. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20358. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20359. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20360. */
  20361. 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;
  20362. /**
  20363. * Creates lathe mesh.
  20364. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  20365. * Please consider using the same method from the MeshBuilder class instead.
  20366. * 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
  20367. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  20368. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  20369. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  20370. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20371. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20372. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20373. */
  20374. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20375. /**
  20376. * Creates a plane mesh.
  20377. * Please consider using the same method from the MeshBuilder class instead.
  20378. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  20379. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20380. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20381. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20382. */
  20383. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20384. /**
  20385. * Creates a ground mesh.
  20386. * Please consider using the same method from the MeshBuilder class instead.
  20387. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  20388. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  20389. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20390. */
  20391. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  20392. /**
  20393. * Creates a tiled ground mesh.
  20394. * Please consider using the same method from the MeshBuilder class instead.
  20395. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  20396. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  20397. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  20398. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  20399. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  20400. * numbers of subdivisions on the ground width and height of each tile.
  20401. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20402. */
  20403. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  20404. w: number;
  20405. h: number;
  20406. }, precision: {
  20407. w: number;
  20408. h: number;
  20409. }, scene: Scene, updatable?: boolean): Mesh;
  20410. /**
  20411. * Creates a ground mesh from a height map.
  20412. * tuto : http://doc.babylonjs.com/babylon101/height_map
  20413. * Please consider using the same method from the MeshBuilder class instead.
  20414. * The parameter `url` sets the URL of the height map image resource.
  20415. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  20416. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  20417. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  20418. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  20419. * 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).
  20420. * This function is passed the newly built mesh :
  20421. * ```javascript
  20422. * function(mesh) { // do things
  20423. * return; }
  20424. * ```
  20425. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20426. */
  20427. 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;
  20428. /**
  20429. * Creates a tube mesh.
  20430. * The tube is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  20431. * Please consider using the same method from the MeshBuilder class instead.
  20432. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  20433. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  20434. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  20435. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  20436. * 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.
  20437. * It must return a radius value (positive float) :
  20438. * ```javascript
  20439. * var radiusFunction = function(i, distance) {
  20440. * // do things
  20441. * return radius; }
  20442. * ```
  20443. * 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
  20444. * 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
  20445. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20446. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20447. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20448. */
  20449. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  20450. (i: number, distance: number): number;
  20451. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20452. /**
  20453. * Creates a polyhedron mesh.
  20454. * Please consider using the same method from the MeshBuilder class instead.
  20455. * 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
  20456. * to choose the wanted type.
  20457. * The parameter `size` (positive float, default 1) sets the polygon size.
  20458. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  20459. * 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`.
  20460. * 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
  20461. * 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)`).
  20462. * 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
  20463. * 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.
  20464. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20465. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20466. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20467. */
  20468. static CreatePolyhedron(name: string, options: {
  20469. type?: number;
  20470. size?: number;
  20471. sizeX?: number;
  20472. sizeY?: number;
  20473. sizeZ?: number;
  20474. custom?: any;
  20475. faceUV?: Vector4[];
  20476. faceColors?: Color4[];
  20477. updatable?: boolean;
  20478. sideOrientation?: number;
  20479. }, scene: Scene): Mesh;
  20480. /**
  20481. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  20482. * Please consider using the same method from the MeshBuilder class instead.
  20483. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  20484. * 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`).
  20485. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  20486. * 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.
  20487. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20488. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20489. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20490. */
  20491. static CreateIcoSphere(name: string, options: {
  20492. radius?: number;
  20493. flat?: boolean;
  20494. subdivisions?: number;
  20495. sideOrientation?: number;
  20496. updatable?: boolean;
  20497. }, scene: Scene): Mesh;
  20498. /**
  20499. * Creates a decal mesh.
  20500. * Please consider using the same method from the MeshBuilder class instead.
  20501. * 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.
  20502. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  20503. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  20504. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  20505. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  20506. */
  20507. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  20508. /**
  20509. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20510. */
  20511. setPositionsForCPUSkinning(): Float32Array;
  20512. /**
  20513. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20514. */
  20515. setNormalsForCPUSkinning(): Float32Array;
  20516. /**
  20517. * Updates the vertex buffer by applying transformation from the bones.
  20518. * Returns the Mesh.
  20519. *
  20520. * @param {skeleton} skeleton to apply
  20521. */
  20522. applySkeleton(skeleton: Skeleton): Mesh;
  20523. /**
  20524. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  20525. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  20526. */
  20527. static MinMax(meshes: AbstractMesh[]): {
  20528. min: Vector3;
  20529. max: Vector3;
  20530. };
  20531. /**
  20532. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  20533. */
  20534. static Center(meshesOrMinMaxVector: {
  20535. min: Vector3;
  20536. max: Vector3;
  20537. } | AbstractMesh[]): Vector3;
  20538. /**
  20539. * Merge the array of meshes into a single mesh for performance reasons.
  20540. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  20541. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  20542. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  20543. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  20544. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  20545. */
  20546. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  20547. }
  20548. }
  20549. declare module BABYLON {
  20550. /**
  20551. * Define an interface for all classes that will get and set the data on vertices
  20552. */
  20553. interface IGetSetVerticesData {
  20554. isVerticesDataPresent(kind: string): boolean;
  20555. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20556. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  20557. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  20558. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  20559. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  20560. }
  20561. /**
  20562. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  20563. */
  20564. class VertexData {
  20565. /**
  20566. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  20567. */
  20568. positions: Nullable<FloatArray>;
  20569. /**
  20570. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  20571. */
  20572. normals: Nullable<FloatArray>;
  20573. /**
  20574. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  20575. */
  20576. tangents: Nullable<FloatArray>;
  20577. /**
  20578. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20579. */
  20580. uvs: Nullable<FloatArray>;
  20581. /**
  20582. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20583. */
  20584. uvs2: Nullable<FloatArray>;
  20585. /**
  20586. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20587. */
  20588. uvs3: Nullable<FloatArray>;
  20589. /**
  20590. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20591. */
  20592. uvs4: Nullable<FloatArray>;
  20593. /**
  20594. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20595. */
  20596. uvs5: Nullable<FloatArray>;
  20597. /**
  20598. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20599. */
  20600. uvs6: Nullable<FloatArray>;
  20601. /**
  20602. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  20603. */
  20604. colors: Nullable<FloatArray>;
  20605. /**
  20606. * 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).
  20607. */
  20608. matricesIndices: Nullable<FloatArray>;
  20609. /**
  20610. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  20611. */
  20612. matricesWeights: Nullable<FloatArray>;
  20613. /**
  20614. * An array extending the number of possible indices
  20615. */
  20616. matricesIndicesExtra: Nullable<FloatArray>;
  20617. /**
  20618. * An array extending the number of possible weights when the number of indices is extended
  20619. */
  20620. matricesWeightsExtra: Nullable<FloatArray>;
  20621. /**
  20622. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  20623. */
  20624. indices: Nullable<IndicesArray>;
  20625. /**
  20626. * Uses the passed data array to set the set the values for the specified kind of data
  20627. * @param data a linear array of floating numbers
  20628. * @param kind the type of data that is being set, eg positions, colors etc
  20629. */
  20630. set(data: FloatArray, kind: string): void;
  20631. /**
  20632. * Associates the vertexData to the passed Mesh.
  20633. * Sets it as updatable or not (default `false`)
  20634. * @param mesh the mesh the vertexData is applied to
  20635. * @param updatable when used and having the value true allows new data to update the vertexData
  20636. * @returns the VertexData
  20637. */
  20638. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  20639. /**
  20640. * Associates the vertexData to the passed Geometry.
  20641. * Sets it as updatable or not (default `false`)
  20642. * @param geometry the geometry the vertexData is applied to
  20643. * @param updatable when used and having the value true allows new data to update the vertexData
  20644. * @returns VertexData
  20645. */
  20646. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  20647. /**
  20648. * Updates the associated mesh
  20649. * @param mesh the mesh to be updated
  20650. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  20651. * @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
  20652. * @returns VertexData
  20653. */
  20654. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  20655. /**
  20656. * Updates the associated geometry
  20657. * @param geometry the geometry to be updated
  20658. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  20659. * @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
  20660. * @returns VertexData.
  20661. */
  20662. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  20663. private _applyTo(meshOrGeometry, updatable?);
  20664. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  20665. /**
  20666. * Transforms each position and each normal of the vertexData according to the passed Matrix
  20667. * @param matrix the transforming matrix
  20668. * @returns the VertexData
  20669. */
  20670. transform(matrix: Matrix): VertexData;
  20671. /**
  20672. * Merges the passed VertexData into the current one
  20673. * @param other the VertexData to be merged into the current one
  20674. * @returns the modified VertexData
  20675. */
  20676. merge(other: VertexData): VertexData;
  20677. private _mergeElement(source, other);
  20678. private _validate();
  20679. /**
  20680. * Serializes the VertexData
  20681. * @returns a serialized object
  20682. */
  20683. serialize(): any;
  20684. /**
  20685. * Extracts the vertexData from a mesh
  20686. * @param mesh the mesh from which to extract the VertexData
  20687. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  20688. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  20689. * @returns the object VertexData associated to the passed mesh
  20690. */
  20691. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  20692. /**
  20693. * Extracts the vertexData from the geometry
  20694. * @param geometry the geometry from which to extract the VertexData
  20695. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  20696. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  20697. * @returns the object VertexData associated to the passed mesh
  20698. */
  20699. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  20700. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  20701. /**
  20702. * Creates the VertexData for a Ribbon
  20703. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  20704. * * pathArray array of paths, each of which an array of successive Vector3
  20705. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  20706. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  20707. * * 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
  20708. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20709. * * 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)
  20710. * * 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)
  20711. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  20712. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  20713. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  20714. * @returns the VertexData of the ribbon
  20715. */
  20716. static CreateRibbon(options: {
  20717. pathArray: Vector3[][];
  20718. closeArray?: boolean;
  20719. closePath?: boolean;
  20720. offset?: number;
  20721. sideOrientation?: number;
  20722. frontUVs?: Vector4;
  20723. backUVs?: Vector4;
  20724. invertUV?: boolean;
  20725. uvs?: Vector2[];
  20726. colors?: Color4[];
  20727. }): VertexData;
  20728. /**
  20729. * Creates the VertexData for a box
  20730. * @param options an object used to set the following optional parameters for the box, required but can be empty
  20731. * * size sets the width, height and depth of the box to the value of size, optional default 1
  20732. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  20733. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  20734. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  20735. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  20736. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  20737. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20738. * * 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)
  20739. * * 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)
  20740. * @returns the VertexData of the box
  20741. */
  20742. static CreateBox(options: {
  20743. size?: number;
  20744. width?: number;
  20745. height?: number;
  20746. depth?: number;
  20747. faceUV?: Vector4[];
  20748. faceColors?: Color4[];
  20749. sideOrientation?: number;
  20750. frontUVs?: Vector4;
  20751. backUVs?: Vector4;
  20752. }): VertexData;
  20753. /**
  20754. * Creates the VertexData for an ellipsoid, defaults to a sphere
  20755. * @param options an object used to set the following optional parameters for the box, required but can be empty
  20756. * * segments sets the number of horizontal strips optional, default 32
  20757. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  20758. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  20759. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  20760. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  20761. * * 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
  20762. * * 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
  20763. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20764. * * 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)
  20765. * * 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)
  20766. * @returns the VertexData of the ellipsoid
  20767. */
  20768. static CreateSphere(options: {
  20769. segments?: number;
  20770. diameter?: number;
  20771. diameterX?: number;
  20772. diameterY?: number;
  20773. diameterZ?: number;
  20774. arc?: number;
  20775. slice?: number;
  20776. sideOrientation?: number;
  20777. frontUVs?: Vector4;
  20778. backUVs?: Vector4;
  20779. }): VertexData;
  20780. /**
  20781. * Creates the VertexData for a cylinder, cone or prism
  20782. * @param options an object used to set the following optional parameters for the box, required but can be empty
  20783. * * height sets the height (y direction) of the cylinder, optional, default 2
  20784. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  20785. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  20786. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  20787. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  20788. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  20789. * * 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
  20790. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  20791. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  20792. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  20793. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  20794. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20795. * * 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)
  20796. * * 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)
  20797. * @returns the VertexData of the cylinder, cone or prism
  20798. */
  20799. static CreateCylinder(options: {
  20800. height?: number;
  20801. diameterTop?: number;
  20802. diameterBottom?: number;
  20803. diameter?: number;
  20804. tessellation?: number;
  20805. subdivisions?: number;
  20806. arc?: number;
  20807. faceColors?: Color4[];
  20808. faceUV?: Vector4[];
  20809. hasRings?: boolean;
  20810. enclose?: boolean;
  20811. sideOrientation?: number;
  20812. frontUVs?: Vector4;
  20813. backUVs?: Vector4;
  20814. }): VertexData;
  20815. /**
  20816. * Creates the VertexData for a torus
  20817. * @param options an object used to set the following optional parameters for the box, required but can be empty
  20818. * * diameter the diameter of the torus, optional default 1
  20819. * * thickness the diameter of the tube forming the torus, optional default 0.5
  20820. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  20821. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20822. * * 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)
  20823. * * 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)
  20824. * @returns the VertexData of the torus
  20825. */
  20826. static CreateTorus(options: {
  20827. diameter?: number;
  20828. thickness?: number;
  20829. tessellation?: number;
  20830. sideOrientation?: number;
  20831. frontUVs?: Vector4;
  20832. backUVs?: Vector4;
  20833. }): VertexData;
  20834. /**
  20835. * Creates the VertexData of the LineSystem
  20836. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  20837. * - lines an array of lines, each line being an array of successive Vector3
  20838. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  20839. * @returns the VertexData of the LineSystem
  20840. */
  20841. static CreateLineSystem(options: {
  20842. lines: Vector3[][];
  20843. colors?: Nullable<Color4[][]>;
  20844. }): VertexData;
  20845. /**
  20846. * Create the VertexData for a DashedLines
  20847. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  20848. * - points an array successive Vector3
  20849. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  20850. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  20851. * - dashNb the intended total number of dashes, optional, default 200
  20852. * @returns the VertexData for the DashedLines
  20853. */
  20854. static CreateDashedLines(options: {
  20855. points: Vector3[];
  20856. dashSize?: number;
  20857. gapSize?: number;
  20858. dashNb?: number;
  20859. }): VertexData;
  20860. /**
  20861. * Creates the VertexData for a Ground
  20862. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  20863. * - width the width (x direction) of the ground, optional, default 1
  20864. * - height the height (z direction) of the ground, optional, default 1
  20865. * - subdivisions the number of subdivisions per side, optional, default 1
  20866. * @returns the VertexData of the Ground
  20867. */
  20868. static CreateGround(options: {
  20869. width?: number;
  20870. height?: number;
  20871. subdivisions?: number;
  20872. subdivisionsX?: number;
  20873. subdivisionsY?: number;
  20874. }): VertexData;
  20875. /**
  20876. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  20877. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  20878. * * xmin the ground minimum X coordinate, optional, default -1
  20879. * * zmin the ground minimum Z coordinate, optional, default -1
  20880. * * xmax the ground maximum X coordinate, optional, default 1
  20881. * * zmax the ground maximum Z coordinate, optional, default 1
  20882. * * 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}
  20883. * * 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}
  20884. * @returns the VertexData of the TiledGround
  20885. */
  20886. static CreateTiledGround(options: {
  20887. xmin: number;
  20888. zmin: number;
  20889. xmax: number;
  20890. zmax: number;
  20891. subdivisions?: {
  20892. w: number;
  20893. h: number;
  20894. };
  20895. precision?: {
  20896. w: number;
  20897. h: number;
  20898. };
  20899. }): VertexData;
  20900. /**
  20901. * Creates the VertexData of the Ground designed from a heightmap
  20902. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  20903. * * width the width (x direction) of the ground
  20904. * * height the height (z direction) of the ground
  20905. * * subdivisions the number of subdivisions per side
  20906. * * minHeight the minimum altitude on the ground, optional, default 0
  20907. * * maxHeight the maximum altitude on the ground, optional default 1
  20908. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  20909. * * buffer the array holding the image color data
  20910. * * bufferWidth the width of image
  20911. * * bufferHeight the height of image
  20912. * @returns the VertexData of the Ground designed from a heightmap
  20913. */
  20914. static CreateGroundFromHeightMap(options: {
  20915. width: number;
  20916. height: number;
  20917. subdivisions: number;
  20918. minHeight: number;
  20919. maxHeight: number;
  20920. colorFilter: Color3;
  20921. buffer: Uint8Array;
  20922. bufferWidth: number;
  20923. bufferHeight: number;
  20924. }): VertexData;
  20925. /**
  20926. * Creates the VertexData for a Plane
  20927. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  20928. * * size sets the width and height of the plane to the value of size, optional default 1
  20929. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  20930. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  20931. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20932. * * 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)
  20933. * * 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)
  20934. * @returns the VertexData of the box
  20935. */
  20936. static CreatePlane(options: {
  20937. size?: number;
  20938. width?: number;
  20939. height?: number;
  20940. sideOrientation?: number;
  20941. frontUVs?: Vector4;
  20942. backUVs?: Vector4;
  20943. }): VertexData;
  20944. /**
  20945. * Creates the VertexData of the Disc or regular Polygon
  20946. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  20947. * * radius the radius of the disc, optional default 0.5
  20948. * * tessellation the number of polygon sides, optional, default 64
  20949. * * 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
  20950. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20951. * * 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)
  20952. * * 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)
  20953. * @returns the VertexData of the box
  20954. */
  20955. static CreateDisc(options: {
  20956. radius?: number;
  20957. tessellation?: number;
  20958. arc?: number;
  20959. sideOrientation?: number;
  20960. frontUVs?: Vector4;
  20961. backUVs?: Vector4;
  20962. }): VertexData;
  20963. /**
  20964. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  20965. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  20966. * @param polygon a mesh built from polygonTriangulation.build()
  20967. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20968. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  20969. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  20970. * @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)
  20971. * @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)
  20972. * @returns the VertexData of the Polygon
  20973. */
  20974. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  20975. /**
  20976. * Creates the VertexData of the IcoSphere
  20977. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  20978. * * radius the radius of the IcoSphere, optional default 1
  20979. * * radiusX allows stretching in the x direction, optional, default radius
  20980. * * radiusY allows stretching in the y direction, optional, default radius
  20981. * * radiusZ allows stretching in the z direction, optional, default radius
  20982. * * flat when true creates a flat shaded mesh, optional, default true
  20983. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  20984. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20985. * * 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)
  20986. * * 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)
  20987. * @returns the VertexData of the IcoSphere
  20988. */
  20989. static CreateIcoSphere(options: {
  20990. radius?: number;
  20991. radiusX?: number;
  20992. radiusY?: number;
  20993. radiusZ?: number;
  20994. flat?: boolean;
  20995. subdivisions?: number;
  20996. sideOrientation?: number;
  20997. frontUVs?: Vector4;
  20998. backUVs?: Vector4;
  20999. }): VertexData;
  21000. /**
  21001. * Creates the VertexData for a Polyhedron
  21002. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21003. * * type provided types are:
  21004. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21005. * * 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)
  21006. * * size the size of the IcoSphere, optional default 1
  21007. * * sizeX allows stretching in the x direction, optional, default size
  21008. * * sizeY allows stretching in the y direction, optional, default size
  21009. * * sizeZ allows stretching in the z direction, optional, default size
  21010. * * 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
  21011. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21012. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21013. * * flat when true creates a flat shaded mesh, optional, default true
  21014. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21015. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21016. * * 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)
  21017. * * 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)
  21018. * @returns the VertexData of the Polyhedron
  21019. */
  21020. static CreatePolyhedron(options: {
  21021. type?: number;
  21022. size?: number;
  21023. sizeX?: number;
  21024. sizeY?: number;
  21025. sizeZ?: number;
  21026. custom?: any;
  21027. faceUV?: Vector4[];
  21028. faceColors?: Color4[];
  21029. flat?: boolean;
  21030. sideOrientation?: number;
  21031. frontUVs?: Vector4;
  21032. backUVs?: Vector4;
  21033. }): VertexData;
  21034. /**
  21035. * Creates the VertexData for a TorusKnot
  21036. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21037. * * radius the radius of the torus knot, optional, default 2
  21038. * * tube the thickness of the tube, optional, default 0.5
  21039. * * radialSegments the number of sides on each tube segments, optional, default 32
  21040. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21041. * * p the number of windings around the z axis, optional, default 2
  21042. * * q the number of windings around the x axis, optional, default 3
  21043. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21044. * * 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)
  21045. * * 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)
  21046. * @returns the VertexData of the Torus Knot
  21047. */
  21048. static CreateTorusKnot(options: {
  21049. radius?: number;
  21050. tube?: number;
  21051. radialSegments?: number;
  21052. tubularSegments?: number;
  21053. p?: number;
  21054. q?: number;
  21055. sideOrientation?: number;
  21056. frontUVs?: Vector4;
  21057. backUVs?: Vector4;
  21058. }): VertexData;
  21059. /**
  21060. * Compute normals for given positions and indices
  21061. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21062. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21063. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21064. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21065. * * facetNormals : optional array of facet normals (vector3)
  21066. * * facetPositions : optional array of facet positions (vector3)
  21067. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21068. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21069. * * bInfo : optional bounding info, required for facetPartitioning computation
  21070. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21071. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21072. * * useRightHandedSystem: optional boolean to for right handed system computation
  21073. * * depthSort : optional boolean to enable the facet depth sort computation
  21074. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21075. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21076. */
  21077. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21078. facetNormals?: any;
  21079. facetPositions?: any;
  21080. facetPartitioning?: any;
  21081. ratio?: number;
  21082. bInfo?: any;
  21083. bbSize?: Vector3;
  21084. subDiv?: any;
  21085. useRightHandedSystem?: boolean;
  21086. depthSort?: boolean;
  21087. distanceTo?: Vector3;
  21088. depthSortedFacets?: any;
  21089. }): void;
  21090. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  21091. /**
  21092. * Applies VertexData created from the imported parameters to the geometry
  21093. * @param parsedVertexData the parsed data from an imported file
  21094. * @param geometry the geometry to apply the VertexData to
  21095. */
  21096. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21097. }
  21098. }
  21099. declare module BABYLON {
  21100. /**
  21101. * Class containing static functions to help procedurally build meshes
  21102. */
  21103. class MeshBuilder {
  21104. private static updateSideOrientation(orientation?);
  21105. /**
  21106. * Creates a box mesh
  21107. * * The parameter `size` sets the size (float) of each box side (default 1)
  21108. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  21109. * * 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)
  21110. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  21111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21112. * * 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
  21113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21114. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  21115. * @param name defines the name of the mesh
  21116. * @param options defines the options used to create the mesh
  21117. * @param scene defines the hosting scene
  21118. * @returns the box mesh
  21119. */
  21120. static CreateBox(name: string, options: {
  21121. size?: number;
  21122. width?: number;
  21123. height?: number;
  21124. depth?: number;
  21125. faceUV?: Vector4[];
  21126. faceColors?: Color4[];
  21127. sideOrientation?: number;
  21128. frontUVs?: Vector4;
  21129. backUVs?: Vector4;
  21130. updatable?: boolean;
  21131. }, scene?: Nullable<Scene>): Mesh;
  21132. /**
  21133. * Creates a sphere mesh
  21134. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  21135. * * 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`)
  21136. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  21137. * * 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
  21138. * * 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)
  21139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21140. * * 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
  21141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21142. * @param name defines the name of the mesh
  21143. * @param options defines the options used to create the mesh
  21144. * @param scene defines the hosting scene
  21145. * @returns the sphere mesh
  21146. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  21147. */
  21148. static CreateSphere(name: string, options: {
  21149. segments?: number;
  21150. diameter?: number;
  21151. diameterX?: number;
  21152. diameterY?: number;
  21153. diameterZ?: number;
  21154. arc?: number;
  21155. slice?: number;
  21156. sideOrientation?: number;
  21157. frontUVs?: Vector4;
  21158. backUVs?: Vector4;
  21159. updatable?: boolean;
  21160. }, scene: any): Mesh;
  21161. /**
  21162. * Creates a plane polygonal mesh. By default, this is a disc
  21163. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  21164. * * 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
  21165. * * 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
  21166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21167. * * 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
  21168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21169. * @param name defines the name of the mesh
  21170. * @param options defines the options used to create the mesh
  21171. * @param scene defines the hosting scene
  21172. * @returns the plane polygonal mesh
  21173. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  21174. */
  21175. static CreateDisc(name: string, options: {
  21176. radius?: number;
  21177. tessellation?: number;
  21178. arc?: number;
  21179. updatable?: boolean;
  21180. sideOrientation?: number;
  21181. frontUVs?: Vector4;
  21182. backUVs?: Vector4;
  21183. }, scene?: Nullable<Scene>): Mesh;
  21184. /**
  21185. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21186. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21187. * * 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`)
  21188. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21189. * * 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
  21190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21191. * * 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
  21192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21193. * @param name defines the name of the mesh
  21194. * @param options defines the options used to create the mesh
  21195. * @param scene defines the hosting scene
  21196. * @returns the icosahedron mesh
  21197. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21198. */
  21199. static CreateIcoSphere(name: string, options: {
  21200. radius?: number;
  21201. radiusX?: number;
  21202. radiusY?: number;
  21203. radiusZ?: number;
  21204. flat?: boolean;
  21205. subdivisions?: number;
  21206. sideOrientation?: number;
  21207. frontUVs?: Vector4;
  21208. backUVs?: Vector4;
  21209. updatable?: boolean;
  21210. }, scene: Scene): Mesh;
  21211. /**
  21212. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  21213. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  21214. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  21215. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  21216. * * 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
  21217. * * 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
  21218. * * 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
  21219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21220. * * 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
  21221. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  21222. * * 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
  21223. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  21224. * * 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
  21225. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  21226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21227. * @param name defines the name of the mesh
  21228. * @param options defines the options used to create the mesh
  21229. * @param scene defines the hosting scene
  21230. * @returns the ribbon mesh
  21231. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21232. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  21233. */
  21234. static CreateRibbon(name: string, options: {
  21235. pathArray: Vector3[][];
  21236. closeArray?: boolean;
  21237. closePath?: boolean;
  21238. offset?: number;
  21239. updatable?: boolean;
  21240. sideOrientation?: number;
  21241. frontUVs?: Vector4;
  21242. backUVs?: Vector4;
  21243. instance?: Mesh;
  21244. invertUV?: boolean;
  21245. uvs?: Vector2[];
  21246. colors?: Color4[];
  21247. }, scene?: Nullable<Scene>): Mesh;
  21248. /**
  21249. * Creates a cylinder or a cone mesh
  21250. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21251. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21252. * * 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.
  21253. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21254. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21255. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  21256. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  21257. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  21258. * * 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).
  21259. * * 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
  21260. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  21261. * * 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
  21262. * * 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.
  21263. * * If `enclose` is false, a ring surface is one element.
  21264. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  21265. * * 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
  21266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21267. * * 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
  21268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21269. * @param name defines the name of the mesh
  21270. * @param options defines the options used to create the mesh
  21271. * @param scene defines the hosting scene
  21272. * @returns the cylinder mesh
  21273. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  21274. */
  21275. static CreateCylinder(name: string, options: {
  21276. height?: number;
  21277. diameterTop?: number;
  21278. diameterBottom?: number;
  21279. diameter?: number;
  21280. tessellation?: number;
  21281. subdivisions?: number;
  21282. arc?: number;
  21283. faceColors?: Color4[];
  21284. faceUV?: Vector4[];
  21285. updatable?: boolean;
  21286. hasRings?: boolean;
  21287. enclose?: boolean;
  21288. sideOrientation?: number;
  21289. frontUVs?: Vector4;
  21290. backUVs?: Vector4;
  21291. }, scene: any): Mesh;
  21292. /**
  21293. * Creates a torus mesh
  21294. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  21295. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  21296. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  21297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21298. * * 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
  21299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21300. * @param name defines the name of the mesh
  21301. * @param options defines the options used to create the mesh
  21302. * @param scene defines the hosting scene
  21303. * @returns the torus mesh
  21304. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  21305. */
  21306. static CreateTorus(name: string, options: {
  21307. diameter?: number;
  21308. thickness?: number;
  21309. tessellation?: number;
  21310. updatable?: boolean;
  21311. sideOrientation?: number;
  21312. frontUVs?: Vector4;
  21313. backUVs?: Vector4;
  21314. }, scene: any): Mesh;
  21315. /**
  21316. * Creates a torus knot mesh
  21317. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  21318. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  21319. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  21320. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  21321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21322. * * 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
  21323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21324. * @param name defines the name of the mesh
  21325. * @param options defines the options used to create the mesh
  21326. * @param scene defines the hosting scene
  21327. * @returns the torus knot mesh
  21328. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  21329. */
  21330. static CreateTorusKnot(name: string, options: {
  21331. radius?: number;
  21332. tube?: number;
  21333. radialSegments?: number;
  21334. tubularSegments?: number;
  21335. p?: number;
  21336. q?: number;
  21337. updatable?: boolean;
  21338. sideOrientation?: number;
  21339. frontUVs?: Vector4;
  21340. backUVs?: Vector4;
  21341. }, scene: any): Mesh;
  21342. /**
  21343. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  21344. * * 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
  21345. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  21346. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  21347. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  21348. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  21349. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  21350. * * 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
  21351. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  21352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21353. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  21354. * @param name defines the name of the new line system
  21355. * @param options defines the options used to create the line system
  21356. * @param scene defines the hosting scene
  21357. * @returns a new line system mesh
  21358. */
  21359. static CreateLineSystem(name: string, options: {
  21360. lines: Vector3[][];
  21361. updatable?: boolean;
  21362. instance?: Nullable<LinesMesh>;
  21363. colors?: Nullable<Color4[][]>;
  21364. useVertexAlpha?: boolean;
  21365. }, scene: Nullable<Scene>): LinesMesh;
  21366. /**
  21367. * Creates a line mesh
  21368. * 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
  21369. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  21370. * * The parameter `points` is an array successive Vector3
  21371. * * 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
  21372. * * The optional parameter `colors` is an array of successive Color4, one per line point
  21373. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  21374. * * When updating an instance, remember that only point positions can change, not the number of points
  21375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21376. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  21377. * @param name defines the name of the new line system
  21378. * @param options defines the options used to create the line system
  21379. * @param scene defines the hosting scene
  21380. * @returns a new line mesh
  21381. */
  21382. static CreateLines(name: string, options: {
  21383. points: Vector3[];
  21384. updatable?: boolean;
  21385. instance?: Nullable<LinesMesh>;
  21386. colors?: Color4[];
  21387. useVertexAlpha?: boolean;
  21388. }, scene?: Nullable<Scene>): LinesMesh;
  21389. /**
  21390. * Creates a dashed line mesh
  21391. * * 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
  21392. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  21393. * * The parameter `points` is an array successive Vector3
  21394. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  21395. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  21396. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21397. * * 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
  21398. * * When updating an instance, remember that only point positions can change, not the number of points
  21399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21400. * @param name defines the name of the mesh
  21401. * @param options defines the options used to create the mesh
  21402. * @param scene defines the hosting scene
  21403. * @returns the dashed line mesh
  21404. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  21405. */
  21406. static CreateDashedLines(name: string, options: {
  21407. points: Vector3[];
  21408. dashSize?: number;
  21409. gapSize?: number;
  21410. dashNb?: number;
  21411. updatable?: boolean;
  21412. instance?: LinesMesh;
  21413. }, scene?: Nullable<Scene>): LinesMesh;
  21414. /**
  21415. * 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.
  21416. * * 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.
  21417. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21418. * * 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.
  21419. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  21420. * * 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
  21421. * * 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
  21422. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21424. * * 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
  21425. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  21426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21427. * @param name defines the name of the mesh
  21428. * @param options defines the options used to create the mesh
  21429. * @param scene defines the hosting scene
  21430. * @returns the extruded shape mesh
  21431. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  21432. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21433. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21434. */
  21435. static ExtrudeShape(name: string, options: {
  21436. shape: Vector3[];
  21437. path: Vector3[];
  21438. scale?: number;
  21439. rotation?: number;
  21440. cap?: number;
  21441. updatable?: boolean;
  21442. sideOrientation?: number;
  21443. frontUVs?: Vector4;
  21444. backUVs?: Vector4;
  21445. instance?: Mesh;
  21446. invertUV?: boolean;
  21447. }, scene?: Nullable<Scene>): Mesh;
  21448. /**
  21449. * Creates an custom extruded shape mesh.
  21450. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  21451. * * 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.
  21452. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21453. * * 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
  21454. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  21455. * * 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
  21456. * * It must returns a float value that will be the scale value applied to the shape on each path point
  21457. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21458. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  21459. * * 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
  21460. * * 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
  21461. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  21462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21463. * * 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
  21464. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  21465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21466. * @param name defines the name of the mesh
  21467. * @param options defines the options used to create the mesh
  21468. * @param scene defines the hosting scene
  21469. * @returns the custom extruded shape mesh
  21470. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  21471. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  21472. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21473. */
  21474. static ExtrudeShapeCustom(name: string, options: {
  21475. shape: Vector3[];
  21476. path: Vector3[];
  21477. scaleFunction?: any;
  21478. rotationFunction?: any;
  21479. ribbonCloseArray?: boolean;
  21480. ribbonClosePath?: boolean;
  21481. cap?: number;
  21482. updatable?: boolean;
  21483. sideOrientation?: number;
  21484. frontUVs?: Vector4;
  21485. backUVs?: Vector4;
  21486. instance?: Mesh;
  21487. invertUV?: boolean;
  21488. }, scene: Scene): Mesh;
  21489. /**
  21490. * Creates lathe mesh.
  21491. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  21492. * * 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
  21493. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  21494. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  21495. * * 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
  21496. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  21497. * * 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
  21498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21499. * * 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
  21500. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  21501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21502. * @param name defines the name of the mesh
  21503. * @param options defines the options used to create the mesh
  21504. * @param scene defines the hosting scene
  21505. * @returns the lathe mesh
  21506. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  21507. */
  21508. static CreateLathe(name: string, options: {
  21509. shape: Vector3[];
  21510. radius?: number;
  21511. tessellation?: number;
  21512. arc?: number;
  21513. closed?: boolean;
  21514. updatable?: boolean;
  21515. sideOrientation?: number;
  21516. frontUVs?: Vector4;
  21517. backUVs?: Vector4;
  21518. cap?: number;
  21519. invertUV?: boolean;
  21520. }, scene: Scene): Mesh;
  21521. /**
  21522. * Creates a plane mesh
  21523. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  21524. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  21525. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  21526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21527. * * 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
  21528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21529. * @param name defines the name of the mesh
  21530. * @param options defines the options used to create the mesh
  21531. * @param scene defines the hosting scene
  21532. * @returns the plane mesh
  21533. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  21534. */
  21535. static CreatePlane(name: string, options: {
  21536. size?: number;
  21537. width?: number;
  21538. height?: number;
  21539. sideOrientation?: number;
  21540. frontUVs?: Vector4;
  21541. backUVs?: Vector4;
  21542. updatable?: boolean;
  21543. sourcePlane?: Plane;
  21544. }, scene: Scene): Mesh;
  21545. /**
  21546. * Creates a ground mesh
  21547. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  21548. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  21549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21550. * @param name defines the name of the mesh
  21551. * @param options defines the options used to create the mesh
  21552. * @param scene defines the hosting scene
  21553. * @returns the ground mesh
  21554. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  21555. */
  21556. static CreateGround(name: string, options: {
  21557. width?: number;
  21558. height?: number;
  21559. subdivisions?: number;
  21560. subdivisionsX?: number;
  21561. subdivisionsY?: number;
  21562. updatable?: boolean;
  21563. }, scene: any): Mesh;
  21564. /**
  21565. * Creates a tiled ground mesh
  21566. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  21567. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  21568. * * 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
  21569. * * 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
  21570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21571. * @param name defines the name of the mesh
  21572. * @param options defines the options used to create the mesh
  21573. * @param scene defines the hosting scene
  21574. * @returns the tiled ground mesh
  21575. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  21576. */
  21577. static CreateTiledGround(name: string, options: {
  21578. xmin: number;
  21579. zmin: number;
  21580. xmax: number;
  21581. zmax: number;
  21582. subdivisions?: {
  21583. w: number;
  21584. h: number;
  21585. };
  21586. precision?: {
  21587. w: number;
  21588. h: number;
  21589. };
  21590. updatable?: boolean;
  21591. }, scene: Scene): Mesh;
  21592. /**
  21593. * Creates a ground mesh from a height map
  21594. * * The parameter `url` sets the URL of the height map image resource.
  21595. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  21596. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  21597. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  21598. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  21599. * * 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.
  21600. * * 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).
  21601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21602. * @param name defines the name of the mesh
  21603. * @param url defines the url to the height map
  21604. * @param options defines the options used to create the mesh
  21605. * @param scene defines the hosting scene
  21606. * @returns the ground mesh
  21607. * @see http://doc.babylonjs.com/babylon101/height_map
  21608. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  21609. */
  21610. static CreateGroundFromHeightMap(name: string, url: string, options: {
  21611. width?: number;
  21612. height?: number;
  21613. subdivisions?: number;
  21614. minHeight?: number;
  21615. maxHeight?: number;
  21616. colorFilter?: Color3;
  21617. updatable?: boolean;
  21618. onReady?: (mesh: GroundMesh) => void;
  21619. }, scene: Scene): GroundMesh;
  21620. /**
  21621. * Creates a polygon mesh
  21622. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  21623. * * 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
  21624. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21626. * * 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)
  21627. * * Remember you can only change the shape positions, not their number when updating a polygon
  21628. * @param name defines the name of the mesh
  21629. * @param options defines the options used to create the mesh
  21630. * @param scene defines the hosting scene
  21631. * @returns the polygon mesh
  21632. */
  21633. static CreatePolygon(name: string, options: {
  21634. shape: Vector3[];
  21635. holes?: Vector3[][];
  21636. depth?: number;
  21637. faceUV?: Vector4[];
  21638. faceColors?: Color4[];
  21639. updatable?: boolean;
  21640. sideOrientation?: number;
  21641. frontUVs?: Vector4;
  21642. backUVs?: Vector4;
  21643. }, scene: Scene): Mesh;
  21644. /**
  21645. * Creates an extruded polygon mesh, with depth in the Y direction.
  21646. * * 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)
  21647. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  21648. * @param name defines the name of the mesh
  21649. * @param options defines the options used to create the mesh
  21650. * @param scene defines the hosting scene
  21651. * @returns the polygon mesh
  21652. */
  21653. static ExtrudePolygon(name: string, options: {
  21654. shape: Vector3[];
  21655. holes?: Vector3[][];
  21656. depth?: number;
  21657. faceUV?: Vector4[];
  21658. faceColors?: Color4[];
  21659. updatable?: boolean;
  21660. sideOrientation?: number;
  21661. frontUVs?: Vector4;
  21662. backUVs?: Vector4;
  21663. }, scene: Scene): Mesh;
  21664. /**
  21665. * Creates a tube mesh.
  21666. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  21667. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  21668. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  21669. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  21670. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  21671. * * 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)
  21672. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  21673. * * 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
  21674. * * 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
  21675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21676. * * 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
  21677. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  21678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21679. * @param name defines the name of the mesh
  21680. * @param options defines the options used to create the mesh
  21681. * @param scene defines the hosting scene
  21682. * @returns the tube mesh
  21683. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  21684. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  21685. */
  21686. static CreateTube(name: string, options: {
  21687. path: Vector3[];
  21688. radius?: number;
  21689. tessellation?: number;
  21690. radiusFunction?: {
  21691. (i: number, distance: number): number;
  21692. };
  21693. cap?: number;
  21694. arc?: number;
  21695. updatable?: boolean;
  21696. sideOrientation?: number;
  21697. frontUVs?: Vector4;
  21698. backUVs?: Vector4;
  21699. instance?: Mesh;
  21700. invertUV?: boolean;
  21701. }, scene: Scene): Mesh;
  21702. /**
  21703. * Creates a polyhedron mesh
  21704. * * 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
  21705. * * The parameter `size` (positive float, default 1) sets the polygon size
  21706. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21707. * * 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`
  21708. * * 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
  21709. * * 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)`)
  21710. * * 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
  21711. * * 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
  21712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21713. * * 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
  21714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21715. * @param name defines the name of the mesh
  21716. * @param options defines the options used to create the mesh
  21717. * @param scene defines the hosting scene
  21718. * @returns the polyhedron mesh
  21719. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  21720. */
  21721. static CreatePolyhedron(name: string, options: {
  21722. type?: number;
  21723. size?: number;
  21724. sizeX?: number;
  21725. sizeY?: number;
  21726. sizeZ?: number;
  21727. custom?: any;
  21728. faceUV?: Vector4[];
  21729. faceColors?: Color4[];
  21730. flat?: boolean;
  21731. updatable?: boolean;
  21732. sideOrientation?: number;
  21733. frontUVs?: Vector4;
  21734. backUVs?: Vector4;
  21735. }, scene: Scene): Mesh;
  21736. /**
  21737. * Creates a decal mesh.
  21738. * 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
  21739. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  21740. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  21741. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  21742. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  21743. * @param name defines the name of the mesh
  21744. * @param sourceMesh defines the mesh where the decal must be applied
  21745. * @param options defines the options used to create the mesh
  21746. * @param scene defines the hosting scene
  21747. * @returns the decal mesh
  21748. * @see http://doc.babylonjs.com/how_to/decals
  21749. */
  21750. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  21751. position?: Vector3;
  21752. normal?: Vector3;
  21753. size?: Vector3;
  21754. angle?: number;
  21755. }): Mesh;
  21756. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  21757. }
  21758. }
  21759. declare module BABYLON {
  21760. class MeshLODLevel {
  21761. distance: number;
  21762. mesh: Mesh;
  21763. constructor(distance: number, mesh: Mesh);
  21764. }
  21765. }
  21766. declare module BABYLON {
  21767. /**
  21768. * A simplifier interface for future simplification implementations.
  21769. */
  21770. interface ISimplifier {
  21771. /**
  21772. * Simplification of a given mesh according to the given settings.
  21773. * Since this requires computation, it is assumed that the function runs async.
  21774. * @param settings The settings of the simplification, including quality and distance
  21775. * @param successCallback A callback that will be called after the mesh was simplified.
  21776. * @param errorCallback in case of an error, this callback will be called. optional.
  21777. */
  21778. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  21779. }
  21780. /**
  21781. * Expected simplification settings.
  21782. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  21783. */
  21784. interface ISimplificationSettings {
  21785. quality: number;
  21786. distance: number;
  21787. optimizeMesh?: boolean;
  21788. }
  21789. class SimplificationSettings implements ISimplificationSettings {
  21790. quality: number;
  21791. distance: number;
  21792. optimizeMesh: boolean | undefined;
  21793. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  21794. }
  21795. interface ISimplificationTask {
  21796. settings: Array<ISimplificationSettings>;
  21797. simplificationType: SimplificationType;
  21798. mesh: Mesh;
  21799. successCallback?: () => void;
  21800. parallelProcessing: boolean;
  21801. }
  21802. class SimplificationQueue {
  21803. private _simplificationArray;
  21804. running: boolean;
  21805. constructor();
  21806. addTask(task: ISimplificationTask): void;
  21807. executeNext(): void;
  21808. runSimplification(task: ISimplificationTask): void;
  21809. private getSimplifier(task);
  21810. }
  21811. /**
  21812. * The implemented types of simplification
  21813. * At the moment only Quadratic Error Decimation is implemented
  21814. */
  21815. enum SimplificationType {
  21816. /** Quadratic error decimation */
  21817. QUADRATIC = 0,
  21818. }
  21819. class DecimationTriangle {
  21820. vertices: Array<DecimationVertex>;
  21821. normal: Vector3;
  21822. error: Array<number>;
  21823. deleted: boolean;
  21824. isDirty: boolean;
  21825. borderFactor: number;
  21826. deletePending: boolean;
  21827. originalOffset: number;
  21828. constructor(vertices: Array<DecimationVertex>);
  21829. }
  21830. class DecimationVertex {
  21831. position: Vector3;
  21832. id: number;
  21833. q: QuadraticMatrix;
  21834. isBorder: boolean;
  21835. triangleStart: number;
  21836. triangleCount: number;
  21837. originalOffsets: Array<number>;
  21838. constructor(position: Vector3, id: number);
  21839. updatePosition(newPosition: Vector3): void;
  21840. }
  21841. class QuadraticMatrix {
  21842. data: Array<number>;
  21843. constructor(data?: Array<number>);
  21844. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  21845. addInPlace(matrix: QuadraticMatrix): void;
  21846. addArrayInPlace(data: Array<number>): void;
  21847. add(matrix: QuadraticMatrix): QuadraticMatrix;
  21848. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  21849. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  21850. }
  21851. class Reference {
  21852. vertexId: number;
  21853. triangleId: number;
  21854. constructor(vertexId: number, triangleId: number);
  21855. }
  21856. /**
  21857. * An implementation of the Quadratic Error simplification algorithm.
  21858. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  21859. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  21860. * @author RaananW
  21861. */
  21862. class QuadraticErrorSimplification implements ISimplifier {
  21863. private _mesh;
  21864. private triangles;
  21865. private vertices;
  21866. private references;
  21867. private _reconstructedMesh;
  21868. syncIterations: number;
  21869. aggressiveness: number;
  21870. decimationIterations: number;
  21871. boundingBoxEpsilon: number;
  21872. constructor(_mesh: Mesh);
  21873. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  21874. private runDecimation(settings, submeshIndex, successCallback);
  21875. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  21876. private init(callback);
  21877. private reconstructMesh(submeshIndex);
  21878. private initDecimatedMesh();
  21879. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  21880. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  21881. private identifyBorder();
  21882. private updateMesh(identifyBorders?);
  21883. private vertexError(q, point);
  21884. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  21885. }
  21886. }
  21887. declare module BABYLON {
  21888. class Polygon {
  21889. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  21890. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  21891. static Parse(input: string): Vector2[];
  21892. static StartingAt(x: number, y: number): Path2;
  21893. }
  21894. class PolygonMeshBuilder {
  21895. private _points;
  21896. private _outlinepoints;
  21897. private _holes;
  21898. private _name;
  21899. private _scene;
  21900. private _epoints;
  21901. private _eholes;
  21902. private _addToepoint(points);
  21903. constructor(name: string, contours: Path2, scene: Scene);
  21904. constructor(name: string, contours: Vector2[], scene: Scene);
  21905. addHole(hole: Vector2[]): PolygonMeshBuilder;
  21906. build(updatable?: boolean, depth?: number): Mesh;
  21907. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  21908. }
  21909. }
  21910. declare module BABYLON {
  21911. class BaseSubMesh {
  21912. _materialDefines: Nullable<MaterialDefines>;
  21913. _materialEffect: Nullable<Effect>;
  21914. readonly effect: Nullable<Effect>;
  21915. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21916. }
  21917. class SubMesh extends BaseSubMesh implements ICullable {
  21918. materialIndex: number;
  21919. verticesStart: number;
  21920. verticesCount: number;
  21921. indexStart: number;
  21922. indexCount: number;
  21923. linesIndexCount: number;
  21924. private _mesh;
  21925. private _renderingMesh;
  21926. private _boundingInfo;
  21927. private _linesIndexBuffer;
  21928. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21929. _trianglePlanes: Plane[];
  21930. _lastColliderTransformMatrix: Matrix;
  21931. _renderId: number;
  21932. _alphaIndex: number;
  21933. _distanceToCamera: number;
  21934. _id: number;
  21935. private _currentMaterial;
  21936. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21937. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21938. readonly IsGlobal: boolean;
  21939. /**
  21940. * Returns the submesh BoudingInfo object.
  21941. */
  21942. getBoundingInfo(): BoundingInfo;
  21943. /**
  21944. * Sets the submesh BoundingInfo.
  21945. * Return the SubMesh.
  21946. */
  21947. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21948. /**
  21949. * Returns the mesh of the current submesh.
  21950. */
  21951. getMesh(): AbstractMesh;
  21952. /**
  21953. * Returns the rendering mesh of the submesh.
  21954. */
  21955. getRenderingMesh(): Mesh;
  21956. /**
  21957. * Returns the submesh material.
  21958. */
  21959. getMaterial(): Nullable<Material>;
  21960. /**
  21961. * Sets a new updated BoundingInfo object to the submesh.
  21962. * Returns the SubMesh.
  21963. */
  21964. refreshBoundingInfo(): SubMesh;
  21965. _checkCollision(collider: Collider): boolean;
  21966. /**
  21967. * Updates the submesh BoundingInfo.
  21968. * Returns the Submesh.
  21969. */
  21970. updateBoundingInfo(world: Matrix): SubMesh;
  21971. /**
  21972. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21973. * Boolean returned.
  21974. */
  21975. isInFrustum(frustumPlanes: Plane[]): boolean;
  21976. /**
  21977. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  21978. * Boolean returned.
  21979. */
  21980. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21981. /**
  21982. * Renders the submesh.
  21983. * Returns it.
  21984. */
  21985. render(enableAlphaMode: boolean): SubMesh;
  21986. /**
  21987. * Returns a new Index Buffer.
  21988. * Type returned : WebGLBuffer.
  21989. */
  21990. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  21991. /**
  21992. * True is the passed Ray intersects the submesh bounding box.
  21993. * Boolean returned.
  21994. */
  21995. canIntersects(ray: Ray): boolean;
  21996. /**
  21997. * Returns an object IntersectionInfo.
  21998. */
  21999. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  22000. _rebuild(): void;
  22001. /**
  22002. * Creates a new Submesh from the passed Mesh.
  22003. */
  22004. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22005. /**
  22006. * Disposes the Submesh.
  22007. * Returns nothing.
  22008. */
  22009. dispose(): void;
  22010. /**
  22011. * Creates a new Submesh from the passed parameters :
  22012. * - materialIndex (integer) : the index of the main mesh material.
  22013. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  22014. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  22015. * - mesh (Mesh) : the main mesh to create the submesh from.
  22016. * - renderingMesh (optional Mesh) : rendering mesh.
  22017. */
  22018. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22019. }
  22020. }
  22021. declare module BABYLON {
  22022. class TransformNode extends Node {
  22023. static BILLBOARDMODE_NONE: number;
  22024. static BILLBOARDMODE_X: number;
  22025. static BILLBOARDMODE_Y: number;
  22026. static BILLBOARDMODE_Z: number;
  22027. static BILLBOARDMODE_ALL: number;
  22028. private _forward;
  22029. private _forwardInverted;
  22030. private _up;
  22031. private _right;
  22032. private _rightInverted;
  22033. private _rotation;
  22034. private _rotationQuaternion;
  22035. protected _scaling: Vector3;
  22036. protected _isDirty: boolean;
  22037. private _transformToBoneReferal;
  22038. billboardMode: number;
  22039. scalingDeterminant: number;
  22040. infiniteDistance: boolean;
  22041. position: Vector3;
  22042. _poseMatrix: Matrix;
  22043. private _localWorld;
  22044. _worldMatrix: Matrix;
  22045. _worldMatrixDeterminant: number;
  22046. private _absolutePosition;
  22047. private _pivotMatrix;
  22048. private _pivotMatrixInverse;
  22049. private _postMultiplyPivotMatrix;
  22050. protected _isWorldMatrixFrozen: boolean;
  22051. /**
  22052. * An event triggered after the world matrix is updated
  22053. */
  22054. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  22055. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  22056. /**
  22057. * Gets a string idenfifying the name of the class
  22058. * @returns "TransformNode" string
  22059. */
  22060. getClassName(): string;
  22061. /**
  22062. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  22063. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  22064. * Default : (0.0, 0.0, 0.0)
  22065. */
  22066. rotation: Vector3;
  22067. /**
  22068. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  22069. * Default : (1.0, 1.0, 1.0)
  22070. */
  22071. /**
  22072. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  22073. * Default : (1.0, 1.0, 1.0)
  22074. */
  22075. scaling: Vector3;
  22076. /**
  22077. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  22078. * It's null by default.
  22079. * 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)
  22080. */
  22081. rotationQuaternion: Nullable<Quaternion>;
  22082. /**
  22083. * The forward direction of that transform in world space.
  22084. */
  22085. readonly forward: Vector3;
  22086. /**
  22087. * The up direction of that transform in world space.
  22088. */
  22089. readonly up: Vector3;
  22090. /**
  22091. * The right direction of that transform in world space.
  22092. */
  22093. readonly right: Vector3;
  22094. /**
  22095. * Returns the latest update of the World matrix
  22096. * Returns a Matrix.
  22097. */
  22098. getWorldMatrix(): Matrix;
  22099. /** @hidden */
  22100. _getWorldMatrixDeterminant(): number;
  22101. /**
  22102. * Returns directly the latest state of the mesh World matrix.
  22103. * A Matrix is returned.
  22104. */
  22105. readonly worldMatrixFromCache: Matrix;
  22106. /**
  22107. * Copies the paramater passed Matrix into the mesh Pose matrix.
  22108. * Returns the TransformNode.
  22109. */
  22110. updatePoseMatrix(matrix: Matrix): TransformNode;
  22111. /**
  22112. * Returns the mesh Pose matrix.
  22113. * Returned object : Matrix
  22114. */
  22115. getPoseMatrix(): Matrix;
  22116. _isSynchronized(): boolean;
  22117. _initCache(): void;
  22118. markAsDirty(property: string): TransformNode;
  22119. /**
  22120. * Returns the current mesh absolute position.
  22121. * Retuns a Vector3.
  22122. */
  22123. readonly absolutePosition: Vector3;
  22124. /**
  22125. * Sets a new matrix to apply before all other transformation
  22126. * @param matrix defines the transform matrix
  22127. * @returns the current TransformNode
  22128. */
  22129. setPreTransformMatrix(matrix: Matrix): TransformNode;
  22130. /**
  22131. * Sets a new pivot matrix to the current node
  22132. * @param matrix defines the new pivot matrix to use
  22133. * @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
  22134. * @returns the current TransformNode
  22135. */
  22136. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  22137. /**
  22138. * Returns the mesh pivot matrix.
  22139. * Default : Identity.
  22140. * A Matrix is returned.
  22141. */
  22142. getPivotMatrix(): Matrix;
  22143. /**
  22144. * Prevents the World matrix to be computed any longer.
  22145. * Returns the TransformNode.
  22146. */
  22147. freezeWorldMatrix(): TransformNode;
  22148. /**
  22149. * Allows back the World matrix computation.
  22150. * Returns the TransformNode.
  22151. */
  22152. unfreezeWorldMatrix(): this;
  22153. /**
  22154. * True if the World matrix has been frozen.
  22155. * Returns a boolean.
  22156. */
  22157. readonly isWorldMatrixFrozen: boolean;
  22158. /**
  22159. * Retuns the mesh absolute position in the World.
  22160. * Returns a Vector3.
  22161. */
  22162. getAbsolutePosition(): Vector3;
  22163. /**
  22164. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  22165. * Returns the TransformNode.
  22166. */
  22167. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22168. /**
  22169. * Sets the mesh position in its local space.
  22170. * Returns the TransformNode.
  22171. */
  22172. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  22173. /**
  22174. * Returns the mesh position in the local space from the current World matrix values.
  22175. * Returns a new Vector3.
  22176. */
  22177. getPositionExpressedInLocalSpace(): Vector3;
  22178. /**
  22179. * Translates the mesh along the passed Vector3 in its local space.
  22180. * Returns the TransformNode.
  22181. */
  22182. locallyTranslate(vector3: Vector3): TransformNode;
  22183. private static _lookAtVectorCache;
  22184. /**
  22185. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  22186. * @param targetPoint the position (must be in same space as current mesh) to look at
  22187. * @param yawCor optional yaw (y-axis) correction in radians
  22188. * @param pitchCor optional pitch (x-axis) correction in radians
  22189. * @param rollCor optional roll (z-axis) correction in radians
  22190. * @param space the choosen space of the target
  22191. * @returns the TransformNode.
  22192. */
  22193. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  22194. /**
  22195. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  22196. * This Vector3 is expressed in the World space.
  22197. */
  22198. getDirection(localAxis: Vector3): Vector3;
  22199. /**
  22200. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  22201. * localAxis is expressed in the mesh local space.
  22202. * result is computed in the Wordl space from the mesh World matrix.
  22203. * Returns the TransformNode.
  22204. */
  22205. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  22206. /**
  22207. * Sets a new pivot point to the current node
  22208. * @param point defines the new pivot point to use
  22209. * @param space defines if the point is in world or local space (local by default)
  22210. * @returns the current TransformNode
  22211. */
  22212. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  22213. /**
  22214. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  22215. */
  22216. getPivotPoint(): Vector3;
  22217. /**
  22218. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  22219. * Returns the TransformNode.
  22220. */
  22221. getPivotPointToRef(result: Vector3): TransformNode;
  22222. /**
  22223. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  22224. */
  22225. getAbsolutePivotPoint(): Vector3;
  22226. /**
  22227. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  22228. * Returns the TransformNode.
  22229. */
  22230. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  22231. /**
  22232. * Defines the passed node as the parent of the current node.
  22233. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  22234. * Returns the TransformNode.
  22235. */
  22236. setParent(node: Nullable<Node>): TransformNode;
  22237. private _nonUniformScaling;
  22238. readonly nonUniformScaling: boolean;
  22239. _updateNonUniformScalingState(value: boolean): boolean;
  22240. /**
  22241. * Attach the current TransformNode to another TransformNode associated with a bone
  22242. * @param bone Bone affecting the TransformNode
  22243. * @param affectedTransformNode TransformNode associated with the bone
  22244. */
  22245. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  22246. detachFromBone(): TransformNode;
  22247. private static _rotationAxisCache;
  22248. /**
  22249. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  22250. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  22251. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  22252. * The passed axis is also normalized.
  22253. * Returns the TransformNode.
  22254. */
  22255. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22256. /**
  22257. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  22258. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  22259. * The passed axis is also normalized.
  22260. * Returns the TransformNode.
  22261. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  22262. */
  22263. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  22264. /**
  22265. * Translates the mesh along the axis vector for the passed distance in the given space.
  22266. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  22267. * Returns the TransformNode.
  22268. */
  22269. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22270. /**
  22271. * Adds a rotation step to the mesh current rotation.
  22272. * x, y, z are Euler angles expressed in radians.
  22273. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  22274. * This means this rotation is made in the mesh local space only.
  22275. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  22276. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  22277. * ```javascript
  22278. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  22279. * ```
  22280. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  22281. * 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.
  22282. * Returns the TransformNode.
  22283. */
  22284. addRotation(x: number, y: number, z: number): TransformNode;
  22285. /**
  22286. * Computes the mesh World matrix and returns it.
  22287. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  22288. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  22289. * If the parameter `force`is set to `true`, the actual computation is done.
  22290. * Returns the mesh World Matrix.
  22291. */
  22292. computeWorldMatrix(force?: boolean): Matrix;
  22293. protected _afterComputeWorldMatrix(): void;
  22294. /**
  22295. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  22296. * @param func: callback function to add
  22297. *
  22298. * Returns the TransformNode.
  22299. */
  22300. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  22301. /**
  22302. * Removes a registered callback function.
  22303. * Returns the TransformNode.
  22304. */
  22305. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  22306. /**
  22307. * Clone the current transform node
  22308. * Returns the new transform node
  22309. * @param name Name of the new clone
  22310. * @param newParent New parent for the clone
  22311. * @param doNotCloneChildren Do not clone children hierarchy
  22312. */
  22313. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  22314. serialize(currentSerializationObject?: any): any;
  22315. /**
  22316. * Returns a new TransformNode object parsed from the source provided.
  22317. * The parameter `parsedMesh` is the source.
  22318. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  22319. */
  22320. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  22321. /**
  22322. * Releases resources associated with this transform node.
  22323. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22324. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22325. */
  22326. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22327. }
  22328. }
  22329. declare module BABYLON {
  22330. class VertexBuffer {
  22331. private _buffer;
  22332. private _kind;
  22333. private _size;
  22334. private _ownsBuffer;
  22335. private _instanced;
  22336. private _instanceDivisor;
  22337. /**
  22338. * The byte type.
  22339. */
  22340. static readonly BYTE: number;
  22341. /**
  22342. * The unsigned byte type.
  22343. */
  22344. static readonly UNSIGNED_BYTE: number;
  22345. /**
  22346. * The short type.
  22347. */
  22348. static readonly SHORT: number;
  22349. /**
  22350. * The unsigned short type.
  22351. */
  22352. static readonly UNSIGNED_SHORT: number;
  22353. /**
  22354. * The integer type.
  22355. */
  22356. static readonly INT: number;
  22357. /**
  22358. * The unsigned integer type.
  22359. */
  22360. static readonly UNSIGNED_INT: number;
  22361. /**
  22362. * The float type.
  22363. */
  22364. static readonly FLOAT: number;
  22365. /**
  22366. * Gets or sets the instance divisor when in instanced mode
  22367. */
  22368. instanceDivisor: number;
  22369. /**
  22370. * Gets the byte stride.
  22371. */
  22372. readonly byteStride: number;
  22373. /**
  22374. * Gets the byte offset.
  22375. */
  22376. readonly byteOffset: number;
  22377. /**
  22378. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  22379. */
  22380. readonly normalized: boolean;
  22381. /**
  22382. * Gets the data type of each component in the array.
  22383. */
  22384. readonly type: number;
  22385. /**
  22386. * Constructor
  22387. * @param engine the engine
  22388. * @param data the data to use for this vertex buffer
  22389. * @param kind the vertex buffer kind
  22390. * @param updatable whether the data is updatable
  22391. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  22392. * @param stride the stride (optional)
  22393. * @param instanced whether the buffer is instanced (optional)
  22394. * @param offset the offset of the data (optional)
  22395. * @param size the number of components (optional)
  22396. * @param type the type of the component (optional)
  22397. * @param normalized whether the data contains normalized data (optional)
  22398. * @param useBytes set to true if stride and offset are in bytes (optional)
  22399. */
  22400. 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);
  22401. _rebuild(): void;
  22402. /**
  22403. * Returns the kind of the VertexBuffer (string).
  22404. */
  22405. getKind(): string;
  22406. /**
  22407. * Boolean : is the VertexBuffer updatable ?
  22408. */
  22409. isUpdatable(): boolean;
  22410. /**
  22411. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  22412. */
  22413. getData(): Nullable<DataArray>;
  22414. /**
  22415. * Returns the WebGLBuffer associated to the VertexBuffer.
  22416. */
  22417. getBuffer(): Nullable<WebGLBuffer>;
  22418. /**
  22419. * Returns the stride as a multiple of the type byte length.
  22420. * DEPRECATED. Use byteStride instead.
  22421. */
  22422. getStrideSize(): number;
  22423. /**
  22424. * Returns the offset as a multiple of the type byte length.
  22425. * DEPRECATED. Use byteOffset instead.
  22426. */
  22427. getOffset(): number;
  22428. /**
  22429. * Returns the number of components per vertex attribute (integer).
  22430. */
  22431. getSize(): number;
  22432. /**
  22433. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  22434. */
  22435. getIsInstanced(): boolean;
  22436. /**
  22437. * Returns the instancing divisor, zero for non-instanced (integer).
  22438. */
  22439. getInstanceDivisor(): number;
  22440. /**
  22441. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  22442. * Returns the created WebGLBuffer.
  22443. */
  22444. create(data?: DataArray): void;
  22445. /**
  22446. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  22447. * This function will create a new buffer if the current one is not updatable
  22448. * Returns the updated WebGLBuffer.
  22449. */
  22450. update(data: DataArray): void;
  22451. /**
  22452. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  22453. * Returns the directly updated WebGLBuffer.
  22454. * @param data the new data
  22455. * @param offset the new offset
  22456. * @param useBytes set to true if the offset is in bytes
  22457. */
  22458. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  22459. /**
  22460. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  22461. */
  22462. dispose(): void;
  22463. /**
  22464. * Enumerates each value of this vertex buffer as numbers.
  22465. * @param count the number of values to enumerate
  22466. * @param callback the callback function called for each value
  22467. */
  22468. forEach(count: number, callback: (value: number, index: number) => void): void;
  22469. private static _PositionKind;
  22470. private static _NormalKind;
  22471. private static _TangentKind;
  22472. private static _UVKind;
  22473. private static _UV2Kind;
  22474. private static _UV3Kind;
  22475. private static _UV4Kind;
  22476. private static _UV5Kind;
  22477. private static _UV6Kind;
  22478. private static _ColorKind;
  22479. private static _MatricesIndicesKind;
  22480. private static _MatricesWeightsKind;
  22481. private static _MatricesIndicesExtraKind;
  22482. private static _MatricesWeightsExtraKind;
  22483. static readonly PositionKind: string;
  22484. static readonly NormalKind: string;
  22485. static readonly TangentKind: string;
  22486. static readonly UVKind: string;
  22487. static readonly UV2Kind: string;
  22488. static readonly UV3Kind: string;
  22489. static readonly UV4Kind: string;
  22490. static readonly UV5Kind: string;
  22491. static readonly UV6Kind: string;
  22492. static readonly ColorKind: string;
  22493. static readonly MatricesIndicesKind: string;
  22494. static readonly MatricesWeightsKind: string;
  22495. static readonly MatricesIndicesExtraKind: string;
  22496. static readonly MatricesWeightsExtraKind: string;
  22497. /**
  22498. * Deduces the stride given a kind.
  22499. * @param kind The kind string to deduce
  22500. * @returns The deduced stride
  22501. */
  22502. static DeduceStride(kind: string): number;
  22503. /**
  22504. * Gets the byte length of the given type.
  22505. * @param type the type
  22506. * @returns the number of bytes
  22507. */
  22508. static GetTypeByteLength(type: number): number;
  22509. /**
  22510. * Enumerates each value of the given parameters as numbers.
  22511. * @param data the data to enumerate
  22512. * @param byteOffset the byte offset of the data
  22513. * @param byteStride the byte stride of the data
  22514. * @param componentCount the number of components per element
  22515. * @param componentType the type of the component
  22516. * @param count the total number of components
  22517. * @param normalized whether the data is normalized
  22518. * @param callback the callback function called for each value
  22519. */
  22520. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  22521. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  22522. }
  22523. }
  22524. declare module BABYLON {
  22525. /**
  22526. * Defines a target to use with MorphTargetManager
  22527. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22528. */
  22529. class MorphTarget implements IAnimatable {
  22530. /** defines the name of the target */
  22531. name: string;
  22532. /**
  22533. * Gets or sets the list of animations
  22534. */
  22535. animations: Animation[];
  22536. private _scene;
  22537. private _positions;
  22538. private _normals;
  22539. private _tangents;
  22540. private _influence;
  22541. /**
  22542. * Observable raised when the influence changes
  22543. */
  22544. onInfluenceChanged: Observable<boolean>;
  22545. /**
  22546. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22547. */
  22548. influence: number;
  22549. private _animationPropertiesOverride;
  22550. /**
  22551. * Gets or sets the animation properties override
  22552. */
  22553. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22554. /**
  22555. * Creates a new MorphTarget
  22556. * @param name defines the name of the target
  22557. * @param influence defines the influence to use
  22558. */
  22559. constructor(
  22560. /** defines the name of the target */
  22561. name: string, influence?: number, scene?: Nullable<Scene>);
  22562. /**
  22563. * Gets a boolean defining if the target contains position data
  22564. */
  22565. readonly hasPositions: boolean;
  22566. /**
  22567. * Gets a boolean defining if the target contains normal data
  22568. */
  22569. readonly hasNormals: boolean;
  22570. /**
  22571. * Gets a boolean defining if the target contains tangent data
  22572. */
  22573. readonly hasTangents: boolean;
  22574. /**
  22575. * Affects position data to this target
  22576. * @param data defines the position data to use
  22577. */
  22578. setPositions(data: Nullable<FloatArray>): void;
  22579. /**
  22580. * Gets the position data stored in this target
  22581. * @returns a FloatArray containing the position data (or null if not present)
  22582. */
  22583. getPositions(): Nullable<FloatArray>;
  22584. /**
  22585. * Affects normal data to this target
  22586. * @param data defines the normal data to use
  22587. */
  22588. setNormals(data: Nullable<FloatArray>): void;
  22589. /**
  22590. * Gets the normal data stored in this target
  22591. * @returns a FloatArray containing the normal data (or null if not present)
  22592. */
  22593. getNormals(): Nullable<FloatArray>;
  22594. /**
  22595. * Affects tangent data to this target
  22596. * @param data defines the tangent data to use
  22597. */
  22598. setTangents(data: Nullable<FloatArray>): void;
  22599. /**
  22600. * Gets the tangent data stored in this target
  22601. * @returns a FloatArray containing the tangent data (or null if not present)
  22602. */
  22603. getTangents(): Nullable<FloatArray>;
  22604. /**
  22605. * Serializes the current target into a Serialization object
  22606. * @returns the serialized object
  22607. */
  22608. serialize(): any;
  22609. /**
  22610. * Creates a new target from serialized data
  22611. * @param serializationObject defines the serialized data to use
  22612. * @returns a new MorphTarget
  22613. */
  22614. static Parse(serializationObject: any): MorphTarget;
  22615. /**
  22616. * Creates a MorphTarget from mesh data
  22617. * @param mesh defines the source mesh
  22618. * @param name defines the name to use for the new target
  22619. * @param influence defines the influence to attach to the target
  22620. * @returns a new MorphTarget
  22621. */
  22622. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22623. }
  22624. }
  22625. declare module BABYLON {
  22626. /**
  22627. * This class is used to deform meshes using morphing between different targets
  22628. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22629. */
  22630. class MorphTargetManager {
  22631. private _targets;
  22632. private _targetObservable;
  22633. private _activeTargets;
  22634. private _scene;
  22635. private _influences;
  22636. private _supportsNormals;
  22637. private _supportsTangents;
  22638. private _vertexCount;
  22639. private _uniqueId;
  22640. private _tempInfluences;
  22641. /**
  22642. * Creates a new MorphTargetManager
  22643. * @param scene defines the current scene
  22644. */
  22645. constructor(scene?: Nullable<Scene>);
  22646. /**
  22647. * Gets the unique ID of this manager
  22648. */
  22649. readonly uniqueId: number;
  22650. /**
  22651. * Gets the number of vertices handled by this manager
  22652. */
  22653. readonly vertexCount: number;
  22654. /**
  22655. * Gets a boolean indicating if this manager supports morphing of normals
  22656. */
  22657. readonly supportsNormals: boolean;
  22658. /**
  22659. * Gets a boolean indicating if this manager supports morphing of tangents
  22660. */
  22661. readonly supportsTangents: boolean;
  22662. /**
  22663. * Gets the number of targets stored in this manager
  22664. */
  22665. readonly numTargets: number;
  22666. /**
  22667. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22668. */
  22669. readonly numInfluencers: number;
  22670. /**
  22671. * Gets the list of influences (one per target)
  22672. */
  22673. readonly influences: Float32Array;
  22674. /**
  22675. * Gets the active target at specified index. An active target is a target with an influence > 0
  22676. * @param index defines the index to check
  22677. * @returns the requested target
  22678. */
  22679. getActiveTarget(index: number): MorphTarget;
  22680. /**
  22681. * Gets the target at specified index
  22682. * @param index defines the index to check
  22683. * @returns the requested target
  22684. */
  22685. getTarget(index: number): MorphTarget;
  22686. /**
  22687. * Add a new target to this manager
  22688. * @param target defines the target to add
  22689. */
  22690. addTarget(target: MorphTarget): void;
  22691. /**
  22692. * Removes a target from the manager
  22693. * @param target defines the target to remove
  22694. */
  22695. removeTarget(target: MorphTarget): void;
  22696. /**
  22697. * Serializes the current manager into a Serialization object
  22698. * @returns the serialized object
  22699. */
  22700. serialize(): any;
  22701. private _syncActiveTargets(needUpdate);
  22702. /**
  22703. * Syncrhonize the targets with all the meshes using this morph target manager
  22704. */
  22705. synchronize(): void;
  22706. /**
  22707. * Creates a new MorphTargetManager from serialized data
  22708. * @param serializationObject defines the serialized data
  22709. * @param scene defines the hosting scene
  22710. * @returns the new MorphTargetManager
  22711. */
  22712. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22713. }
  22714. }
  22715. declare module BABYLON {
  22716. /**
  22717. * This represents a GPU particle system in Babylon
  22718. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  22719. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  22720. */
  22721. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  22722. /**
  22723. * The id of the Particle system.
  22724. */
  22725. id: string;
  22726. /**
  22727. * The friendly name of the Particle system.
  22728. */
  22729. name: string;
  22730. /**
  22731. * The emitter represents the Mesh or position we are attaching the particle system to.
  22732. */
  22733. emitter: Nullable<AbstractMesh | Vector3>;
  22734. /**
  22735. * The rendering group used by the Particle system to chose when to render.
  22736. */
  22737. renderingGroupId: number;
  22738. /**
  22739. * The layer mask we are rendering the particles through.
  22740. */
  22741. layerMask: number;
  22742. private _capacity;
  22743. private _activeCount;
  22744. private _currentActiveCount;
  22745. private _renderEffect;
  22746. private _updateEffect;
  22747. private _buffer0;
  22748. private _buffer1;
  22749. private _spriteBuffer;
  22750. private _updateVAO;
  22751. private _renderVAO;
  22752. private _targetIndex;
  22753. private _sourceBuffer;
  22754. private _targetBuffer;
  22755. private _scene;
  22756. private _engine;
  22757. private _currentRenderId;
  22758. private _started;
  22759. private _stopped;
  22760. private _timeDelta;
  22761. private _randomTexture;
  22762. private readonly _attributesStrideSize;
  22763. private _updateEffectOptions;
  22764. private _randomTextureSize;
  22765. private _actualFrame;
  22766. /**
  22767. * List of animations used by the particle system.
  22768. */
  22769. animations: Animation[];
  22770. /**
  22771. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  22772. */
  22773. static readonly IsSupported: boolean;
  22774. /**
  22775. * An event triggered when the system is disposed.
  22776. */
  22777. onDisposeObservable: Observable<GPUParticleSystem>;
  22778. /**
  22779. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  22780. */
  22781. updateSpeed: number;
  22782. /**
  22783. * The amount of time the particle system is running (depends of the overall update speed).
  22784. */
  22785. targetStopDuration: number;
  22786. /**
  22787. * The texture used to render each particle. (this can be a spritesheet)
  22788. */
  22789. particleTexture: Nullable<Texture>;
  22790. /**
  22791. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  22792. */
  22793. blendMode: number;
  22794. /**
  22795. * Minimum life time of emitting particles.
  22796. */
  22797. minLifeTime: number;
  22798. /**
  22799. * Maximum life time of emitting particles.
  22800. */
  22801. maxLifeTime: number;
  22802. /**
  22803. * Minimum Size of emitting particles.
  22804. */
  22805. minSize: number;
  22806. /**
  22807. * Maximum Size of emitting particles.
  22808. */
  22809. maxSize: number;
  22810. /**
  22811. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  22812. */
  22813. color1: Color4;
  22814. /**
  22815. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  22816. */
  22817. color2: Color4;
  22818. /**
  22819. * Color the particle will have at the end of its lifetime.
  22820. */
  22821. colorDead: Color4;
  22822. /**
  22823. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  22824. */
  22825. emitRate: number;
  22826. /**
  22827. * You can use gravity if you want to give an orientation to your particles.
  22828. */
  22829. gravity: Vector3;
  22830. /**
  22831. * Minimum power of emitting particles.
  22832. */
  22833. minEmitPower: number;
  22834. /**
  22835. * Maximum power of emitting particles.
  22836. */
  22837. maxEmitPower: number;
  22838. /**
  22839. * The particle emitter type defines the emitter used by the particle system.
  22840. * It can be for example box, sphere, or cone...
  22841. */
  22842. particleEmitterType: Nullable<IParticleEmitterType>;
  22843. /**
  22844. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  22845. * This only works when particleEmitterTyps is a BoxParticleEmitter
  22846. */
  22847. direction1: Vector3;
  22848. /**
  22849. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  22850. * This only works when particleEmitterTyps is a BoxParticleEmitter
  22851. */
  22852. direction2: Vector3;
  22853. /**
  22854. * 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.
  22855. * This only works when particleEmitterTyps is a BoxParticleEmitter
  22856. */
  22857. minEmitBox: Vector3;
  22858. /**
  22859. * 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.
  22860. * This only works when particleEmitterTyps is a BoxParticleEmitter
  22861. */
  22862. maxEmitBox: Vector3;
  22863. /**
  22864. * Gets the maximum number of particles active at the same time.
  22865. * @returns The max number of active particles.
  22866. */
  22867. getCapacity(): number;
  22868. /**
  22869. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  22870. * to override the particles.
  22871. */
  22872. forceDepthWrite: boolean;
  22873. /**
  22874. * Gets or set the number of active particles
  22875. */
  22876. activeParticleCount: number;
  22877. /**
  22878. * Is this system ready to be used/rendered
  22879. * @return true if the system is ready
  22880. */
  22881. isReady(): boolean;
  22882. /**
  22883. * Gets Wether the system has been started.
  22884. * @returns True if it has been started, otherwise false.
  22885. */
  22886. isStarted(): boolean;
  22887. /**
  22888. * Starts the particle system and begins to emit.
  22889. */
  22890. start(): void;
  22891. /**
  22892. * Stops the particle system.
  22893. */
  22894. stop(): void;
  22895. /**
  22896. * Remove all active particles
  22897. */
  22898. reset(): void;
  22899. /**
  22900. * Returns the string "GPUParticleSystem"
  22901. * @returns a string containing the class name
  22902. */
  22903. getClassName(): string;
  22904. /**
  22905. * Instantiates a GPU particle system.
  22906. * 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.
  22907. * @param name The name of the particle system
  22908. * @param capacity The max number of particles alive at the same time
  22909. * @param scene The scene the particle system belongs to
  22910. */
  22911. constructor(name: string, options: Partial<{
  22912. capacity: number;
  22913. randomTextureSize: number;
  22914. }>, scene: Scene);
  22915. private _createUpdateVAO(source);
  22916. private _createRenderVAO(source, spriteSource);
  22917. private _initialize(force?);
  22918. /** @hidden */
  22919. _recreateUpdateEffect(): void;
  22920. /** @hidden */
  22921. _recreateRenderEffect(): void;
  22922. /**
  22923. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  22924. */
  22925. animate(): void;
  22926. /**
  22927. * Renders the particle system in its current state.
  22928. * @returns the current number of particles
  22929. */
  22930. render(): number;
  22931. /**
  22932. * Rebuilds the particle system
  22933. */
  22934. rebuild(): void;
  22935. private _releaseBuffers();
  22936. private _releaseVAOs();
  22937. /**
  22938. * Disposes the particle system and free the associated resources
  22939. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  22940. */
  22941. dispose(disposeTexture?: boolean): void;
  22942. /**
  22943. * Clones the particle system.
  22944. * @param name The name of the cloned object
  22945. * @param newEmitter The new emitter to use
  22946. * @returns the cloned particle system
  22947. */
  22948. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  22949. /**
  22950. * Serializes the particle system to a JSON object.
  22951. * @returns the JSON object
  22952. */
  22953. serialize(): any;
  22954. /**
  22955. * Parses a JSON object to create a GPU particle system.
  22956. * @param parsedParticleSystem The JSON object to parse
  22957. * @param scene The scene to create the particle system in
  22958. * @param rootUrl The root url to use to load external dependencies like texture
  22959. * @returns the parsed GPU particle system
  22960. */
  22961. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  22962. }
  22963. }
  22964. declare module BABYLON {
  22965. /**
  22966. * Interface representing a particle system in Babylon.
  22967. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  22968. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  22969. */
  22970. interface IParticleSystem {
  22971. /**
  22972. * The id of the Particle system.
  22973. */
  22974. id: string;
  22975. /**
  22976. * The name of the Particle system.
  22977. */
  22978. name: string;
  22979. /**
  22980. * The emitter represents the Mesh or position we are attaching the particle system to.
  22981. */
  22982. emitter: Nullable<AbstractMesh | Vector3>;
  22983. /**
  22984. * The rendering group used by the Particle system to chose when to render.
  22985. */
  22986. renderingGroupId: number;
  22987. /**
  22988. * The layer mask we are rendering the particles through.
  22989. */
  22990. layerMask: number;
  22991. /**
  22992. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  22993. */
  22994. updateSpeed: number;
  22995. /**
  22996. * The amount of time the particle system is running (depends of the overall update speed).
  22997. */
  22998. targetStopDuration: number;
  22999. /**
  23000. * The texture used to render each particle. (this can be a spritesheet)
  23001. */
  23002. particleTexture: Nullable<Texture>;
  23003. /**
  23004. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  23005. */
  23006. blendMode: number;
  23007. /**
  23008. * Minimum life time of emitting particles.
  23009. */
  23010. minLifeTime: number;
  23011. /**
  23012. * Maximum life time of emitting particles.
  23013. */
  23014. maxLifeTime: number;
  23015. /**
  23016. * Minimum Size of emitting particles.
  23017. */
  23018. minSize: number;
  23019. /**
  23020. * Maximum Size of emitting particles.
  23021. */
  23022. maxSize: number;
  23023. /**
  23024. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23025. */
  23026. color1: Color4;
  23027. /**
  23028. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23029. */
  23030. color2: Color4;
  23031. /**
  23032. * Color the particle will have at the end of its lifetime.
  23033. */
  23034. colorDead: Color4;
  23035. /**
  23036. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  23037. */
  23038. emitRate: number;
  23039. /**
  23040. * You can use gravity if you want to give an orientation to your particles.
  23041. */
  23042. gravity: Vector3;
  23043. /**
  23044. * Minimum power of emitting particles.
  23045. */
  23046. minEmitPower: number;
  23047. /**
  23048. * Maximum power of emitting particles.
  23049. */
  23050. maxEmitPower: number;
  23051. /**
  23052. * The particle emitter type defines the emitter used by the particle system.
  23053. * It can be for example box, sphere, or cone...
  23054. */
  23055. particleEmitterType: Nullable<IParticleEmitterType>;
  23056. /**
  23057. * Gets the maximum number of particles active at the same time.
  23058. * @returns The max number of active particles.
  23059. */
  23060. getCapacity(): number;
  23061. /**
  23062. * Gets Wether the system has been started.
  23063. * @returns True if it has been started, otherwise false.
  23064. */
  23065. isStarted(): boolean;
  23066. /**
  23067. * Gets if the particle system has been started.
  23068. * @return true if the system has been started, otherwise false.
  23069. */
  23070. isStarted(): boolean;
  23071. /**
  23072. * Animates the particle system for this frame.
  23073. */
  23074. animate(): void;
  23075. /**
  23076. * Renders the particle system in its current state.
  23077. * @returns the current number of particles
  23078. */
  23079. render(): number;
  23080. /**
  23081. * Dispose the particle system and frees its associated resources.
  23082. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  23083. */
  23084. dispose(disposeTexture?: boolean): void;
  23085. /**
  23086. * Clones the particle system.
  23087. * @param name The name of the cloned object
  23088. * @param newEmitter The new emitter to use
  23089. * @returns the cloned particle system
  23090. */
  23091. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  23092. /**
  23093. * Serializes the particle system to a JSON object.
  23094. * @returns the JSON object
  23095. */
  23096. serialize(): any;
  23097. /**
  23098. * Rebuild the particle system
  23099. */
  23100. rebuild(): void;
  23101. /**
  23102. * Starts the particle system and begins to emit.
  23103. */
  23104. start(): void;
  23105. /**
  23106. * Stops the particle system.
  23107. */
  23108. stop(): void;
  23109. /**
  23110. * Remove all active particles
  23111. */
  23112. reset(): void;
  23113. /**
  23114. * Is this system ready to be used/rendered
  23115. * @return true if the system is ready
  23116. */
  23117. isReady(): boolean;
  23118. }
  23119. }
  23120. declare module BABYLON {
  23121. /**
  23122. * A particle represents one of the element emitted by a particle system.
  23123. * This is mainly define by its coordinates, direction, velocity and age.
  23124. */
  23125. class Particle {
  23126. /**
  23127. * particleSystem the particle system the particle belongs to.
  23128. */
  23129. particleSystem: ParticleSystem;
  23130. /**
  23131. * The world position of the particle in the scene.
  23132. */
  23133. position: Vector3;
  23134. /**
  23135. * The world direction of the particle in the scene.
  23136. */
  23137. direction: Vector3;
  23138. /**
  23139. * The color of the particle.
  23140. */
  23141. color: Color4;
  23142. /**
  23143. * The color change of the particle per step.
  23144. */
  23145. colorStep: Color4;
  23146. /**
  23147. * Defines how long will the life of the particle be.
  23148. */
  23149. lifeTime: number;
  23150. /**
  23151. * The current age of the particle.
  23152. */
  23153. age: number;
  23154. /**
  23155. * The current size of the particle.
  23156. */
  23157. size: number;
  23158. /**
  23159. * The current angle of the particle.
  23160. */
  23161. angle: number;
  23162. /**
  23163. * Defines how fast is the angle changing.
  23164. */
  23165. angularSpeed: number;
  23166. /**
  23167. * Defines the cell index used by the particle to be rendered from a sprite.
  23168. */
  23169. cellIndex: number;
  23170. private _currentFrameCounter;
  23171. /**
  23172. * Creates a new instance Particle
  23173. * @param particleSystem the particle system the particle belongs to
  23174. */
  23175. constructor(
  23176. /**
  23177. * particleSystem the particle system the particle belongs to.
  23178. */
  23179. particleSystem: ParticleSystem);
  23180. private updateCellInfoFromSystem();
  23181. /**
  23182. * Defines how the sprite cell index is updated for the particle. This is
  23183. * defined as a callback.
  23184. */
  23185. updateCellIndex: (scaledUpdateSpeed: number) => void;
  23186. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  23187. private _updateCellIndexWithCustomSpeed();
  23188. /**
  23189. * Copy the properties of particle to another one.
  23190. * @param other the particle to copy the information to.
  23191. */
  23192. copyTo(other: Particle): void;
  23193. }
  23194. }
  23195. declare module BABYLON {
  23196. /**
  23197. * This represents a particle system in Babylon.
  23198. * 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.
  23199. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  23200. * @example https://doc.babylonjs.com/babylon101/particles
  23201. */
  23202. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  23203. /**
  23204. * Source color is added to the destination color without alpha affecting the result.
  23205. */
  23206. static BLENDMODE_ONEONE: number;
  23207. /**
  23208. * Blend current color and particle color using particle’s alpha.
  23209. */
  23210. static BLENDMODE_STANDARD: number;
  23211. /**
  23212. * List of animations used by the particle system.
  23213. */
  23214. animations: Animation[];
  23215. /**
  23216. * The id of the Particle system.
  23217. */
  23218. id: string;
  23219. /**
  23220. * The friendly name of the Particle system.
  23221. */
  23222. name: string;
  23223. /**
  23224. * The rendering group used by the Particle system to chose when to render.
  23225. */
  23226. renderingGroupId: number;
  23227. /**
  23228. * The emitter represents the Mesh or position we are attaching the particle system to.
  23229. */
  23230. emitter: Nullable<AbstractMesh | Vector3>;
  23231. /**
  23232. * The maximum number of particles to emit per frame
  23233. */
  23234. emitRate: number;
  23235. /**
  23236. * If you want to launch only a few particles at once, that can be done, as well.
  23237. */
  23238. manualEmitCount: number;
  23239. /**
  23240. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  23241. */
  23242. updateSpeed: number;
  23243. /**
  23244. * The amount of time the particle system is running (depends of the overall update speed).
  23245. */
  23246. targetStopDuration: number;
  23247. /**
  23248. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  23249. */
  23250. disposeOnStop: boolean;
  23251. /**
  23252. * Minimum power of emitting particles.
  23253. */
  23254. minEmitPower: number;
  23255. /**
  23256. * Maximum power of emitting particles.
  23257. */
  23258. maxEmitPower: number;
  23259. /**
  23260. * Minimum life time of emitting particles.
  23261. */
  23262. minLifeTime: number;
  23263. /**
  23264. * Maximum life time of emitting particles.
  23265. */
  23266. maxLifeTime: number;
  23267. /**
  23268. * Minimum Size of emitting particles.
  23269. */
  23270. minSize: number;
  23271. /**
  23272. * Maximum Size of emitting particles.
  23273. */
  23274. maxSize: number;
  23275. /**
  23276. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  23277. */
  23278. minAngularSpeed: number;
  23279. /**
  23280. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  23281. */
  23282. maxAngularSpeed: number;
  23283. /**
  23284. * The texture used to render each particle. (this can be a spritesheet)
  23285. */
  23286. particleTexture: Nullable<Texture>;
  23287. /**
  23288. * The layer mask we are rendering the particles through.
  23289. */
  23290. layerMask: number;
  23291. /**
  23292. * This can help using your own shader to render the particle system.
  23293. * The according effect will be created
  23294. */
  23295. customShader: any;
  23296. /**
  23297. * By default particle system starts as soon as they are created. This prevents the
  23298. * automatic start to happen and let you decide when to start emitting particles.
  23299. */
  23300. preventAutoStart: boolean;
  23301. /**
  23302. * This function can be defined to provide custom update for active particles.
  23303. * This function will be called instead of regular update (age, position, color, etc.).
  23304. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  23305. */
  23306. updateFunction: (particles: Particle[]) => void;
  23307. /**
  23308. * Callback triggered when the particle animation is ending.
  23309. */
  23310. onAnimationEnd: Nullable<() => void>;
  23311. /**
  23312. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  23313. */
  23314. blendMode: number;
  23315. /**
  23316. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  23317. * to override the particles.
  23318. */
  23319. forceDepthWrite: boolean;
  23320. /**
  23321. * You can use gravity if you want to give an orientation to your particles.
  23322. */
  23323. gravity: Vector3;
  23324. /**
  23325. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23326. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23327. */
  23328. direction1: Vector3;
  23329. /**
  23330. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23331. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23332. */
  23333. direction2: Vector3;
  23334. /**
  23335. * 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.
  23336. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23337. */
  23338. minEmitBox: Vector3;
  23339. /**
  23340. * 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.
  23341. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23342. */
  23343. maxEmitBox: Vector3;
  23344. /**
  23345. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23346. */
  23347. color1: Color4;
  23348. /**
  23349. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23350. */
  23351. color2: Color4;
  23352. /**
  23353. * Color the particle will have at the end of its lifetime.
  23354. */
  23355. colorDead: Color4;
  23356. /**
  23357. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  23358. */
  23359. textureMask: Color4;
  23360. /**
  23361. * The particle emitter type defines the emitter used by the particle system.
  23362. * It can be for example box, sphere, or cone...
  23363. */
  23364. particleEmitterType: IParticleEmitterType;
  23365. /**
  23366. * This function can be defined to specify initial direction for every new particle.
  23367. * It by default use the emitterType defined function.
  23368. */
  23369. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  23370. /**
  23371. * This function can be defined to specify initial position for every new particle.
  23372. * It by default use the emitterType defined function.
  23373. */
  23374. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  23375. /**
  23376. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  23377. */
  23378. spriteCellLoop: boolean;
  23379. /**
  23380. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  23381. */
  23382. spriteCellChangeSpeed: number;
  23383. /**
  23384. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  23385. */
  23386. startSpriteCellID: number;
  23387. /**
  23388. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  23389. */
  23390. endSpriteCellID: number;
  23391. /**
  23392. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  23393. */
  23394. spriteCellWidth: number;
  23395. /**
  23396. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  23397. */
  23398. spriteCellHeight: number;
  23399. /**
  23400. * An event triggered when the system is disposed.
  23401. */
  23402. onDisposeObservable: Observable<ParticleSystem>;
  23403. private _onDisposeObserver;
  23404. /**
  23405. * Sets a callback that will be triggered when the system is disposed.
  23406. */
  23407. onDispose: () => void;
  23408. /**
  23409. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  23410. */
  23411. readonly isAnimationSheetEnabled: Boolean;
  23412. private _particles;
  23413. private _epsilon;
  23414. private _capacity;
  23415. private _scene;
  23416. private _stockParticles;
  23417. private _newPartsExcess;
  23418. private _vertexData;
  23419. private _vertexBuffer;
  23420. private _vertexBuffers;
  23421. private _indexBuffer;
  23422. private _effect;
  23423. private _customEffect;
  23424. private _cachedDefines;
  23425. private _scaledColorStep;
  23426. private _colorDiff;
  23427. private _scaledDirection;
  23428. private _scaledGravity;
  23429. private _currentRenderId;
  23430. private _alive;
  23431. private _started;
  23432. private _stopped;
  23433. private _actualFrame;
  23434. private _scaledUpdateSpeed;
  23435. private _vertexBufferSize;
  23436. private _isAnimationSheetEnabled;
  23437. /**
  23438. * 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.
  23439. */
  23440. subEmitters: ParticleSystem[];
  23441. /**
  23442. * The current active Sub-systems, this property is used by the root particle system only.
  23443. */
  23444. activeSubSystems: Array<ParticleSystem>;
  23445. private _rootParticleSystem;
  23446. /**
  23447. * Gets the current list of active particles
  23448. */
  23449. readonly particles: Particle[];
  23450. /**
  23451. * Returns the string "ParticleSystem"
  23452. * @returns a string containing the class name
  23453. */
  23454. getClassName(): string;
  23455. /**
  23456. * Instantiates a particle system.
  23457. * 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.
  23458. * @param name The name of the particle system
  23459. * @param capacity The max number of particles alive at the same time
  23460. * @param scene The scene the particle system belongs to
  23461. * @param customEffect a custom effect used to change the way particles are rendered by default
  23462. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  23463. * @param epsilon Offset used to render the particles
  23464. */
  23465. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  23466. private _createIndexBuffer();
  23467. /**
  23468. * Gets the maximum number of particles active at the same time.
  23469. * @returns The max number of active particles.
  23470. */
  23471. getCapacity(): number;
  23472. /**
  23473. * Gets Wether there are still active particles in the system.
  23474. * @returns True if it is alive, otherwise false.
  23475. */
  23476. isAlive(): boolean;
  23477. /**
  23478. * Gets Wether the system has been started.
  23479. * @returns True if it has been started, otherwise false.
  23480. */
  23481. isStarted(): boolean;
  23482. /**
  23483. * Starts the particle system and begins to emit.
  23484. */
  23485. start(): void;
  23486. /**
  23487. * Stops the particle system.
  23488. * @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.
  23489. */
  23490. stop(stopSubEmitters?: boolean): void;
  23491. /**
  23492. * Remove all active particles
  23493. */
  23494. reset(): void;
  23495. /**
  23496. * @hidden (for internal use only)
  23497. */
  23498. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  23499. /**
  23500. * @hidden (for internal use only)
  23501. */
  23502. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  23503. /**
  23504. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  23505. * Its lifetime will start back at 0.
  23506. */
  23507. recycleParticle: (particle: Particle) => void;
  23508. private _stopSubEmitters();
  23509. private _createParticle;
  23510. private _removeFromRoot();
  23511. private _emitFromParticle;
  23512. private _update(newParticles);
  23513. private _getEffect();
  23514. /**
  23515. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  23516. */
  23517. animate(): void;
  23518. private _appendParticleVertexes;
  23519. private _appenedParticleVertexesWithSheet(offset, particle);
  23520. private _appenedParticleVertexesNoSheet(offset, particle);
  23521. /**
  23522. * Rebuilds the particle system.
  23523. */
  23524. rebuild(): void;
  23525. /**
  23526. * Is this system ready to be used/rendered
  23527. * @return true if the system is ready
  23528. */
  23529. isReady(): boolean;
  23530. /**
  23531. * Renders the particle system in its current state.
  23532. * @returns the current number of particles
  23533. */
  23534. render(): number;
  23535. /**
  23536. * Disposes the particle system and free the associated resources
  23537. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  23538. */
  23539. dispose(disposeTexture?: boolean): void;
  23540. /**
  23541. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  23542. * @param radius The radius of the sphere to emit from
  23543. * @returns the emitter
  23544. */
  23545. createSphereEmitter(radius?: number): SphereParticleEmitter;
  23546. /**
  23547. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  23548. * @param radius The radius of the sphere to emit from
  23549. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  23550. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  23551. * @returns the emitter
  23552. */
  23553. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  23554. /**
  23555. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  23556. * @param radius The radius of the cone to emit from
  23557. * @param angle The base angle of the cone
  23558. * @returns the emitter
  23559. */
  23560. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  23561. /**
  23562. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  23563. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  23564. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  23565. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  23566. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  23567. * @returns the emitter
  23568. */
  23569. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  23570. /**
  23571. * Clones the particle system.
  23572. * @param name The name of the cloned object
  23573. * @param newEmitter The new emitter to use
  23574. * @returns the cloned particle system
  23575. */
  23576. clone(name: string, newEmitter: any): ParticleSystem;
  23577. /**
  23578. * Serializes the particle system to a JSON object.
  23579. * @returns the JSON object
  23580. */
  23581. serialize(): any;
  23582. /**
  23583. * Parses a JSON object to create a particle system.
  23584. * @param parsedParticleSystem The JSON object to parse
  23585. * @param scene The scene to create the particle system in
  23586. * @param rootUrl The root url to use to load external dependencies like texture
  23587. * @returns the Parsed particle system
  23588. */
  23589. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  23590. }
  23591. }
  23592. declare module BABYLON {
  23593. /**
  23594. * Represents one particle of a solid particle system.
  23595. */
  23596. class SolidParticle {
  23597. /**
  23598. * particle global index
  23599. */
  23600. idx: number;
  23601. /**
  23602. * The color of the particle
  23603. */
  23604. color: Nullable<Color4>;
  23605. /**
  23606. * The world space position of the particle.
  23607. */
  23608. position: Vector3;
  23609. /**
  23610. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23611. */
  23612. rotation: Vector3;
  23613. /**
  23614. * The world space rotation quaternion of the particle.
  23615. */
  23616. rotationQuaternion: Nullable<Quaternion>;
  23617. /**
  23618. * The scaling of the particle.
  23619. */
  23620. scaling: Vector3;
  23621. /**
  23622. * The uvs of the particle.
  23623. */
  23624. uvs: Vector4;
  23625. /**
  23626. * The current speed of the particle.
  23627. */
  23628. velocity: Vector3;
  23629. /**
  23630. * The pivot point in the particle local space.
  23631. */
  23632. pivot: Vector3;
  23633. /**
  23634. * Must the particle be translated from its pivot point in its local space ?
  23635. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23636. * Default : false
  23637. */
  23638. translateFromPivot: boolean;
  23639. /**
  23640. * Is the particle active or not ?
  23641. */
  23642. alive: boolean;
  23643. /**
  23644. * Is the particle visible or not ?
  23645. */
  23646. isVisible: boolean;
  23647. /**
  23648. * Index of this particle in the global "positions" array (Internal use)
  23649. */
  23650. _pos: number;
  23651. /**
  23652. * Index of this particle in the global "indices" array (Internal use)
  23653. */
  23654. _ind: number;
  23655. /**
  23656. * ModelShape of this particle (Internal use)
  23657. */
  23658. _model: ModelShape;
  23659. /**
  23660. * ModelShape id of this particle
  23661. */
  23662. shapeId: number;
  23663. /**
  23664. * Index of the particle in its shape id (Internal use)
  23665. */
  23666. idxInShape: number;
  23667. /**
  23668. * Reference to the shape model BoundingInfo object (Internal use)
  23669. */
  23670. _modelBoundingInfo: BoundingInfo;
  23671. /**
  23672. * Particle BoundingInfo object (Internal use)
  23673. */
  23674. _boundingInfo: BoundingInfo;
  23675. /**
  23676. * Reference to the SPS what the particle belongs to (Internal use)
  23677. */
  23678. _sps: SolidParticleSystem;
  23679. /**
  23680. * Still set as invisible in order to skip useless computations (Internal use)
  23681. */
  23682. _stillInvisible: boolean;
  23683. /**
  23684. * Last computed particle rotation matrix
  23685. */
  23686. _rotationMatrix: number[];
  23687. /**
  23688. * Parent particle Id, if any.
  23689. * Default null.
  23690. */
  23691. parentId: Nullable<number>;
  23692. /**
  23693. * Internal global position in the SPS.
  23694. */
  23695. _globalPosition: Vector3;
  23696. /**
  23697. * Creates a Solid Particle object.
  23698. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23699. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23700. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23701. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23702. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23703. * @param shapeId (integer) is the model shape identifier in the SPS.
  23704. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23705. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23706. */
  23707. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23708. /**
  23709. * Legacy support, changed scale to scaling
  23710. */
  23711. /**
  23712. * Legacy support, changed scale to scaling
  23713. */
  23714. scale: Vector3;
  23715. /**
  23716. * Legacy support, changed quaternion to rotationQuaternion
  23717. */
  23718. /**
  23719. * Legacy support, changed quaternion to rotationQuaternion
  23720. */
  23721. quaternion: Nullable<Quaternion>;
  23722. /**
  23723. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23724. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23725. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23726. * @returns true if it intersects
  23727. */
  23728. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23729. }
  23730. /**
  23731. * Represents the shape of the model used by one particle of a solid particle system.
  23732. * SPS internal tool, don't use it manually.
  23733. */
  23734. class ModelShape {
  23735. /**
  23736. * The shape id.
  23737. */
  23738. shapeID: number;
  23739. /**
  23740. * flat array of model positions (internal use)
  23741. */
  23742. _shape: Vector3[];
  23743. /**
  23744. * flat array of model UVs (internal use)
  23745. */
  23746. _shapeUV: number[];
  23747. /**
  23748. * length of the shape in the model indices array (internal use)
  23749. */
  23750. _indicesLength: number;
  23751. /**
  23752. * Custom position function (internal use)
  23753. */
  23754. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23755. /**
  23756. * Custom vertex function (internal use)
  23757. */
  23758. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23759. /**
  23760. * 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.
  23761. * SPS internal tool, don't use it manually.
  23762. * @hidden
  23763. */
  23764. 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>);
  23765. }
  23766. /**
  23767. * Represents a Depth Sorted Particle in the solid particle system.
  23768. */
  23769. class DepthSortedParticle {
  23770. /**
  23771. * Index of the particle in the "indices" array
  23772. */
  23773. ind: number;
  23774. /**
  23775. * Length of the particle shape in the "indices" array
  23776. */
  23777. indicesLength: number;
  23778. /**
  23779. * Squared distance from the particle to the camera
  23780. */
  23781. sqDistance: number;
  23782. }
  23783. }
  23784. declare module BABYLON {
  23785. /**
  23786. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23787. *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.
  23788. * The SPS is also a particle system. It provides some methods to manage the particles.
  23789. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23790. *
  23791. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23792. */
  23793. class SolidParticleSystem implements IDisposable {
  23794. /**
  23795. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23796. * Example : var p = SPS.particles[i];
  23797. */
  23798. particles: SolidParticle[];
  23799. /**
  23800. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23801. */
  23802. nbParticles: number;
  23803. /**
  23804. * If the particles must ever face the camera (default false). Useful for planar particles.
  23805. */
  23806. billboard: boolean;
  23807. /**
  23808. * Recompute normals when adding a shape
  23809. */
  23810. recomputeNormals: boolean;
  23811. /**
  23812. * This a counter ofr your own usage. It's not set by any SPS functions.
  23813. */
  23814. counter: number;
  23815. /**
  23816. * The SPS name. This name is also given to the underlying mesh.
  23817. */
  23818. name: string;
  23819. /**
  23820. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23821. */
  23822. mesh: Mesh;
  23823. /**
  23824. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23825. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23826. */
  23827. vars: any;
  23828. /**
  23829. * This array is populated when the SPS is set as 'pickable'.
  23830. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23831. * Each element of this array is an object `{idx: int, faceId: int}`.
  23832. * `idx` is the picked particle index in the `SPS.particles` array
  23833. * `faceId` is the picked face index counted within this particle.
  23834. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23835. */
  23836. pickedParticles: {
  23837. idx: number;
  23838. faceId: number;
  23839. }[];
  23840. /**
  23841. * This array is populated when `enableDepthSort` is set to true.
  23842. * Each element of this array is an instance of the class DepthSortedParticle.
  23843. */
  23844. depthSortedParticles: DepthSortedParticle[];
  23845. /**
  23846. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23847. */
  23848. _bSphereOnly: boolean;
  23849. /**
  23850. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23851. */
  23852. _bSphereRadiusFactor: number;
  23853. private _scene;
  23854. private _positions;
  23855. private _indices;
  23856. private _normals;
  23857. private _colors;
  23858. private _uvs;
  23859. private _indices32;
  23860. private _positions32;
  23861. private _normals32;
  23862. private _fixedNormal32;
  23863. private _colors32;
  23864. private _uvs32;
  23865. private _index;
  23866. private _updatable;
  23867. private _pickable;
  23868. private _isVisibilityBoxLocked;
  23869. private _alwaysVisible;
  23870. private _depthSort;
  23871. private _shapeCounter;
  23872. private _copy;
  23873. private _shape;
  23874. private _shapeUV;
  23875. private _color;
  23876. private _computeParticleColor;
  23877. private _computeParticleTexture;
  23878. private _computeParticleRotation;
  23879. private _computeParticleVertex;
  23880. private _computeBoundingBox;
  23881. private _depthSortParticles;
  23882. private _cam_axisZ;
  23883. private _cam_axisY;
  23884. private _cam_axisX;
  23885. private _axisZ;
  23886. private _camera;
  23887. private _particle;
  23888. private _camDir;
  23889. private _camInvertedPosition;
  23890. private _rotMatrix;
  23891. private _invertMatrix;
  23892. private _rotated;
  23893. private _quaternion;
  23894. private _vertex;
  23895. private _normal;
  23896. private _yaw;
  23897. private _pitch;
  23898. private _roll;
  23899. private _halfroll;
  23900. private _halfpitch;
  23901. private _halfyaw;
  23902. private _sinRoll;
  23903. private _cosRoll;
  23904. private _sinPitch;
  23905. private _cosPitch;
  23906. private _sinYaw;
  23907. private _cosYaw;
  23908. private _mustUnrotateFixedNormals;
  23909. private _minimum;
  23910. private _maximum;
  23911. private _minBbox;
  23912. private _maxBbox;
  23913. private _particlesIntersect;
  23914. private _depthSortFunction;
  23915. private _needs32Bits;
  23916. private _pivotBackTranslation;
  23917. private _scaledPivot;
  23918. private _particleHasParent;
  23919. private _parent;
  23920. /**
  23921. * Creates a SPS (Solid Particle System) object.
  23922. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23923. * @param scene (Scene) is the scene in which the SPS is added.
  23924. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23925. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23926. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23927. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23928. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23929. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23930. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23931. */
  23932. constructor(name: string, scene: Scene, options?: {
  23933. updatable?: boolean;
  23934. isPickable?: boolean;
  23935. enableDepthSort?: boolean;
  23936. particleIntersection?: boolean;
  23937. boundingSphereOnly?: boolean;
  23938. bSphereRadiusFactor?: number;
  23939. });
  23940. /**
  23941. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23942. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23943. * @returns the created mesh
  23944. */
  23945. buildMesh(): Mesh;
  23946. /**
  23947. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23948. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23949. * Thus the particles generated from `digest()` have their property `position` set yet.
  23950. * @param mesh ( Mesh ) is the mesh to be digested
  23951. * @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
  23952. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23953. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23954. * @returns the current SPS
  23955. */
  23956. digest(mesh: Mesh, options?: {
  23957. facetNb?: number;
  23958. number?: number;
  23959. delta?: number;
  23960. }): SolidParticleSystem;
  23961. private _unrotateFixedNormals();
  23962. private _resetCopy();
  23963. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  23964. private _posToShape(positions);
  23965. private _uvsToShapeUV(uvs);
  23966. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  23967. /**
  23968. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23969. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23970. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23971. * @param nb (positive integer) the number of particles to be created from this model
  23972. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23973. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23974. * @returns the number of shapes in the system
  23975. */
  23976. addShape(mesh: Mesh, nb: number, options?: {
  23977. positionFunction?: any;
  23978. vertexFunction?: any;
  23979. }): number;
  23980. private _rebuildParticle(particle);
  23981. /**
  23982. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23983. * @returns the SPS.
  23984. */
  23985. rebuildMesh(): SolidParticleSystem;
  23986. /**
  23987. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23988. * This method calls `updateParticle()` for each particle of the SPS.
  23989. * For an animated SPS, it is usually called within the render loop.
  23990. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23991. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23992. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23993. * @returns the SPS.
  23994. */
  23995. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23996. private _quaternionRotationYPR();
  23997. private _quaternionToRotationMatrix();
  23998. /**
  23999. * Disposes the SPS.
  24000. */
  24001. dispose(): void;
  24002. /**
  24003. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24004. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24005. * @returns the SPS.
  24006. */
  24007. refreshVisibleSize(): SolidParticleSystem;
  24008. /**
  24009. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24010. * @param size the size (float) of the visibility box
  24011. * note : this doesn't lock the SPS mesh bounding box.
  24012. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24013. */
  24014. setVisibilityBox(size: number): void;
  24015. /**
  24016. * Gets whether the SPS as always visible or not
  24017. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24018. */
  24019. /**
  24020. * Sets the SPS as always visible or not
  24021. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24022. */
  24023. isAlwaysVisible: boolean;
  24024. /**
  24025. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24026. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24027. */
  24028. /**
  24029. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24030. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24031. */
  24032. isVisibilityBoxLocked: boolean;
  24033. /**
  24034. * Gets if `setParticles()` computes the particle rotations or not.
  24035. * Default value : true. The SPS is faster when it's set to false.
  24036. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24037. */
  24038. /**
  24039. * Tells to `setParticles()` to compute the particle rotations or not.
  24040. * Default value : true. The SPS is faster when it's set to false.
  24041. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24042. */
  24043. computeParticleRotation: boolean;
  24044. /**
  24045. * Gets if `setParticles()` computes the particle colors or not.
  24046. * Default value : true. The SPS is faster when it's set to false.
  24047. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24048. */
  24049. /**
  24050. * Tells to `setParticles()` to compute the particle colors or not.
  24051. * Default value : true. The SPS is faster when it's set to false.
  24052. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24053. */
  24054. computeParticleColor: boolean;
  24055. /**
  24056. * Gets if `setParticles()` computes the particle textures or not.
  24057. * Default value : true. The SPS is faster when it's set to false.
  24058. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24059. */
  24060. computeParticleTexture: boolean;
  24061. /**
  24062. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24063. * Default value : false. The SPS is faster when it's set to false.
  24064. * Note : the particle custom vertex positions aren't stored values.
  24065. */
  24066. /**
  24067. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24068. * Default value : false. The SPS is faster when it's set to false.
  24069. * Note : the particle custom vertex positions aren't stored values.
  24070. */
  24071. computeParticleVertex: boolean;
  24072. /**
  24073. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24074. */
  24075. /**
  24076. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24077. */
  24078. computeBoundingBox: boolean;
  24079. /**
  24080. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24081. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24082. * Default : `true`
  24083. */
  24084. /**
  24085. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24086. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24087. * Default : `true`
  24088. */
  24089. depthSortParticles: boolean;
  24090. /**
  24091. * This function does nothing. It may be overwritten to set all the particle first values.
  24092. * The SPS doesn't call this function, you may have to call it by your own.
  24093. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24094. */
  24095. initParticles(): void;
  24096. /**
  24097. * This function does nothing. It may be overwritten to recycle a particle.
  24098. * The SPS doesn't call this function, you may have to call it by your own.
  24099. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24100. * @param particle The particle to recycle
  24101. * @returns the recycled particle
  24102. */
  24103. recycleParticle(particle: SolidParticle): SolidParticle;
  24104. /**
  24105. * Updates a particle : this function should be overwritten by the user.
  24106. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24107. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24108. * @example : just set a particle position or velocity and recycle conditions
  24109. * @param particle The particle to update
  24110. * @returns the updated particle
  24111. */
  24112. updateParticle(particle: SolidParticle): SolidParticle;
  24113. /**
  24114. * Updates a vertex of a particle : it can be overwritten by the user.
  24115. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24116. * @param particle the current particle
  24117. * @param vertex the current index of the current particle
  24118. * @param pt the index of the current vertex in the particle shape
  24119. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24120. * @example : just set a vertex particle position
  24121. * @returns the updated vertex
  24122. */
  24123. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24124. /**
  24125. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24126. * This does nothing and may be overwritten by the user.
  24127. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24128. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24129. * @param update the boolean update value actually passed to setParticles()
  24130. */
  24131. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24132. /**
  24133. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24134. * This will be passed three parameters.
  24135. * This does nothing and may be overwritten by the user.
  24136. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24137. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24138. * @param update the boolean update value actually passed to setParticles()
  24139. */
  24140. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24141. }
  24142. }
  24143. declare module BABYLON {
  24144. interface PhysicsImpostorJoint {
  24145. mainImpostor: PhysicsImpostor;
  24146. connectedImpostor: PhysicsImpostor;
  24147. joint: PhysicsJoint;
  24148. }
  24149. class PhysicsEngine {
  24150. private _physicsPlugin;
  24151. gravity: Vector3;
  24152. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  24153. setGravity(gravity: Vector3): void;
  24154. /**
  24155. * Set the time step of the physics engine.
  24156. * default is 1/60.
  24157. * To slow it down, enter 1/600 for example.
  24158. * To speed it up, 1/30
  24159. * @param {number} newTimeStep the new timestep to apply to this world.
  24160. */
  24161. setTimeStep(newTimeStep?: number): void;
  24162. /**
  24163. * Get the time step of the physics engine.
  24164. */
  24165. getTimeStep(): number;
  24166. dispose(): void;
  24167. getPhysicsPluginName(): string;
  24168. static Epsilon: number;
  24169. private _impostors;
  24170. private _joints;
  24171. /**
  24172. * Adding a new impostor for the impostor tracking.
  24173. * This will be done by the impostor itself.
  24174. * @param {PhysicsImpostor} impostor the impostor to add
  24175. */
  24176. addImpostor(impostor: PhysicsImpostor): void;
  24177. /**
  24178. * Remove an impostor from the engine.
  24179. * This impostor and its mesh will not longer be updated by the physics engine.
  24180. * @param {PhysicsImpostor} impostor the impostor to remove
  24181. */
  24182. removeImpostor(impostor: PhysicsImpostor): void;
  24183. /**
  24184. * Add a joint to the physics engine
  24185. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  24186. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  24187. * @param {PhysicsJoint} the joint that will connect both impostors.
  24188. */
  24189. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24190. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24191. /**
  24192. * Called by the scene. no need to call it.
  24193. */
  24194. _step(delta: number): void;
  24195. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24196. getImpostors(): Array<PhysicsImpostor>;
  24197. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24198. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24199. }
  24200. interface IPhysicsEnginePlugin {
  24201. world: any;
  24202. name: string;
  24203. setGravity(gravity: Vector3): void;
  24204. setTimeStep(timeStep: number): void;
  24205. getTimeStep(): number;
  24206. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24207. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24208. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24209. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24210. removePhysicsBody(impostor: PhysicsImpostor): void;
  24211. generateJoint(joint: PhysicsImpostorJoint): void;
  24212. removeJoint(joint: PhysicsImpostorJoint): void;
  24213. isSupported(): boolean;
  24214. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24215. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24216. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24217. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24218. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24219. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24220. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24221. getBodyMass(impostor: PhysicsImpostor): number;
  24222. getBodyFriction(impostor: PhysicsImpostor): number;
  24223. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24224. getBodyRestitution(impostor: PhysicsImpostor): number;
  24225. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24226. sleepBody(impostor: PhysicsImpostor): void;
  24227. wakeUpBody(impostor: PhysicsImpostor): void;
  24228. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24229. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24230. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24231. getRadius(impostor: PhysicsImpostor): number;
  24232. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24233. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24234. dispose(): void;
  24235. }
  24236. }
  24237. declare module BABYLON {
  24238. class PhysicsHelper {
  24239. private _scene;
  24240. private _physicsEngine;
  24241. constructor(scene: Scene);
  24242. /**
  24243. * @param {Vector3} origin the origin of the explosion
  24244. * @param {number} radius the explosion radius
  24245. * @param {number} strength the explosion strength
  24246. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24247. */
  24248. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24249. /**
  24250. * @param {Vector3} origin the origin of the explosion
  24251. * @param {number} radius the explosion radius
  24252. * @param {number} strength the explosion strength
  24253. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24254. */
  24255. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24256. /**
  24257. * @param {Vector3} origin the origin of the explosion
  24258. * @param {number} radius the explosion radius
  24259. * @param {number} strength the explosion strength
  24260. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24261. */
  24262. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  24263. /**
  24264. * @param {Vector3} origin the origin of the updraft
  24265. * @param {number} radius the radius of the updraft
  24266. * @param {number} strength the strength of the updraft
  24267. * @param {number} height the height of the updraft
  24268. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  24269. */
  24270. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  24271. /**
  24272. * @param {Vector3} origin the of the vortex
  24273. * @param {number} radius the radius of the vortex
  24274. * @param {number} strength the strength of the vortex
  24275. * @param {number} height the height of the vortex
  24276. */
  24277. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  24278. }
  24279. /***** Radial explosion *****/
  24280. class PhysicsRadialExplosionEvent {
  24281. private _scene;
  24282. private _sphere;
  24283. private _sphereOptions;
  24284. private _rays;
  24285. private _dataFetched;
  24286. constructor(scene: Scene);
  24287. /**
  24288. * Returns the data related to the radial explosion event (sphere & rays).
  24289. * @returns {PhysicsRadialExplosionEventData}
  24290. */
  24291. getData(): PhysicsRadialExplosionEventData;
  24292. /**
  24293. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  24294. * @param impostor
  24295. * @param {Vector3} origin the origin of the explosion
  24296. * @param {number} radius the explosion radius
  24297. * @param {number} strength the explosion strength
  24298. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  24299. * @returns {Nullable<PhysicsForceAndContactPoint>}
  24300. */
  24301. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  24302. /**
  24303. * Disposes the sphere.
  24304. * @param {bolean} force
  24305. */
  24306. dispose(force?: boolean): void;
  24307. /*** Helpers ***/
  24308. private _prepareSphere();
  24309. private _intersectsWithSphere(impostor, origin, radius);
  24310. }
  24311. /***** Gravitational Field *****/
  24312. class PhysicsGravitationalFieldEvent {
  24313. private _physicsHelper;
  24314. private _scene;
  24315. private _origin;
  24316. private _radius;
  24317. private _strength;
  24318. private _falloff;
  24319. private _tickCallback;
  24320. private _sphere;
  24321. private _dataFetched;
  24322. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  24323. /**
  24324. * Returns the data related to the gravitational field event (sphere).
  24325. * @returns {PhysicsGravitationalFieldEventData}
  24326. */
  24327. getData(): PhysicsGravitationalFieldEventData;
  24328. /**
  24329. * Enables the gravitational field.
  24330. */
  24331. enable(): void;
  24332. /**
  24333. * Disables the gravitational field.
  24334. */
  24335. disable(): void;
  24336. /**
  24337. * Disposes the sphere.
  24338. * @param {bolean} force
  24339. */
  24340. dispose(force?: boolean): void;
  24341. private _tick();
  24342. }
  24343. /***** Updraft *****/
  24344. class PhysicsUpdraftEvent {
  24345. private _scene;
  24346. private _origin;
  24347. private _radius;
  24348. private _strength;
  24349. private _height;
  24350. private _updraftMode;
  24351. private _physicsEngine;
  24352. private _originTop;
  24353. private _originDirection;
  24354. private _tickCallback;
  24355. private _cylinder;
  24356. private _cylinderPosition;
  24357. private _dataFetched;
  24358. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  24359. /**
  24360. * Returns the data related to the updraft event (cylinder).
  24361. * @returns {PhysicsUpdraftEventData}
  24362. */
  24363. getData(): PhysicsUpdraftEventData;
  24364. /**
  24365. * Enables the updraft.
  24366. */
  24367. enable(): void;
  24368. /**
  24369. * Disables the cortex.
  24370. */
  24371. disable(): void;
  24372. /**
  24373. * Disposes the sphere.
  24374. * @param {bolean} force
  24375. */
  24376. dispose(force?: boolean): void;
  24377. private getImpostorForceAndContactPoint(impostor);
  24378. private _tick();
  24379. /*** Helpers ***/
  24380. private _prepareCylinder();
  24381. private _intersectsWithCylinder(impostor);
  24382. }
  24383. /***** Vortex *****/
  24384. class PhysicsVortexEvent {
  24385. private _scene;
  24386. private _origin;
  24387. private _radius;
  24388. private _strength;
  24389. private _height;
  24390. private _physicsEngine;
  24391. private _originTop;
  24392. private _centripetalForceThreshold;
  24393. private _updraftMultiplier;
  24394. private _tickCallback;
  24395. private _cylinder;
  24396. private _cylinderPosition;
  24397. private _dataFetched;
  24398. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  24399. /**
  24400. * Returns the data related to the vortex event (cylinder).
  24401. * @returns {PhysicsVortexEventData}
  24402. */
  24403. getData(): PhysicsVortexEventData;
  24404. /**
  24405. * Enables the vortex.
  24406. */
  24407. enable(): void;
  24408. /**
  24409. * Disables the cortex.
  24410. */
  24411. disable(): void;
  24412. /**
  24413. * Disposes the sphere.
  24414. * @param {bolean} force
  24415. */
  24416. dispose(force?: boolean): void;
  24417. private getImpostorForceAndContactPoint(impostor);
  24418. private _tick();
  24419. /*** Helpers ***/
  24420. private _prepareCylinder();
  24421. private _intersectsWithCylinder(impostor);
  24422. }
  24423. /***** Enums *****/
  24424. /**
  24425. * The strenght of the force in correspondence to the distance of the affected object
  24426. */
  24427. enum PhysicsRadialImpulseFalloff {
  24428. /** Defines that impulse is constant in strength across it's whole radius */
  24429. Constant = 0,
  24430. /** DEfines that impulse gets weaker if it's further from the origin */
  24431. Linear = 1,
  24432. }
  24433. /**
  24434. * The strenght of the force in correspondence to the distance of the affected object
  24435. */
  24436. enum PhysicsUpdraftMode {
  24437. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  24438. Center = 0,
  24439. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  24440. Perpendicular = 1,
  24441. }
  24442. /***** Data interfaces *****/
  24443. interface PhysicsForceAndContactPoint {
  24444. force: Vector3;
  24445. contactPoint: Vector3;
  24446. }
  24447. interface PhysicsRadialExplosionEventData {
  24448. sphere: Mesh;
  24449. rays: Array<Ray>;
  24450. }
  24451. interface PhysicsGravitationalFieldEventData {
  24452. sphere: Mesh;
  24453. }
  24454. interface PhysicsUpdraftEventData {
  24455. cylinder: Mesh;
  24456. }
  24457. interface PhysicsVortexEventData {
  24458. cylinder: Mesh;
  24459. }
  24460. }
  24461. declare module BABYLON {
  24462. interface PhysicsImpostorParameters {
  24463. mass: number;
  24464. friction?: number;
  24465. restitution?: number;
  24466. nativeOptions?: any;
  24467. ignoreParent?: boolean;
  24468. disableBidirectionalTransformation?: boolean;
  24469. }
  24470. interface IPhysicsEnabledObject {
  24471. position: Vector3;
  24472. rotationQuaternion: Nullable<Quaternion>;
  24473. scaling: Vector3;
  24474. rotation?: Vector3;
  24475. parent?: any;
  24476. getBoundingInfo(): BoundingInfo;
  24477. computeWorldMatrix(force: boolean): Matrix;
  24478. getWorldMatrix?(): Matrix;
  24479. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24480. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24481. getIndices?(): Nullable<IndicesArray>;
  24482. getScene?(): Scene;
  24483. getAbsolutePosition(): Vector3;
  24484. getAbsolutePivotPoint(): Vector3;
  24485. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24486. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24487. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24488. getClassName(): string;
  24489. }
  24490. class PhysicsImpostor {
  24491. object: IPhysicsEnabledObject;
  24492. type: number;
  24493. private _options;
  24494. private _scene;
  24495. static DEFAULT_OBJECT_SIZE: Vector3;
  24496. static IDENTITY_QUATERNION: Quaternion;
  24497. private _physicsEngine;
  24498. private _physicsBody;
  24499. private _bodyUpdateRequired;
  24500. private _onBeforePhysicsStepCallbacks;
  24501. private _onAfterPhysicsStepCallbacks;
  24502. private _onPhysicsCollideCallbacks;
  24503. private _deltaPosition;
  24504. private _deltaRotation;
  24505. private _deltaRotationConjugated;
  24506. private _parent;
  24507. private _isDisposed;
  24508. private static _tmpVecs;
  24509. private static _tmpQuat;
  24510. readonly isDisposed: boolean;
  24511. mass: number;
  24512. friction: number;
  24513. restitution: number;
  24514. uniqueId: number;
  24515. private _joints;
  24516. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24517. /**
  24518. * This function will completly initialize this impostor.
  24519. * It will create a new body - but only if this mesh has no parent.
  24520. * If it has, this impostor will not be used other than to define the impostor
  24521. * of the child mesh.
  24522. */
  24523. _init(): void;
  24524. private _getPhysicsParent();
  24525. /**
  24526. * Should a new body be generated.
  24527. */
  24528. isBodyInitRequired(): boolean;
  24529. setScalingUpdated(updated: boolean): void;
  24530. /**
  24531. * Force a regeneration of this or the parent's impostor's body.
  24532. * Use under cautious - This will remove all joints already implemented.
  24533. */
  24534. forceUpdate(): void;
  24535. /**
  24536. * Gets the body that holds this impostor. Either its own, or its parent.
  24537. */
  24538. /**
  24539. * Set the physics body. Used mainly by the physics engine/plugin
  24540. */
  24541. physicsBody: any;
  24542. parent: Nullable<PhysicsImpostor>;
  24543. resetUpdateFlags(): void;
  24544. getObjectExtendSize(): Vector3;
  24545. getObjectCenter(): Vector3;
  24546. /**
  24547. * Get a specific parametes from the options parameter.
  24548. */
  24549. getParam(paramName: string): any;
  24550. /**
  24551. * Sets a specific parameter in the options given to the physics plugin
  24552. */
  24553. setParam(paramName: string, value: number): void;
  24554. /**
  24555. * Specifically change the body's mass option. Won't recreate the physics body object
  24556. */
  24557. setMass(mass: number): void;
  24558. getLinearVelocity(): Nullable<Vector3>;
  24559. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24560. getAngularVelocity(): Nullable<Vector3>;
  24561. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24562. /**
  24563. * Execute a function with the physics plugin native code.
  24564. * Provide a function the will have two variables - the world object and the physics body object.
  24565. */
  24566. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24567. /**
  24568. * Register a function that will be executed before the physics world is stepping forward.
  24569. */
  24570. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24571. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24572. /**
  24573. * Register a function that will be executed after the physics step
  24574. */
  24575. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24576. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24577. /**
  24578. * register a function that will be executed when this impostor collides against a different body.
  24579. */
  24580. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24581. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24582. private _tmpQuat;
  24583. private _tmpQuat2;
  24584. getParentsRotation(): Quaternion;
  24585. /**
  24586. * this function is executed by the physics engine.
  24587. */
  24588. beforeStep: () => void;
  24589. /**
  24590. * this function is executed by the physics engine.
  24591. */
  24592. afterStep: () => void;
  24593. /**
  24594. * Legacy collision detection event support
  24595. */
  24596. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24597. onCollide: (e: {
  24598. body: any;
  24599. }) => void;
  24600. /**
  24601. * Apply a force
  24602. */
  24603. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24604. /**
  24605. * Apply an impulse
  24606. */
  24607. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24608. /**
  24609. * A help function to create a joint.
  24610. */
  24611. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24612. /**
  24613. * Add a joint to this impostor with a different impostor.
  24614. */
  24615. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24616. /**
  24617. * Will keep this body still, in a sleep mode.
  24618. */
  24619. sleep(): PhysicsImpostor;
  24620. /**
  24621. * Wake the body up.
  24622. */
  24623. wakeUp(): PhysicsImpostor;
  24624. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24625. dispose(): void;
  24626. setDeltaPosition(position: Vector3): void;
  24627. setDeltaRotation(rotation: Quaternion): void;
  24628. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24629. getRadius(): number;
  24630. /**
  24631. * Sync a bone with this impostor
  24632. * @param bone The bone to sync to the impostor.
  24633. * @param boneMesh The mesh that the bone is influencing.
  24634. * @param jointPivot The pivot of the joint / bone in local space.
  24635. * @param distToJoint Optional distance from the impostor to the joint.
  24636. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24637. */
  24638. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24639. /**
  24640. * Sync impostor to a bone
  24641. * @param bone The bone that the impostor will be synced to.
  24642. * @param boneMesh The mesh that the bone is influencing.
  24643. * @param jointPivot The pivot of the joint / bone in local space.
  24644. * @param distToJoint Optional distance from the impostor to the joint.
  24645. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24646. * @param boneAxis Optional vector3 axis the bone is aligned with
  24647. */
  24648. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24649. static NoImpostor: number;
  24650. static SphereImpostor: number;
  24651. static BoxImpostor: number;
  24652. static PlaneImpostor: number;
  24653. static MeshImpostor: number;
  24654. static CylinderImpostor: number;
  24655. static ParticleImpostor: number;
  24656. static HeightmapImpostor: number;
  24657. }
  24658. }
  24659. declare module BABYLON {
  24660. interface PhysicsJointData {
  24661. mainPivot?: Vector3;
  24662. connectedPivot?: Vector3;
  24663. mainAxis?: Vector3;
  24664. connectedAxis?: Vector3;
  24665. collision?: boolean;
  24666. nativeParams?: any;
  24667. }
  24668. /**
  24669. * This is a holder class for the physics joint created by the physics plugin.
  24670. * It holds a set of functions to control the underlying joint.
  24671. */
  24672. class PhysicsJoint {
  24673. type: number;
  24674. jointData: PhysicsJointData;
  24675. private _physicsJoint;
  24676. protected _physicsPlugin: IPhysicsEnginePlugin;
  24677. constructor(type: number, jointData: PhysicsJointData);
  24678. physicsJoint: any;
  24679. physicsPlugin: IPhysicsEnginePlugin;
  24680. /**
  24681. * Execute a function that is physics-plugin specific.
  24682. * @param {Function} func the function that will be executed.
  24683. * It accepts two parameters: the physics world and the physics joint.
  24684. */
  24685. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24686. static DistanceJoint: number;
  24687. static HingeJoint: number;
  24688. static BallAndSocketJoint: number;
  24689. static WheelJoint: number;
  24690. static SliderJoint: number;
  24691. static PrismaticJoint: number;
  24692. static UniversalJoint: number;
  24693. static Hinge2Joint: number;
  24694. static PointToPointJoint: number;
  24695. static SpringJoint: number;
  24696. static LockJoint: number;
  24697. }
  24698. /**
  24699. * A class representing a physics distance joint.
  24700. */
  24701. class DistanceJoint extends PhysicsJoint {
  24702. constructor(jointData: DistanceJointData);
  24703. /**
  24704. * Update the predefined distance.
  24705. */
  24706. updateDistance(maxDistance: number, minDistance?: number): void;
  24707. }
  24708. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24709. constructor(type: number, jointData: PhysicsJointData);
  24710. /**
  24711. * Set the motor values.
  24712. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24713. * @param {number} force the force to apply
  24714. * @param {number} maxForce max force for this motor.
  24715. */
  24716. setMotor(force?: number, maxForce?: number): void;
  24717. /**
  24718. * Set the motor's limits.
  24719. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24720. */
  24721. setLimit(upperLimit: number, lowerLimit?: number): void;
  24722. }
  24723. /**
  24724. * This class represents a single hinge physics joint
  24725. */
  24726. class HingeJoint extends MotorEnabledJoint {
  24727. constructor(jointData: PhysicsJointData);
  24728. /**
  24729. * Set the motor values.
  24730. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24731. * @param {number} force the force to apply
  24732. * @param {number} maxForce max force for this motor.
  24733. */
  24734. setMotor(force?: number, maxForce?: number): void;
  24735. /**
  24736. * Set the motor's limits.
  24737. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24738. */
  24739. setLimit(upperLimit: number, lowerLimit?: number): void;
  24740. }
  24741. /**
  24742. * This class represents a dual hinge physics joint (same as wheel joint)
  24743. */
  24744. class Hinge2Joint extends MotorEnabledJoint {
  24745. constructor(jointData: PhysicsJointData);
  24746. /**
  24747. * Set the motor values.
  24748. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24749. * @param {number} force the force to apply
  24750. * @param {number} maxForce max force for this motor.
  24751. * @param {motorIndex} the motor's index, 0 or 1.
  24752. */
  24753. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24754. /**
  24755. * Set the motor limits.
  24756. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24757. * @param {number} upperLimit the upper limit
  24758. * @param {number} lowerLimit lower limit
  24759. * @param {motorIndex} the motor's index, 0 or 1.
  24760. */
  24761. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24762. }
  24763. interface IMotorEnabledJoint {
  24764. physicsJoint: any;
  24765. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24766. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24767. }
  24768. interface DistanceJointData extends PhysicsJointData {
  24769. maxDistance: number;
  24770. }
  24771. interface SpringJointData extends PhysicsJointData {
  24772. length: number;
  24773. stiffness: number;
  24774. damping: number;
  24775. }
  24776. }
  24777. declare module BABYLON {
  24778. /**
  24779. * Postprocess used to generate anaglyphic rendering
  24780. */
  24781. class AnaglyphPostProcess extends PostProcess {
  24782. private _passedProcess;
  24783. /**
  24784. * Creates a new AnaglyphPostProcess
  24785. * @param name defines postprocess name
  24786. * @param options defines creation options or target ratio scale
  24787. * @param rigCameras defines cameras using this postprocess
  24788. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  24789. * @param engine defines hosting engine
  24790. * @param reusable defines if the postprocess will be reused multiple times per frame
  24791. */
  24792. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  24793. }
  24794. }
  24795. declare module BABYLON {
  24796. class BlackAndWhitePostProcess extends PostProcess {
  24797. degree: number;
  24798. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  24799. }
  24800. }
  24801. declare module BABYLON {
  24802. /**
  24803. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  24804. */
  24805. class BloomEffect extends PostProcessRenderEffect {
  24806. private bloomScale;
  24807. /**
  24808. * Internal
  24809. */
  24810. _effects: Array<PostProcess>;
  24811. /**
  24812. * Internal
  24813. */
  24814. _downscale: ExtractHighlightsPostProcess;
  24815. private _blurX;
  24816. private _blurY;
  24817. private _merge;
  24818. /**
  24819. * The luminance threshold to find bright areas of the image to bloom.
  24820. */
  24821. threshold: number;
  24822. /**
  24823. * The strength of the bloom.
  24824. */
  24825. weight: number;
  24826. /**
  24827. * Specifies the size of the bloom blur kernel, relative to the final output size
  24828. */
  24829. kernel: number;
  24830. /**
  24831. * Creates a new instance of @see BloomEffect
  24832. * @param scene The scene the effect belongs to.
  24833. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  24834. * @param bloomKernel The size of the kernel to be used when applying the blur.
  24835. * @param bloomWeight The the strength of bloom.
  24836. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  24837. * @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)
  24838. */
  24839. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  24840. /**
  24841. * Disposes each of the internal effects for a given camera.
  24842. * @param camera The camera to dispose the effect on.
  24843. */
  24844. disposeEffects(camera: Camera): void;
  24845. /**
  24846. * Internal
  24847. */
  24848. _updateEffects(): void;
  24849. /**
  24850. * Internal
  24851. * @returns if all the contained post processes are ready.
  24852. */
  24853. _isReady(): boolean;
  24854. }
  24855. }
  24856. declare module BABYLON {
  24857. /**
  24858. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  24859. */
  24860. class BloomMergePostProcess extends PostProcess {
  24861. /** Weight of the bloom to be added to the original input. */ weight: number;
  24862. /**
  24863. * Creates a new instance of @see BloomMergePostProcess
  24864. * @param name The name of the effect.
  24865. * @param originalFromInput Post process which's input will be used for the merge.
  24866. * @param blurred Blurred highlights post process which's output will be used.
  24867. * @param weight Weight of the bloom to be added to the original input.
  24868. * @param options The required width/height ratio to downsize to before computing the render pass.
  24869. * @param camera The camera to apply the render pass to.
  24870. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24871. * @param engine The engine which the post process will be applied. (default: current engine)
  24872. * @param reusable If the post process can be reused on the same frame. (default: false)
  24873. * @param textureType Type of textures used when performing the post process. (default: 0)
  24874. * @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)
  24875. */
  24876. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess, /** Weight of the bloom to be added to the original input. */ weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  24877. }
  24878. }
  24879. declare module BABYLON {
  24880. /**
  24881. * The Blur Post Process which blurs an image based on a kernel and direction.
  24882. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  24883. */
  24884. class BlurPostProcess extends PostProcess {
  24885. /** The direction in which to blur the image. */ direction: Vector2;
  24886. private blockCompilation;
  24887. protected _kernel: number;
  24888. protected _idealKernel: number;
  24889. protected _packedFloat: boolean;
  24890. private _staticDefines;
  24891. /**
  24892. * Gets the length in pixels of the blur sample region
  24893. */
  24894. /**
  24895. * Sets the length in pixels of the blur sample region
  24896. */
  24897. kernel: number;
  24898. /**
  24899. * Gets wether or not the blur is unpacking/repacking floats
  24900. */
  24901. /**
  24902. * Sets wether or not the blur needs to unpack/repack floats
  24903. */
  24904. packedFloat: boolean;
  24905. /**
  24906. * Creates a new instance BlurPostProcess
  24907. * @param name The name of the effect.
  24908. * @param direction The direction in which to blur the image.
  24909. * @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.
  24910. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24911. * @param camera The camera to apply the render pass to.
  24912. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24913. * @param engine The engine which the post process will be applied. (default: current engine)
  24914. * @param reusable If the post process can be reused on the same frame. (default: false)
  24915. * @param textureType Type of textures used when performing the post process. (default: 0)
  24916. * @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)
  24917. */
  24918. constructor(name: string, /** The direction in which to blur the image. */ direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  24919. /**
  24920. * Updates the effect with the current post process compile time values and recompiles the shader.
  24921. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24922. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24923. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24924. * @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
  24925. * @param onCompiled Called when the shader has been compiled.
  24926. * @param onError Called if there is an error when compiling a shader.
  24927. */
  24928. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24929. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24930. /**
  24931. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  24932. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  24933. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  24934. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  24935. * The gaps between physical kernels are compensated for in the weighting of the samples
  24936. * @param idealKernel Ideal blur kernel.
  24937. * @return Nearest best kernel.
  24938. */
  24939. protected _nearestBestKernel(idealKernel: number): number;
  24940. /**
  24941. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  24942. * @param x The point on the Gaussian distribution to sample.
  24943. * @return the value of the Gaussian function at x.
  24944. */
  24945. protected _gaussianWeight(x: number): number;
  24946. /**
  24947. * Generates a string that can be used as a floating point number in GLSL.
  24948. * @param x Value to print.
  24949. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  24950. * @return GLSL float string.
  24951. */
  24952. protected _glslFloat(x: number, decimalFigures?: number): string;
  24953. }
  24954. }
  24955. declare module BABYLON {
  24956. /**
  24957. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  24958. */
  24959. class ChromaticAberrationPostProcess extends PostProcess {
  24960. /**
  24961. * The amount of seperation of rgb channels (default: 30)
  24962. */
  24963. aberrationAmount: number;
  24964. /**
  24965. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  24966. */
  24967. radialIntensity: number;
  24968. /**
  24969. * 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))
  24970. */
  24971. direction: Vector2;
  24972. /**
  24973. * 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))
  24974. */
  24975. centerPosition: Vector2;
  24976. /**
  24977. * Creates a new instance ChromaticAberrationPostProcess
  24978. * @param name The name of the effect.
  24979. * @param screenWidth The width of the screen to apply the effect on.
  24980. * @param screenHeight The height of the screen to apply the effect on.
  24981. * @param options The required width/height ratio to downsize to before computing the render pass.
  24982. * @param camera The camera to apply the render pass to.
  24983. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24984. * @param engine The engine which the post process will be applied. (default: current engine)
  24985. * @param reusable If the post process can be reused on the same frame. (default: false)
  24986. * @param textureType Type of textures used when performing the post process. (default: 0)
  24987. * @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)
  24988. */
  24989. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  24990. }
  24991. }
  24992. declare module BABYLON {
  24993. /**
  24994. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  24995. */
  24996. class CircleOfConfusionPostProcess extends PostProcess {
  24997. /**
  24998. * 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.
  24999. */
  25000. lensSize: number;
  25001. /**
  25002. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25003. */
  25004. fStop: number;
  25005. /**
  25006. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25007. */
  25008. focusDistance: number;
  25009. /**
  25010. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  25011. */
  25012. focalLength: number;
  25013. private _depthTexture;
  25014. /**
  25015. * Creates a new instance CircleOfConfusionPostProcess
  25016. * @param name The name of the effect.
  25017. * @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.
  25018. * @param options The required width/height ratio to downsize to before computing the render pass.
  25019. * @param camera The camera to apply the render pass to.
  25020. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25021. * @param engine The engine which the post process will be applied. (default: current engine)
  25022. * @param reusable If the post process can be reused on the same frame. (default: false)
  25023. * @param textureType Type of textures used when performing the post process. (default: 0)
  25024. * @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)
  25025. */
  25026. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25027. /**
  25028. * 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.
  25029. */
  25030. depthTexture: RenderTargetTexture;
  25031. }
  25032. }
  25033. declare module BABYLON {
  25034. class ColorCorrectionPostProcess extends PostProcess {
  25035. private _colorTableTexture;
  25036. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25037. }
  25038. }
  25039. declare module BABYLON {
  25040. /**
  25041. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  25042. * input texture to perform effects such as edge detection or sharpening
  25043. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  25044. */
  25045. class ConvolutionPostProcess extends PostProcess {
  25046. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  25047. /**
  25048. * Creates a new instance ConvolutionPostProcess
  25049. * @param name The name of the effect.
  25050. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  25051. * @param options The required width/height ratio to downsize to before computing the render pass.
  25052. * @param camera The camera to apply the render pass to.
  25053. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25054. * @param engine The engine which the post process will be applied. (default: current engine)
  25055. * @param reusable If the post process can be reused on the same frame. (default: false)
  25056. * @param textureType Type of textures used when performing the post process. (default: 0)
  25057. */
  25058. constructor(name: string, /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25059. /**
  25060. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25061. */
  25062. static EdgeDetect0Kernel: number[];
  25063. /**
  25064. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25065. */
  25066. static EdgeDetect1Kernel: number[];
  25067. /**
  25068. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25069. */
  25070. static EdgeDetect2Kernel: number[];
  25071. /**
  25072. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25073. */
  25074. static SharpenKernel: number[];
  25075. /**
  25076. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25077. */
  25078. static EmbossKernel: number[];
  25079. /**
  25080. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25081. */
  25082. static GaussianKernel: number[];
  25083. }
  25084. }
  25085. declare module BABYLON {
  25086. /**
  25087. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  25088. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  25089. * based on samples that have a large difference in distance than the center pixel.
  25090. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  25091. */
  25092. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  25093. direction: Vector2;
  25094. /**
  25095. * Creates a new instance CircleOfConfusionPostProcess
  25096. * @param name The name of the effect.
  25097. * @param scene The scene the effect belongs to.
  25098. * @param direction The direction the blur should be applied.
  25099. * @param kernel The size of the kernel used to blur.
  25100. * @param options The required width/height ratio to downsize to before computing the render pass.
  25101. * @param camera The camera to apply the render pass to.
  25102. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  25103. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  25104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25105. * @param engine The engine which the post process will be applied. (default: current engine)
  25106. * @param reusable If the post process can be reused on the same frame. (default: false)
  25107. * @param textureType Type of textures used when performing the post process. (default: 0)
  25108. * @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)
  25109. */
  25110. 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);
  25111. }
  25112. }
  25113. declare module BABYLON {
  25114. /**
  25115. * Specifies the level of max blur that should be applied when using the depth of field effect
  25116. */
  25117. enum DepthOfFieldEffectBlurLevel {
  25118. /**
  25119. * Subtle blur
  25120. */
  25121. Low = 0,
  25122. /**
  25123. * Medium blur
  25124. */
  25125. Medium = 1,
  25126. /**
  25127. * Large blur
  25128. */
  25129. High = 2,
  25130. }
  25131. /**
  25132. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  25133. */
  25134. class DepthOfFieldEffect extends PostProcessRenderEffect {
  25135. private _circleOfConfusion;
  25136. /**
  25137. * Internal, blurs from high to low
  25138. */
  25139. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  25140. private _depthOfFieldBlurY;
  25141. private _dofMerge;
  25142. /**
  25143. * Internal post processes in depth of field effect
  25144. */
  25145. _effects: Array<PostProcess>;
  25146. /**
  25147. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  25148. */
  25149. focalLength: number;
  25150. /**
  25151. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25152. */
  25153. fStop: number;
  25154. /**
  25155. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25156. */
  25157. focusDistance: number;
  25158. /**
  25159. * 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.
  25160. */
  25161. lensSize: number;
  25162. /**
  25163. * Creates a new instance DepthOfFieldEffect
  25164. * @param scene The scene the effect belongs to.
  25165. * @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.
  25166. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  25167. * @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)
  25168. */
  25169. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  25170. /**
  25171. * 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.
  25172. */
  25173. depthTexture: RenderTargetTexture;
  25174. /**
  25175. * Disposes each of the internal effects for a given camera.
  25176. * @param camera The camera to dispose the effect on.
  25177. */
  25178. disposeEffects(camera: Camera): void;
  25179. /**
  25180. * Internal
  25181. */
  25182. _updateEffects(): void;
  25183. /**
  25184. * Internal
  25185. * @returns if all the contained post processes are ready.
  25186. */
  25187. _isReady(): boolean;
  25188. }
  25189. }
  25190. declare module BABYLON {
  25191. /**
  25192. * Options to be set when merging outputs from the default pipeline.
  25193. */
  25194. class DepthOfFieldMergePostProcessOptions {
  25195. /**
  25196. * The original image to merge on top of
  25197. */
  25198. originalFromInput: PostProcess;
  25199. /**
  25200. * Parameters to perform the merge of the depth of field effect
  25201. */
  25202. depthOfField?: {
  25203. circleOfConfusion: PostProcess;
  25204. blurSteps: Array<PostProcess>;
  25205. };
  25206. /**
  25207. * Parameters to perform the merge of bloom effect
  25208. */
  25209. bloom?: {
  25210. blurred: PostProcess;
  25211. weight: number;
  25212. };
  25213. }
  25214. /**
  25215. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  25216. */
  25217. class DepthOfFieldMergePostProcess extends PostProcess {
  25218. private blurSteps;
  25219. /**
  25220. * Creates a new instance of DepthOfFieldMergePostProcess
  25221. * @param name The name of the effect.
  25222. * @param originalFromInput Post process which's input will be used for the merge.
  25223. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  25224. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  25225. * @param options The required width/height ratio to downsize to before computing the render pass.
  25226. * @param camera The camera to apply the render pass to.
  25227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25228. * @param engine The engine which the post process will be applied. (default: current engine)
  25229. * @param reusable If the post process can be reused on the same frame. (default: false)
  25230. * @param textureType Type of textures used when performing the post process. (default: 0)
  25231. * @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)
  25232. */
  25233. 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);
  25234. /**
  25235. * Updates the effect with the current post process compile time values and recompiles the shader.
  25236. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25237. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25238. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25239. * @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
  25240. * @param onCompiled Called when the shader has been compiled.
  25241. * @param onError Called if there is an error when compiling a shader.
  25242. */
  25243. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25244. }
  25245. }
  25246. declare module BABYLON {
  25247. class DisplayPassPostProcess extends PostProcess {
  25248. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25249. }
  25250. }
  25251. declare module BABYLON {
  25252. /**
  25253. * 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.
  25254. */
  25255. class ExtractHighlightsPostProcess extends PostProcess {
  25256. /**
  25257. * The luminance threshold, pixels below this value will be set to black.
  25258. */
  25259. threshold: number;
  25260. /**
  25261. * Internal
  25262. */
  25263. _exposure: number;
  25264. /**
  25265. * Post process which has the input texture to be used when performing highlight extraction
  25266. */
  25267. _inputPostProcess: Nullable<PostProcess>;
  25268. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25269. }
  25270. }
  25271. declare module BABYLON {
  25272. class FilterPostProcess extends PostProcess {
  25273. kernelMatrix: Matrix;
  25274. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25275. }
  25276. }
  25277. declare module BABYLON {
  25278. class FxaaPostProcess extends PostProcess {
  25279. texelWidth: number;
  25280. texelHeight: number;
  25281. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25282. private _getDefines();
  25283. }
  25284. }
  25285. declare module BABYLON {
  25286. /**
  25287. * The GrainPostProcess adds noise to the image at mid luminance levels
  25288. */
  25289. class GrainPostProcess extends PostProcess {
  25290. /**
  25291. * The intensity of the grain added (default: 30)
  25292. */
  25293. intensity: number;
  25294. /**
  25295. * If the grain should be randomized on every frame
  25296. */
  25297. animated: boolean;
  25298. /**
  25299. * Creates a new instance of @see GrainPostProcess
  25300. * @param name The name of the effect.
  25301. * @param options The required width/height ratio to downsize to before computing the render pass.
  25302. * @param camera The camera to apply the render pass to.
  25303. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25304. * @param engine The engine which the post process will be applied. (default: current engine)
  25305. * @param reusable If the post process can be reused on the same frame. (default: false)
  25306. * @param textureType Type of textures used when performing the post process. (default: 0)
  25307. * @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)
  25308. */
  25309. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25310. }
  25311. }
  25312. declare module BABYLON {
  25313. class HighlightsPostProcess extends PostProcess {
  25314. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25315. }
  25316. }
  25317. declare module BABYLON {
  25318. class ImageProcessingPostProcess extends PostProcess {
  25319. /**
  25320. * Default configuration related to image processing available in the PBR Material.
  25321. */
  25322. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25323. /**
  25324. * Gets the image processing configuration used either in this material.
  25325. */
  25326. /**
  25327. * Sets the Default image processing configuration used either in the this material.
  25328. *
  25329. * If sets to null, the scene one is in use.
  25330. */
  25331. imageProcessingConfiguration: ImageProcessingConfiguration;
  25332. /**
  25333. * Keep track of the image processing observer to allow dispose and replace.
  25334. */
  25335. private _imageProcessingObserver;
  25336. /**
  25337. * Attaches a new image processing configuration to the PBR Material.
  25338. * @param configuration
  25339. */
  25340. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  25341. /**
  25342. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25343. */
  25344. /**
  25345. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25346. */
  25347. colorCurves: Nullable<ColorCurves>;
  25348. /**
  25349. * Gets wether the color curves effect is enabled.
  25350. */
  25351. /**
  25352. * Sets wether the color curves effect is enabled.
  25353. */
  25354. colorCurvesEnabled: boolean;
  25355. /**
  25356. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25357. */
  25358. /**
  25359. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25360. */
  25361. colorGradingTexture: Nullable<BaseTexture>;
  25362. /**
  25363. * Gets wether the color grading effect is enabled.
  25364. */
  25365. /**
  25366. * Gets wether the color grading effect is enabled.
  25367. */
  25368. colorGradingEnabled: boolean;
  25369. /**
  25370. * Gets exposure used in the effect.
  25371. */
  25372. /**
  25373. * Sets exposure used in the effect.
  25374. */
  25375. exposure: number;
  25376. /**
  25377. * Gets wether tonemapping is enabled or not.
  25378. */
  25379. /**
  25380. * Sets wether tonemapping is enabled or not
  25381. */
  25382. toneMappingEnabled: boolean;
  25383. /**
  25384. * Gets contrast used in the effect.
  25385. */
  25386. /**
  25387. * Sets contrast used in the effect.
  25388. */
  25389. contrast: number;
  25390. /**
  25391. * Gets Vignette stretch size.
  25392. */
  25393. /**
  25394. * Sets Vignette stretch size.
  25395. */
  25396. vignetteStretch: number;
  25397. /**
  25398. * Gets Vignette centre X Offset.
  25399. */
  25400. /**
  25401. * Sets Vignette centre X Offset.
  25402. */
  25403. vignetteCentreX: number;
  25404. /**
  25405. * Gets Vignette centre Y Offset.
  25406. */
  25407. /**
  25408. * Sets Vignette centre Y Offset.
  25409. */
  25410. vignetteCentreY: number;
  25411. /**
  25412. * Gets Vignette weight or intensity of the vignette effect.
  25413. */
  25414. /**
  25415. * Sets Vignette weight or intensity of the vignette effect.
  25416. */
  25417. vignetteWeight: number;
  25418. /**
  25419. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25420. * if vignetteEnabled is set to true.
  25421. */
  25422. /**
  25423. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25424. * if vignetteEnabled is set to true.
  25425. */
  25426. vignetteColor: Color4;
  25427. /**
  25428. * Gets Camera field of view used by the Vignette effect.
  25429. */
  25430. /**
  25431. * Sets Camera field of view used by the Vignette effect.
  25432. */
  25433. vignetteCameraFov: number;
  25434. /**
  25435. * Gets the vignette blend mode allowing different kind of effect.
  25436. */
  25437. /**
  25438. * Sets the vignette blend mode allowing different kind of effect.
  25439. */
  25440. vignetteBlendMode: number;
  25441. /**
  25442. * Gets wether the vignette effect is enabled.
  25443. */
  25444. /**
  25445. * Sets wether the vignette effect is enabled.
  25446. */
  25447. vignetteEnabled: boolean;
  25448. private _fromLinearSpace;
  25449. /**
  25450. * Gets wether the input of the processing is in Gamma or Linear Space.
  25451. */
  25452. /**
  25453. * Sets wether the input of the processing is in Gamma or Linear Space.
  25454. */
  25455. fromLinearSpace: boolean;
  25456. /**
  25457. * Defines cache preventing GC.
  25458. */
  25459. private _defines;
  25460. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25461. getClassName(): string;
  25462. protected _updateParameters(): void;
  25463. dispose(camera?: Camera): void;
  25464. }
  25465. }
  25466. declare module BABYLON {
  25467. class PassPostProcess extends PostProcess {
  25468. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25469. }
  25470. }
  25471. declare module BABYLON {
  25472. type PostProcessOptions = {
  25473. width: number;
  25474. height: number;
  25475. };
  25476. /**
  25477. * PostProcess can be used to apply a shader to a texture after it has been rendered
  25478. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  25479. */
  25480. class PostProcess {
  25481. /** Name of the PostProcess. */ name: string;
  25482. /**
  25483. * Width of the texture to apply the post process on
  25484. */
  25485. width: number;
  25486. /**
  25487. * Height of the texture to apply the post process on
  25488. */
  25489. height: number;
  25490. /**
  25491. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  25492. */
  25493. _outputTexture: Nullable<InternalTexture>;
  25494. /**
  25495. * Sampling mode used by the shader
  25496. * See https://doc.babylonjs.com/classes/3.1/texture
  25497. */
  25498. renderTargetSamplingMode: number;
  25499. /**
  25500. * Clear color to use when screen clearing
  25501. */
  25502. clearColor: Color4;
  25503. /**
  25504. * If the buffer needs to be cleared before applying the post process. (default: true)
  25505. * Should be set to false if shader will overwrite all previous pixels.
  25506. */
  25507. autoClear: boolean;
  25508. /**
  25509. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  25510. */
  25511. alphaMode: number;
  25512. /**
  25513. * Sets the setAlphaBlendConstants of the babylon engine
  25514. */
  25515. alphaConstants: Color4;
  25516. /**
  25517. * Animations to be used for the post processing
  25518. */
  25519. animations: Animation[];
  25520. /**
  25521. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  25522. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  25523. */
  25524. enablePixelPerfectMode: boolean;
  25525. /**
  25526. * Force the postprocess to be applied without taking in account viewport
  25527. */
  25528. forceFullscreenViewport: boolean;
  25529. /**
  25530. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  25531. */
  25532. scaleMode: number;
  25533. /**
  25534. * Force textures to be a power of two (default: false)
  25535. */
  25536. alwaysForcePOT: boolean;
  25537. /**
  25538. * Number of sample textures (default: 1)
  25539. */
  25540. samples: number;
  25541. /**
  25542. * Modify the scale of the post process to be the same as the viewport (default: false)
  25543. */
  25544. adaptScaleToCurrentViewport: boolean;
  25545. private _camera;
  25546. private _scene;
  25547. private _engine;
  25548. private _options;
  25549. private _reusable;
  25550. private _textureType;
  25551. /**
  25552. * Smart array of input and output textures for the post process.
  25553. */
  25554. _textures: SmartArray<InternalTexture>;
  25555. /**
  25556. * The index in _textures that corresponds to the output texture.
  25557. */
  25558. _currentRenderTextureInd: number;
  25559. private _effect;
  25560. private _samplers;
  25561. private _fragmentUrl;
  25562. private _vertexUrl;
  25563. private _parameters;
  25564. private _scaleRatio;
  25565. protected _indexParameters: any;
  25566. private _shareOutputWithPostProcess;
  25567. private _texelSize;
  25568. private _forcedOutputTexture;
  25569. /**
  25570. * An event triggered when the postprocess is activated.
  25571. */
  25572. onActivateObservable: Observable<Camera>;
  25573. private _onActivateObserver;
  25574. /**
  25575. * A function that is added to the onActivateObservable
  25576. */
  25577. onActivate: Nullable<(camera: Camera) => void>;
  25578. /**
  25579. * An event triggered when the postprocess changes its size.
  25580. */
  25581. onSizeChangedObservable: Observable<PostProcess>;
  25582. private _onSizeChangedObserver;
  25583. /**
  25584. * A function that is added to the onSizeChangedObservable
  25585. */
  25586. onSizeChanged: (postProcess: PostProcess) => void;
  25587. /**
  25588. * An event triggered when the postprocess applies its effect.
  25589. */
  25590. onApplyObservable: Observable<Effect>;
  25591. private _onApplyObserver;
  25592. /**
  25593. * A function that is added to the onApplyObservable
  25594. */
  25595. onApply: (effect: Effect) => void;
  25596. /**
  25597. * An event triggered before rendering the postprocess
  25598. */
  25599. onBeforeRenderObservable: Observable<Effect>;
  25600. private _onBeforeRenderObserver;
  25601. /**
  25602. * A function that is added to the onBeforeRenderObservable
  25603. */
  25604. onBeforeRender: (effect: Effect) => void;
  25605. /**
  25606. * An event triggered after rendering the postprocess
  25607. */
  25608. onAfterRenderObservable: Observable<Effect>;
  25609. private _onAfterRenderObserver;
  25610. /**
  25611. * A function that is added to the onAfterRenderObservable
  25612. */
  25613. onAfterRender: (efect: Effect) => void;
  25614. /**
  25615. * 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
  25616. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  25617. */
  25618. inputTexture: InternalTexture;
  25619. /**
  25620. * Gets the camera which post process is applied to.
  25621. * @returns The camera the post process is applied to.
  25622. */
  25623. getCamera(): Camera;
  25624. /**
  25625. * Gets the texel size of the postprocess.
  25626. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  25627. */
  25628. readonly texelSize: Vector2;
  25629. /**
  25630. * Creates a new instance PostProcess
  25631. * @param name The name of the PostProcess.
  25632. * @param fragmentUrl The url of the fragment shader to be used.
  25633. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  25634. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  25635. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  25636. * @param camera The camera to apply the render pass to.
  25637. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25638. * @param engine The engine which the post process will be applied. (default: current engine)
  25639. * @param reusable If the post process can be reused on the same frame. (default: false)
  25640. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  25641. * @param textureType Type of textures used when performing the post process. (default: 0)
  25642. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  25643. * @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
  25644. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  25645. */
  25646. constructor(/** Name of the PostProcess. */ name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  25647. /**
  25648. * Gets the engine which this post process belongs to.
  25649. * @returns The engine the post process was enabled with.
  25650. */
  25651. getEngine(): Engine;
  25652. /**
  25653. * The effect that is created when initializing the post process.
  25654. * @returns The created effect corrisponding the the postprocess.
  25655. */
  25656. getEffect(): Effect;
  25657. /**
  25658. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  25659. * @param postProcess The post process to share the output with.
  25660. * @returns This post process.
  25661. */
  25662. shareOutputWith(postProcess: PostProcess): PostProcess;
  25663. /**
  25664. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  25665. * This should be called if the post process that shares output with this post process is disabled/disposed.
  25666. */
  25667. useOwnOutput(): void;
  25668. /**
  25669. * Updates the effect with the current post process compile time values and recompiles the shader.
  25670. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25671. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25672. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25673. * @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
  25674. * @param onCompiled Called when the shader has been compiled.
  25675. * @param onError Called if there is an error when compiling a shader.
  25676. */
  25677. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25678. /**
  25679. * The post process is reusable if it can be used multiple times within one frame.
  25680. * @returns If the post process is reusable
  25681. */
  25682. isReusable(): boolean;
  25683. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  25684. markTextureDirty(): void;
  25685. /**
  25686. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  25687. * 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.
  25688. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  25689. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  25690. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  25691. * @returns The target texture that was bound to be written to.
  25692. */
  25693. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  25694. /**
  25695. * If the post process is supported.
  25696. */
  25697. readonly isSupported: boolean;
  25698. /**
  25699. * The aspect ratio of the output texture.
  25700. */
  25701. readonly aspectRatio: number;
  25702. /**
  25703. * Get a value indicating if the post-process is ready to be used
  25704. * @returns true if the post-process is ready (shader is compiled)
  25705. */
  25706. isReady(): boolean;
  25707. /**
  25708. * Binds all textures and uniforms to the shader, this will be run on every pass.
  25709. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  25710. */
  25711. apply(): Nullable<Effect>;
  25712. private _disposeTextures();
  25713. /**
  25714. * Disposes the post process.
  25715. * @param camera The camera to dispose the post process on.
  25716. */
  25717. dispose(camera?: Camera): void;
  25718. }
  25719. }
  25720. declare module BABYLON {
  25721. /**
  25722. * PostProcessManager is used to manage one or more post processes or post process pipelines
  25723. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  25724. */
  25725. class PostProcessManager {
  25726. private _scene;
  25727. private _indexBuffer;
  25728. private _vertexBuffers;
  25729. /**
  25730. * Creates a new instance PostProcess
  25731. * @param scene The scene that the post process is associated with.
  25732. */
  25733. constructor(scene: Scene);
  25734. private _prepareBuffers();
  25735. private _buildIndexBuffer();
  25736. /**
  25737. * Rebuilds the vertex buffers of the manager.
  25738. */
  25739. _rebuild(): void;
  25740. /**
  25741. * Prepares a frame to be run through a post process.
  25742. * @param sourceTexture The input texture to the post procesess. (default: null)
  25743. * @param postProcesses An array of post processes to be run. (default: null)
  25744. * @returns True if the post processes were able to be run.
  25745. */
  25746. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  25747. /**
  25748. * Manually render a set of post processes to a texture.
  25749. * @param postProcesses An array of post processes to be run.
  25750. * @param targetTexture The target texture to render to.
  25751. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  25752. */
  25753. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  25754. /**
  25755. * Finalize the result of the output of the postprocesses.
  25756. * @param doNotPresent If true the result will not be displayed to the screen.
  25757. * @param targetTexture The target texture to render to.
  25758. * @param faceIndex The index of the face to bind the target texture to.
  25759. * @param postProcesses The array of post processes to render.
  25760. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  25761. */
  25762. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  25763. /**
  25764. * Disposes of the post process manager.
  25765. */
  25766. dispose(): void;
  25767. }
  25768. }
  25769. declare module BABYLON {
  25770. class RefractionPostProcess extends PostProcess {
  25771. color: Color3;
  25772. depth: number;
  25773. colorLevel: number;
  25774. private _refTexture;
  25775. private _ownRefractionTexture;
  25776. /**
  25777. * Gets or sets the refraction texture
  25778. * Please note that you are responsible for disposing the texture if you set it manually
  25779. */
  25780. refractionTexture: Texture;
  25781. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25782. dispose(camera: Camera): void;
  25783. }
  25784. }
  25785. declare module BABYLON {
  25786. /**
  25787. * The SharpenPostProcess applies a sharpen kernel to every pixel
  25788. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  25789. */
  25790. class SharpenPostProcess extends PostProcess {
  25791. /**
  25792. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  25793. */
  25794. colorAmount: number;
  25795. /**
  25796. * How much sharpness should be applied (default: 0.3)
  25797. */
  25798. edgeAmount: number;
  25799. /**
  25800. * Creates a new instance ConvolutionPostProcess
  25801. * @param name The name of the effect.
  25802. * @param options The required width/height ratio to downsize to before computing the render pass.
  25803. * @param camera The camera to apply the render pass to.
  25804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25805. * @param engine The engine which the post process will be applied. (default: current engine)
  25806. * @param reusable If the post process can be reused on the same frame. (default: false)
  25807. * @param textureType Type of textures used when performing the post process. (default: 0)
  25808. * @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)
  25809. */
  25810. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25811. }
  25812. }
  25813. declare module BABYLON {
  25814. class StereoscopicInterlacePostProcess extends PostProcess {
  25815. private _stepSize;
  25816. private _passedProcess;
  25817. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25818. }
  25819. }
  25820. declare module BABYLON {
  25821. /** Defines operator used for tonemapping */
  25822. enum TonemappingOperator {
  25823. /** Hable */
  25824. Hable = 0,
  25825. /** Reinhard */
  25826. Reinhard = 1,
  25827. /** HejiDawson */
  25828. HejiDawson = 2,
  25829. /** Photographic */
  25830. Photographic = 3,
  25831. }
  25832. /**
  25833. * Defines a post process to apply tone mapping
  25834. */
  25835. class TonemapPostProcess extends PostProcess {
  25836. private _operator;
  25837. /** Defines the required exposure adjustement */
  25838. exposureAdjustment: number;
  25839. /**
  25840. * Creates a new TonemapPostProcess
  25841. * @param name defines the name of the postprocess
  25842. * @param _operator defines the operator to use
  25843. * @param exposureAdjustment defines the required exposure adjustement
  25844. * @param camera defines the camera to use (can be null)
  25845. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  25846. * @param engine defines the hosting engine (can be ignore if camera is set)
  25847. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  25848. */
  25849. constructor(name: string, _operator: TonemappingOperator,
  25850. /** Defines the required exposure adjustement */
  25851. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  25852. }
  25853. }
  25854. declare module BABYLON {
  25855. class VolumetricLightScatteringPostProcess extends PostProcess {
  25856. private _volumetricLightScatteringPass;
  25857. private _volumetricLightScatteringRTT;
  25858. private _viewPort;
  25859. private _screenCoordinates;
  25860. private _cachedDefines;
  25861. /**
  25862. * If not undefined, the mesh position is computed from the attached node position
  25863. */
  25864. attachedNode: {
  25865. position: Vector3;
  25866. };
  25867. /**
  25868. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  25869. */
  25870. customMeshPosition: Vector3;
  25871. /**
  25872. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  25873. */
  25874. useCustomMeshPosition: boolean;
  25875. /**
  25876. * If the post-process should inverse the light scattering direction
  25877. */
  25878. invert: boolean;
  25879. /**
  25880. * The internal mesh used by the post-process
  25881. */
  25882. mesh: Mesh;
  25883. useDiffuseColor: boolean;
  25884. /**
  25885. * Array containing the excluded meshes not rendered in the internal pass
  25886. */
  25887. excludedMeshes: AbstractMesh[];
  25888. /**
  25889. * Controls the overall intensity of the post-process
  25890. */
  25891. exposure: number;
  25892. /**
  25893. * Dissipates each sample's contribution in range [0, 1]
  25894. */
  25895. decay: number;
  25896. /**
  25897. * Controls the overall intensity of each sample
  25898. */
  25899. weight: number;
  25900. /**
  25901. * Controls the density of each sample
  25902. */
  25903. density: number;
  25904. /**
  25905. * @constructor
  25906. * @param {string} name - The post-process name
  25907. * @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)
  25908. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  25909. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  25910. * @param {number} samples - The post-process quality, default 100
  25911. * @param {number} samplingMode - The post-process filtering mode
  25912. * @param {BABYLON.Engine} engine - The babylon engine
  25913. * @param {boolean} reusable - If the post-process is reusable
  25914. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  25915. */
  25916. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  25917. getClassName(): string;
  25918. private _isReady(subMesh, useInstances);
  25919. /**
  25920. * Sets the new light position for light scattering effect
  25921. * @param {BABYLON.Vector3} The new custom light position
  25922. */
  25923. setCustomMeshPosition(position: Vector3): void;
  25924. /**
  25925. * Returns the light position for light scattering effect
  25926. * @return {BABYLON.Vector3} The custom light position
  25927. */
  25928. getCustomMeshPosition(): Vector3;
  25929. /**
  25930. * Disposes the internal assets and detaches the post-process from the camera
  25931. */
  25932. dispose(camera: Camera): void;
  25933. /**
  25934. * Returns the render target texture used by the post-process
  25935. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  25936. */
  25937. getPass(): RenderTargetTexture;
  25938. private _meshExcluded(mesh);
  25939. private _createPass(scene, ratio);
  25940. private _updateMeshScreenCoordinates(scene);
  25941. /**
  25942. * Creates a default mesh for the Volumeric Light Scattering post-process
  25943. * @param {string} The mesh name
  25944. * @param {BABYLON.Scene} The scene where to create the mesh
  25945. * @return {BABYLON.Mesh} the default mesh
  25946. */
  25947. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  25948. }
  25949. }
  25950. declare module BABYLON {
  25951. class VRDistortionCorrectionPostProcess extends PostProcess {
  25952. private _isRightEye;
  25953. private _distortionFactors;
  25954. private _postProcessScaleFactor;
  25955. private _lensCenterOffset;
  25956. private _scaleIn;
  25957. private _scaleFactor;
  25958. private _lensCenter;
  25959. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  25960. }
  25961. }
  25962. declare module BABYLON {
  25963. class ReflectionProbe {
  25964. name: string;
  25965. private _scene;
  25966. private _renderTargetTexture;
  25967. private _projectionMatrix;
  25968. private _viewMatrix;
  25969. private _target;
  25970. private _add;
  25971. private _attachedMesh;
  25972. private _invertYAxis;
  25973. position: Vector3;
  25974. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  25975. samples: number;
  25976. refreshRate: number;
  25977. getScene(): Scene;
  25978. readonly cubeTexture: RenderTargetTexture;
  25979. readonly renderList: Nullable<AbstractMesh[]>;
  25980. attachToMesh(mesh: AbstractMesh): void;
  25981. /**
  25982. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  25983. *
  25984. * @param renderingGroupId The rendering group id corresponding to its index
  25985. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  25986. */
  25987. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  25988. dispose(): void;
  25989. }
  25990. }
  25991. declare module BABYLON {
  25992. class BoundingBoxRenderer {
  25993. frontColor: Color3;
  25994. backColor: Color3;
  25995. showBackLines: boolean;
  25996. renderList: SmartArray<BoundingBox>;
  25997. private _scene;
  25998. private _colorShader;
  25999. private _vertexBuffers;
  26000. private _indexBuffer;
  26001. constructor(scene: Scene);
  26002. private _prepareRessources();
  26003. private _createIndexBuffer();
  26004. _rebuild(): void;
  26005. reset(): void;
  26006. render(): void;
  26007. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  26008. dispose(): void;
  26009. }
  26010. }
  26011. declare module BABYLON {
  26012. /**
  26013. * This represents a depth renderer in Babylon.
  26014. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  26015. */
  26016. class DepthRenderer {
  26017. private _scene;
  26018. private _depthMap;
  26019. private _effect;
  26020. private _cachedDefines;
  26021. private _camera;
  26022. /**
  26023. * Instantiates a depth renderer
  26024. * @param scene The scene the renderer belongs to
  26025. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  26026. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  26027. */
  26028. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  26029. /**
  26030. * Creates the depth rendering effect and checks if the effect is ready.
  26031. * @param subMesh The submesh to be used to render the depth map of
  26032. * @param useInstances If multiple world instances should be used
  26033. * @returns if the depth renderer is ready to render the depth map
  26034. */
  26035. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26036. /**
  26037. * Gets the texture which the depth map will be written to.
  26038. * @returns The depth map texture
  26039. */
  26040. getDepthMap(): RenderTargetTexture;
  26041. /**
  26042. * Disposes of the depth renderer.
  26043. */
  26044. dispose(): void;
  26045. }
  26046. }
  26047. declare module BABYLON {
  26048. class EdgesRenderer {
  26049. edgesWidthScalerForOrthographic: number;
  26050. edgesWidthScalerForPerspective: number;
  26051. private _source;
  26052. private _linesPositions;
  26053. private _linesNormals;
  26054. private _linesIndices;
  26055. private _epsilon;
  26056. private _indicesCount;
  26057. private _lineShader;
  26058. private _ib;
  26059. private _buffers;
  26060. private _checkVerticesInsteadOfIndices;
  26061. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  26062. private _prepareRessources();
  26063. _rebuild(): void;
  26064. dispose(): void;
  26065. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  26066. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  26067. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  26068. _generateEdgesLines(): void;
  26069. render(): void;
  26070. }
  26071. }
  26072. declare module BABYLON {
  26073. /**
  26074. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  26075. */
  26076. class GeometryBufferRenderer {
  26077. private _scene;
  26078. private _multiRenderTarget;
  26079. private _ratio;
  26080. private _enablePosition;
  26081. protected _effect: Effect;
  26082. protected _cachedDefines: string;
  26083. /**
  26084. * Set the render list (meshes to be rendered) used in the G buffer.
  26085. */
  26086. renderList: Mesh[];
  26087. /**
  26088. * Gets wether or not G buffer are supported by the running hardware.
  26089. * This requires draw buffer supports
  26090. */
  26091. readonly isSupported: boolean;
  26092. /**
  26093. * Gets wether or not position are enabled for the G buffer.
  26094. */
  26095. /**
  26096. * Sets wether or not position are enabled for the G buffer.
  26097. */
  26098. enablePosition: boolean;
  26099. /**
  26100. * Gets the scene associated with the buffer.
  26101. */
  26102. readonly scene: Scene;
  26103. /**
  26104. * Gets the ratio used by the buffer during its creation.
  26105. * How big is the buffer related to the main canvas.
  26106. */
  26107. readonly ratio: number;
  26108. /**
  26109. * Creates a new G Buffer for the scene
  26110. * @param scene The scene the buffer belongs to
  26111. * @param ratio How big is the buffer related to the main canvas.
  26112. */
  26113. constructor(scene: Scene, ratio?: number);
  26114. /**
  26115. * Checks wether everything is ready to render a submesh to the G buffer.
  26116. * @param subMesh the submesh to check readiness for
  26117. * @param useInstances is the mesh drawn using instance or not
  26118. * @returns true if ready otherwise false
  26119. */
  26120. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26121. /**
  26122. * Gets the current underlying G Buffer.
  26123. * @returns the buffer
  26124. */
  26125. getGBuffer(): MultiRenderTarget;
  26126. /**
  26127. * Gets the number of samples used to render the buffer (anti aliasing).
  26128. */
  26129. /**
  26130. * Sets the number of samples used to render the buffer (anti aliasing).
  26131. */
  26132. samples: number;
  26133. /**
  26134. * Disposes the renderer and frees up associated resources.
  26135. */
  26136. dispose(): void;
  26137. protected _createRenderTargets(): void;
  26138. }
  26139. }
  26140. declare module BABYLON {
  26141. class OutlineRenderer {
  26142. private _scene;
  26143. private _effect;
  26144. private _cachedDefines;
  26145. zOffset: number;
  26146. constructor(scene: Scene);
  26147. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  26148. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  26149. }
  26150. }
  26151. declare module BABYLON {
  26152. class RenderingGroup {
  26153. index: number;
  26154. private _scene;
  26155. private _opaqueSubMeshes;
  26156. private _transparentSubMeshes;
  26157. private _alphaTestSubMeshes;
  26158. private _depthOnlySubMeshes;
  26159. private _particleSystems;
  26160. private _spriteManagers;
  26161. private _opaqueSortCompareFn;
  26162. private _alphaTestSortCompareFn;
  26163. private _transparentSortCompareFn;
  26164. private _renderOpaque;
  26165. private _renderAlphaTest;
  26166. private _renderTransparent;
  26167. private _edgesRenderers;
  26168. onBeforeTransparentRendering: () => void;
  26169. /**
  26170. * Set the opaque sort comparison function.
  26171. * If null the sub meshes will be render in the order they were created
  26172. */
  26173. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26174. /**
  26175. * Set the alpha test sort comparison function.
  26176. * If null the sub meshes will be render in the order they were created
  26177. */
  26178. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26179. /**
  26180. * Set the transparent sort comparison function.
  26181. * If null the sub meshes will be render in the order they were created
  26182. */
  26183. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  26184. /**
  26185. * Creates a new rendering group.
  26186. * @param index The rendering group index
  26187. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  26188. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  26189. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  26190. */
  26191. 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>);
  26192. /**
  26193. * Render all the sub meshes contained in the group.
  26194. * @param customRenderFunction Used to override the default render behaviour of the group.
  26195. * @returns true if rendered some submeshes.
  26196. */
  26197. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  26198. /**
  26199. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  26200. * @param subMeshes The submeshes to render
  26201. */
  26202. private renderOpaqueSorted(subMeshes);
  26203. /**
  26204. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  26205. * @param subMeshes The submeshes to render
  26206. */
  26207. private renderAlphaTestSorted(subMeshes);
  26208. /**
  26209. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  26210. * @param subMeshes The submeshes to render
  26211. */
  26212. private renderTransparentSorted(subMeshes);
  26213. /**
  26214. * Renders the submeshes in a specified order.
  26215. * @param subMeshes The submeshes to sort before render
  26216. * @param sortCompareFn The comparison function use to sort
  26217. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  26218. * @param transparent Specifies to activate blending if true
  26219. */
  26220. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  26221. /**
  26222. * Renders the submeshes in the order they were dispatched (no sort applied).
  26223. * @param subMeshes The submeshes to render
  26224. */
  26225. private static renderUnsorted(subMeshes);
  26226. /**
  26227. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26228. * are rendered back to front if in the same alpha index.
  26229. *
  26230. * @param a The first submesh
  26231. * @param b The second submesh
  26232. * @returns The result of the comparison
  26233. */
  26234. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  26235. /**
  26236. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26237. * are rendered back to front.
  26238. *
  26239. * @param a The first submesh
  26240. * @param b The second submesh
  26241. * @returns The result of the comparison
  26242. */
  26243. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  26244. /**
  26245. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  26246. * are rendered front to back (prevent overdraw).
  26247. *
  26248. * @param a The first submesh
  26249. * @param b The second submesh
  26250. * @returns The result of the comparison
  26251. */
  26252. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  26253. /**
  26254. * Resets the different lists of submeshes to prepare a new frame.
  26255. */
  26256. prepare(): void;
  26257. dispose(): void;
  26258. /**
  26259. * Inserts the submesh in its correct queue depending on its material.
  26260. * @param subMesh The submesh to dispatch
  26261. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  26262. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  26263. */
  26264. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  26265. dispatchSprites(spriteManager: SpriteManager): void;
  26266. dispatchParticles(particleSystem: IParticleSystem): void;
  26267. private _renderParticles(activeMeshes);
  26268. private _renderSprites();
  26269. }
  26270. }
  26271. declare module BABYLON {
  26272. class RenderingManager {
  26273. /**
  26274. * The max id used for rendering groups (not included)
  26275. */
  26276. static MAX_RENDERINGGROUPS: number;
  26277. /**
  26278. * The min id used for rendering groups (included)
  26279. */
  26280. static MIN_RENDERINGGROUPS: number;
  26281. /**
  26282. * Used to globally prevent autoclearing scenes.
  26283. */
  26284. static AUTOCLEAR: boolean;
  26285. private _scene;
  26286. private _renderingGroups;
  26287. private _depthStencilBufferAlreadyCleaned;
  26288. private _autoClearDepthStencil;
  26289. private _customOpaqueSortCompareFn;
  26290. private _customAlphaTestSortCompareFn;
  26291. private _customTransparentSortCompareFn;
  26292. private _renderinGroupInfo;
  26293. constructor(scene: Scene);
  26294. private _clearDepthStencilBuffer(depth?, stencil?);
  26295. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  26296. reset(): void;
  26297. dispose(): void;
  26298. /**
  26299. * Clear the info related to rendering groups preventing retention points during dispose.
  26300. */
  26301. freeRenderingGroups(): void;
  26302. private _prepareRenderingGroup(renderingGroupId);
  26303. dispatchSprites(spriteManager: SpriteManager): void;
  26304. dispatchParticles(particleSystem: IParticleSystem): void;
  26305. /**
  26306. * @param subMesh The submesh to dispatch
  26307. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  26308. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  26309. */
  26310. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  26311. /**
  26312. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  26313. * This allowed control for front to back rendering or reversly depending of the special needs.
  26314. *
  26315. * @param renderingGroupId The rendering group id corresponding to its index
  26316. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  26317. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  26318. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  26319. */
  26320. 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;
  26321. /**
  26322. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  26323. *
  26324. * @param renderingGroupId The rendering group id corresponding to its index
  26325. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  26326. * @param depth Automatically clears depth between groups if true and autoClear is true.
  26327. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  26328. */
  26329. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  26330. }
  26331. }
  26332. declare module BABYLON {
  26333. class Sprite {
  26334. name: string;
  26335. position: Vector3;
  26336. color: Color4;
  26337. width: number;
  26338. height: number;
  26339. angle: number;
  26340. cellIndex: number;
  26341. invertU: number;
  26342. invertV: number;
  26343. disposeWhenFinishedAnimating: boolean;
  26344. animations: Animation[];
  26345. isPickable: boolean;
  26346. actionManager: ActionManager;
  26347. private _animationStarted;
  26348. private _loopAnimation;
  26349. private _fromIndex;
  26350. private _toIndex;
  26351. private _delay;
  26352. private _direction;
  26353. private _manager;
  26354. private _time;
  26355. private _onAnimationEnd;
  26356. size: number;
  26357. constructor(name: string, manager: SpriteManager);
  26358. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  26359. stopAnimation(): void;
  26360. _animate(deltaTime: number): void;
  26361. dispose(): void;
  26362. }
  26363. }
  26364. declare module BABYLON {
  26365. class SpriteManager {
  26366. name: string;
  26367. sprites: Sprite[];
  26368. renderingGroupId: number;
  26369. layerMask: number;
  26370. fogEnabled: boolean;
  26371. isPickable: boolean;
  26372. cellWidth: number;
  26373. cellHeight: number;
  26374. /**
  26375. * An event triggered when the manager is disposed.
  26376. */
  26377. onDisposeObservable: Observable<SpriteManager>;
  26378. private _onDisposeObserver;
  26379. onDispose: () => void;
  26380. private _capacity;
  26381. private _spriteTexture;
  26382. private _epsilon;
  26383. private _scene;
  26384. private _vertexData;
  26385. private _buffer;
  26386. private _vertexBuffers;
  26387. private _indexBuffer;
  26388. private _effectBase;
  26389. private _effectFog;
  26390. texture: Texture;
  26391. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  26392. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  26393. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  26394. render(): void;
  26395. dispose(): void;
  26396. }
  26397. }
  26398. declare module BABYLON {
  26399. /**
  26400. * @hidden
  26401. **/
  26402. class _AlphaState {
  26403. private _isAlphaBlendDirty;
  26404. private _isBlendFunctionParametersDirty;
  26405. private _isBlendEquationParametersDirty;
  26406. private _isBlendConstantsDirty;
  26407. private _alphaBlend;
  26408. private _blendFunctionParameters;
  26409. private _blendEquationParameters;
  26410. private _blendConstants;
  26411. /**
  26412. * Initializes the state.
  26413. */
  26414. constructor();
  26415. readonly isDirty: boolean;
  26416. alphaBlend: boolean;
  26417. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  26418. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  26419. setAlphaEquationParameters(rgb: number, alpha: number): void;
  26420. reset(): void;
  26421. apply(gl: WebGLRenderingContext): void;
  26422. }
  26423. }
  26424. declare module BABYLON {
  26425. /**
  26426. * @hidden
  26427. **/
  26428. class _DepthCullingState {
  26429. private _isDepthTestDirty;
  26430. private _isDepthMaskDirty;
  26431. private _isDepthFuncDirty;
  26432. private _isCullFaceDirty;
  26433. private _isCullDirty;
  26434. private _isZOffsetDirty;
  26435. private _isFrontFaceDirty;
  26436. private _depthTest;
  26437. private _depthMask;
  26438. private _depthFunc;
  26439. private _cull;
  26440. private _cullFace;
  26441. private _zOffset;
  26442. private _frontFace;
  26443. /**
  26444. * Initializes the state.
  26445. */
  26446. constructor();
  26447. readonly isDirty: boolean;
  26448. zOffset: number;
  26449. cullFace: Nullable<number>;
  26450. cull: Nullable<boolean>;
  26451. depthFunc: Nullable<number>;
  26452. depthMask: boolean;
  26453. depthTest: boolean;
  26454. frontFace: Nullable<number>;
  26455. reset(): void;
  26456. apply(gl: WebGLRenderingContext): void;
  26457. }
  26458. }
  26459. declare module BABYLON {
  26460. /**
  26461. * @hidden
  26462. **/
  26463. class _StencilState {
  26464. private _isStencilTestDirty;
  26465. private _isStencilMaskDirty;
  26466. private _isStencilFuncDirty;
  26467. private _isStencilOpDirty;
  26468. private _stencilTest;
  26469. private _stencilMask;
  26470. private _stencilFunc;
  26471. private _stencilFuncRef;
  26472. private _stencilFuncMask;
  26473. private _stencilOpStencilFail;
  26474. private _stencilOpDepthFail;
  26475. private _stencilOpStencilDepthPass;
  26476. readonly isDirty: boolean;
  26477. stencilFunc: number;
  26478. stencilFuncRef: number;
  26479. stencilFuncMask: number;
  26480. stencilOpStencilFail: number;
  26481. stencilOpDepthFail: number;
  26482. stencilOpStencilDepthPass: number;
  26483. stencilMask: number;
  26484. stencilTest: boolean;
  26485. constructor();
  26486. reset(): void;
  26487. apply(gl: WebGLRenderingContext): void;
  26488. }
  26489. }
  26490. declare module BABYLON {
  26491. /**
  26492. * Class used to evalaute queries containing `and` and `or` operators
  26493. */
  26494. class AndOrNotEvaluator {
  26495. /**
  26496. * Evaluate a query
  26497. * @param query defines the query to evaluate
  26498. * @param evaluateCallback defines the callback used to filter result
  26499. * @returns true if the query matches
  26500. */
  26501. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  26502. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  26503. private static _SimplifyNegation(booleanString);
  26504. }
  26505. }
  26506. declare module BABYLON {
  26507. /**
  26508. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  26509. */
  26510. enum AssetTaskState {
  26511. /**
  26512. * Initialization
  26513. */
  26514. INIT = 0,
  26515. /**
  26516. * Running
  26517. */
  26518. RUNNING = 1,
  26519. /**
  26520. * Done
  26521. */
  26522. DONE = 2,
  26523. /**
  26524. * Error
  26525. */
  26526. ERROR = 3,
  26527. }
  26528. /**
  26529. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  26530. */
  26531. abstract class AbstractAssetTask {
  26532. /**
  26533. * Task name
  26534. */ name: string;
  26535. /**
  26536. * Callback called when the task is successful
  26537. */
  26538. onSuccess: (task: any) => void;
  26539. /**
  26540. * Callback called when the task is not successful
  26541. */
  26542. onError: (task: any, message?: string, exception?: any) => void;
  26543. /**
  26544. * Creates a new {BABYLON.AssetsManager}
  26545. * @param name defines the name of the task
  26546. */
  26547. constructor(
  26548. /**
  26549. * Task name
  26550. */ name: string);
  26551. private _isCompleted;
  26552. private _taskState;
  26553. private _errorObject;
  26554. /**
  26555. * Get if the task is completed
  26556. */
  26557. readonly isCompleted: boolean;
  26558. /**
  26559. * Gets the current state of the task
  26560. */
  26561. readonly taskState: AssetTaskState;
  26562. /**
  26563. * Gets the current error object (if task is in error)
  26564. */
  26565. readonly errorObject: {
  26566. message?: string;
  26567. exception?: any;
  26568. };
  26569. /**
  26570. * Internal only
  26571. * @hidden
  26572. */
  26573. _setErrorObject(message?: string, exception?: any): void;
  26574. /**
  26575. * Execute the current task
  26576. * @param scene defines the scene where you want your assets to be loaded
  26577. * @param onSuccess is a callback called when the task is successfully executed
  26578. * @param onError is a callback called if an error occurs
  26579. */
  26580. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26581. /**
  26582. * Execute the current task
  26583. * @param scene defines the scene where you want your assets to be loaded
  26584. * @param onSuccess is a callback called when the task is successfully executed
  26585. * @param onError is a callback called if an error occurs
  26586. */
  26587. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26588. private onErrorCallback(onError, message?, exception?);
  26589. private onDoneCallback(onSuccess, onError);
  26590. }
  26591. /**
  26592. * Define the interface used by progress events raised during assets loading
  26593. */
  26594. interface IAssetsProgressEvent {
  26595. /**
  26596. * Defines the number of remaining tasks to process
  26597. */
  26598. remainingCount: number;
  26599. /**
  26600. * Defines the total number of tasks
  26601. */
  26602. totalCount: number;
  26603. /**
  26604. * Defines the task that was just processed
  26605. */
  26606. task: AbstractAssetTask;
  26607. }
  26608. /**
  26609. * Class used to share progress information about assets loading
  26610. */
  26611. class AssetsProgressEvent implements IAssetsProgressEvent {
  26612. /**
  26613. * Defines the number of remaining tasks to process
  26614. */
  26615. remainingCount: number;
  26616. /**
  26617. * Defines the total number of tasks
  26618. */
  26619. totalCount: number;
  26620. /**
  26621. * Defines the task that was just processed
  26622. */
  26623. task: AbstractAssetTask;
  26624. /**
  26625. * Creates a {BABYLON.AssetsProgressEvent}
  26626. * @param remainingCount defines the number of remaining tasks to process
  26627. * @param totalCount defines the total number of tasks
  26628. * @param task defines the task that was just processed
  26629. */
  26630. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  26631. }
  26632. /**
  26633. * Define a task used by {BABYLON.AssetsManager} to load meshes
  26634. */
  26635. class MeshAssetTask extends AbstractAssetTask {
  26636. /**
  26637. * Defines the name of the task
  26638. */
  26639. name: string;
  26640. /**
  26641. * Defines the list of mesh's names you want to load
  26642. */
  26643. meshesNames: any;
  26644. /**
  26645. * Defines the root url to use as a base to load your meshes and associated resources
  26646. */
  26647. rootUrl: string;
  26648. /**
  26649. * Defines the filename of the scene to load from
  26650. */
  26651. sceneFilename: string;
  26652. /**
  26653. * Gets the list of loaded meshes
  26654. */
  26655. loadedMeshes: Array<AbstractMesh>;
  26656. /**
  26657. * Gets the list of loaded particle systems
  26658. */
  26659. loadedParticleSystems: Array<ParticleSystem>;
  26660. /**
  26661. * Gets the list of loaded skeletons
  26662. */
  26663. loadedSkeletons: Array<Skeleton>;
  26664. /**
  26665. * Callback called when the task is successful
  26666. */
  26667. onSuccess: (task: MeshAssetTask) => void;
  26668. /**
  26669. * Callback called when the task is successful
  26670. */
  26671. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  26672. /**
  26673. * Creates a new {BABYLON.MeshAssetTask}
  26674. * @param name defines the name of the task
  26675. * @param meshesNames defines the list of mesh's names you want to load
  26676. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  26677. * @param sceneFilename defines the filename of the scene to load from
  26678. */
  26679. constructor(
  26680. /**
  26681. * Defines the name of the task
  26682. */
  26683. name: string,
  26684. /**
  26685. * Defines the list of mesh's names you want to load
  26686. */
  26687. meshesNames: any,
  26688. /**
  26689. * Defines the root url to use as a base to load your meshes and associated resources
  26690. */
  26691. rootUrl: string,
  26692. /**
  26693. * Defines the filename of the scene to load from
  26694. */
  26695. sceneFilename: string);
  26696. /**
  26697. * Execute the current task
  26698. * @param scene defines the scene where you want your assets to be loaded
  26699. * @param onSuccess is a callback called when the task is successfully executed
  26700. * @param onError is a callback called if an error occurs
  26701. */
  26702. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26703. }
  26704. /**
  26705. * Define a task used by {BABYLON.AssetsManager} to load text content
  26706. */
  26707. class TextFileAssetTask extends AbstractAssetTask {
  26708. /**
  26709. * Defines the name of the task
  26710. */
  26711. name: string;
  26712. /**
  26713. * Defines the location of the file to load
  26714. */
  26715. url: string;
  26716. /**
  26717. * Gets the loaded text string
  26718. */
  26719. text: string;
  26720. /**
  26721. * Callback called when the task is successful
  26722. */
  26723. onSuccess: (task: TextFileAssetTask) => void;
  26724. /**
  26725. * Callback called when the task is successful
  26726. */
  26727. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  26728. /**
  26729. * Creates a new TextFileAssetTask object
  26730. * @param name defines the name of the task
  26731. * @param url defines the location of the file to load
  26732. */
  26733. constructor(
  26734. /**
  26735. * Defines the name of the task
  26736. */
  26737. name: string,
  26738. /**
  26739. * Defines the location of the file to load
  26740. */
  26741. url: string);
  26742. /**
  26743. * Execute the current task
  26744. * @param scene defines the scene where you want your assets to be loaded
  26745. * @param onSuccess is a callback called when the task is successfully executed
  26746. * @param onError is a callback called if an error occurs
  26747. */
  26748. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26749. }
  26750. /**
  26751. * Define a task used by {BABYLON.AssetsManager} to load binary data
  26752. */
  26753. class BinaryFileAssetTask extends AbstractAssetTask {
  26754. /**
  26755. * Defines the name of the task
  26756. */
  26757. name: string;
  26758. /**
  26759. * Defines the location of the file to load
  26760. */
  26761. url: string;
  26762. /**
  26763. * Gets the lodaded data (as an array buffer)
  26764. */
  26765. data: ArrayBuffer;
  26766. /**
  26767. * Callback called when the task is successful
  26768. */
  26769. onSuccess: (task: BinaryFileAssetTask) => void;
  26770. /**
  26771. * Callback called when the task is successful
  26772. */
  26773. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  26774. /**
  26775. * Creates a new BinaryFileAssetTask object
  26776. * @param name defines the name of the new task
  26777. * @param url defines the location of the file to load
  26778. */
  26779. constructor(
  26780. /**
  26781. * Defines the name of the task
  26782. */
  26783. name: string,
  26784. /**
  26785. * Defines the location of the file to load
  26786. */
  26787. url: string);
  26788. /**
  26789. * Execute the current task
  26790. * @param scene defines the scene where you want your assets to be loaded
  26791. * @param onSuccess is a callback called when the task is successfully executed
  26792. * @param onError is a callback called if an error occurs
  26793. */
  26794. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26795. }
  26796. /**
  26797. * Define a task used by {BABYLON.AssetsManager} to load images
  26798. */
  26799. class ImageAssetTask extends AbstractAssetTask {
  26800. /**
  26801. * Defines the name of the task
  26802. */
  26803. name: string;
  26804. /**
  26805. * Defines the location of the image to load
  26806. */
  26807. url: string;
  26808. /**
  26809. * Gets the loaded images
  26810. */
  26811. image: HTMLImageElement;
  26812. /**
  26813. * Callback called when the task is successful
  26814. */
  26815. onSuccess: (task: ImageAssetTask) => void;
  26816. /**
  26817. * Callback called when the task is successful
  26818. */
  26819. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  26820. /**
  26821. * Creates a new ImageAssetTask
  26822. * @param name defines the name of the task
  26823. * @param url defines the location of the image to load
  26824. */
  26825. constructor(
  26826. /**
  26827. * Defines the name of the task
  26828. */
  26829. name: string,
  26830. /**
  26831. * Defines the location of the image to load
  26832. */
  26833. url: string);
  26834. /**
  26835. * Execute the current task
  26836. * @param scene defines the scene where you want your assets to be loaded
  26837. * @param onSuccess is a callback called when the task is successfully executed
  26838. * @param onError is a callback called if an error occurs
  26839. */
  26840. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26841. }
  26842. /**
  26843. * Defines the interface used by texture loading tasks
  26844. */
  26845. interface ITextureAssetTask<TEX extends BaseTexture> {
  26846. /**
  26847. * Gets the loaded texture
  26848. */
  26849. texture: TEX;
  26850. }
  26851. /**
  26852. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  26853. */
  26854. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  26855. /**
  26856. * Defines the name of the task
  26857. */
  26858. name: string;
  26859. /**
  26860. * Defines the location of the file to load
  26861. */
  26862. url: string;
  26863. /**
  26864. * Defines if mipmap should not be generated (default is false)
  26865. */
  26866. noMipmap: boolean | undefined;
  26867. /**
  26868. * Defines if texture must be inverted on Y axis (default is false)
  26869. */
  26870. invertY: boolean | undefined;
  26871. /**
  26872. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  26873. */
  26874. samplingMode: number;
  26875. /**
  26876. * Gets the loaded texture
  26877. */
  26878. texture: Texture;
  26879. /**
  26880. * Callback called when the task is successful
  26881. */
  26882. onSuccess: (task: TextureAssetTask) => void;
  26883. /**
  26884. * Callback called when the task is successful
  26885. */
  26886. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  26887. /**
  26888. * Creates a new TextureAssetTask object
  26889. * @param name defines the name of the task
  26890. * @param url defines the location of the file to load
  26891. * @param noMipmap defines if mipmap should not be generated (default is false)
  26892. * @param invertY defines if texture must be inverted on Y axis (default is false)
  26893. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  26894. */
  26895. constructor(
  26896. /**
  26897. * Defines the name of the task
  26898. */
  26899. name: string,
  26900. /**
  26901. * Defines the location of the file to load
  26902. */
  26903. url: string,
  26904. /**
  26905. * Defines if mipmap should not be generated (default is false)
  26906. */
  26907. noMipmap?: boolean | undefined,
  26908. /**
  26909. * Defines if texture must be inverted on Y axis (default is false)
  26910. */
  26911. invertY?: boolean | undefined,
  26912. /**
  26913. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  26914. */
  26915. samplingMode?: number);
  26916. /**
  26917. * Execute the current task
  26918. * @param scene defines the scene where you want your assets to be loaded
  26919. * @param onSuccess is a callback called when the task is successfully executed
  26920. * @param onError is a callback called if an error occurs
  26921. */
  26922. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26923. }
  26924. /**
  26925. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  26926. */
  26927. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  26928. /**
  26929. * Defines the name of the task
  26930. */
  26931. name: string;
  26932. /**
  26933. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  26934. */
  26935. url: string;
  26936. /**
  26937. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  26938. */
  26939. extensions: string[] | undefined;
  26940. /**
  26941. * Defines if mipmaps should not be generated (default is false)
  26942. */
  26943. noMipmap: boolean | undefined;
  26944. /**
  26945. * Defines the explicit list of files (undefined by default)
  26946. */
  26947. files: string[] | undefined;
  26948. /**
  26949. * Gets the loaded texture
  26950. */
  26951. texture: CubeTexture;
  26952. /**
  26953. * Callback called when the task is successful
  26954. */
  26955. onSuccess: (task: CubeTextureAssetTask) => void;
  26956. /**
  26957. * Callback called when the task is successful
  26958. */
  26959. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  26960. /**
  26961. * Creates a new CubeTextureAssetTask
  26962. * @param name defines the name of the task
  26963. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  26964. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  26965. * @param noMipmap defines if mipmaps should not be generated (default is false)
  26966. * @param files defines the explicit list of files (undefined by default)
  26967. */
  26968. constructor(
  26969. /**
  26970. * Defines the name of the task
  26971. */
  26972. name: string,
  26973. /**
  26974. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  26975. */
  26976. url: string,
  26977. /**
  26978. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  26979. */
  26980. extensions?: string[] | undefined,
  26981. /**
  26982. * Defines if mipmaps should not be generated (default is false)
  26983. */
  26984. noMipmap?: boolean | undefined,
  26985. /**
  26986. * Defines the explicit list of files (undefined by default)
  26987. */
  26988. files?: string[] | undefined);
  26989. /**
  26990. * Execute the current task
  26991. * @param scene defines the scene where you want your assets to be loaded
  26992. * @param onSuccess is a callback called when the task is successfully executed
  26993. * @param onError is a callback called if an error occurs
  26994. */
  26995. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26996. }
  26997. /**
  26998. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  26999. */
  27000. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  27001. /**
  27002. * Defines the name of the task
  27003. */
  27004. name: string;
  27005. /**
  27006. * Defines the location of the file to load
  27007. */
  27008. url: string;
  27009. /**
  27010. * Defines the desired size (the more it increases the longer the generation will be)
  27011. */
  27012. size: number;
  27013. /**
  27014. * Defines if mipmaps should not be generated (default is false)
  27015. */
  27016. noMipmap: boolean;
  27017. /**
  27018. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27019. */
  27020. generateHarmonics: boolean;
  27021. /**
  27022. * 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)
  27023. */
  27024. gammaSpace: boolean;
  27025. /**
  27026. * Internal Use Only
  27027. */
  27028. reserved: boolean;
  27029. /**
  27030. * Gets the loaded texture
  27031. */
  27032. texture: HDRCubeTexture;
  27033. /**
  27034. * Callback called when the task is successful
  27035. */
  27036. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  27037. /**
  27038. * Callback called when the task is successful
  27039. */
  27040. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  27041. /**
  27042. * Creates a new HDRCubeTextureAssetTask object
  27043. * @param name defines the name of the task
  27044. * @param url defines the location of the file to load
  27045. * @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.
  27046. * @param noMipmap defines if mipmaps should not be generated (default is false)
  27047. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27048. * @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)
  27049. * @param reserved Internal use only
  27050. */
  27051. constructor(
  27052. /**
  27053. * Defines the name of the task
  27054. */
  27055. name: string,
  27056. /**
  27057. * Defines the location of the file to load
  27058. */
  27059. url: string,
  27060. /**
  27061. * Defines the desired size (the more it increases the longer the generation will be)
  27062. */
  27063. size: number,
  27064. /**
  27065. * Defines if mipmaps should not be generated (default is false)
  27066. */
  27067. noMipmap?: boolean,
  27068. /**
  27069. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27070. */
  27071. generateHarmonics?: boolean,
  27072. /**
  27073. * 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)
  27074. */
  27075. gammaSpace?: boolean,
  27076. /**
  27077. * Internal Use Only
  27078. */
  27079. reserved?: boolean);
  27080. /**
  27081. * Execute the current task
  27082. * @param scene defines the scene where you want your assets to be loaded
  27083. * @param onSuccess is a callback called when the task is successfully executed
  27084. * @param onError is a callback called if an error occurs
  27085. */
  27086. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27087. }
  27088. /**
  27089. * This class can be used to easily import assets into a scene
  27090. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  27091. */
  27092. class AssetsManager {
  27093. private _scene;
  27094. private _isLoading;
  27095. protected _tasks: AbstractAssetTask[];
  27096. protected _waitingTasksCount: number;
  27097. protected _totalTasksCount: number;
  27098. /**
  27099. * Callback called when all tasks are processed
  27100. */
  27101. onFinish: (tasks: AbstractAssetTask[]) => void;
  27102. /**
  27103. * Callback called when a task is successful
  27104. */
  27105. onTaskSuccess: (task: AbstractAssetTask) => void;
  27106. /**
  27107. * Callback called when a task had an error
  27108. */
  27109. onTaskError: (task: AbstractAssetTask) => void;
  27110. /**
  27111. * Callback called when a task is done (whatever the result is)
  27112. */
  27113. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  27114. /**
  27115. * Observable called when all tasks are processed
  27116. */
  27117. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  27118. /**
  27119. * Observable called when a task had an error
  27120. */
  27121. onTaskErrorObservable: Observable<AbstractAssetTask>;
  27122. /**
  27123. * Observable called when a task is successful
  27124. */
  27125. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  27126. /**
  27127. * Observable called when a task is done (whatever the result is)
  27128. */
  27129. onProgressObservable: Observable<IAssetsProgressEvent>;
  27130. /**
  27131. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  27132. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27133. */
  27134. useDefaultLoadingScreen: boolean;
  27135. /**
  27136. * Creates a new AssetsManager
  27137. * @param scene defines the scene to work on
  27138. */
  27139. constructor(scene: Scene);
  27140. /**
  27141. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  27142. * @param taskName defines the name of the new task
  27143. * @param meshesNames defines the name of meshes to load
  27144. * @param rootUrl defines the root url to use to locate files
  27145. * @param sceneFilename defines the filename of the scene file
  27146. * @returns a new {BABYLON.MeshAssetTask} object
  27147. */
  27148. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  27149. /**
  27150. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  27151. * @param taskName defines the name of the new task
  27152. * @param url defines the url of the file to load
  27153. * @returns a new {BABYLON.TextFileAssetTask} object
  27154. */
  27155. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  27156. /**
  27157. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  27158. * @param taskName defines the name of the new task
  27159. * @param url defines the url of the file to load
  27160. * @returns a new {BABYLON.BinaryFileAssetTask} object
  27161. */
  27162. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  27163. /**
  27164. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  27165. * @param taskName defines the name of the new task
  27166. * @param url defines the url of the file to load
  27167. * @returns a new {BABYLON.ImageAssetTask} object
  27168. */
  27169. addImageTask(taskName: string, url: string): ImageAssetTask;
  27170. /**
  27171. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  27172. * @param taskName defines the name of the new task
  27173. * @param url defines the url of the file to load
  27174. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27175. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  27176. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  27177. * @returns a new {BABYLON.TextureAssetTask} object
  27178. */
  27179. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  27180. /**
  27181. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  27182. * @param taskName defines the name of the new task
  27183. * @param url defines the url of the file to load
  27184. * @param extensions defines the extension to use to load the cube map (can be null)
  27185. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27186. * @param files defines the list of files to load (can be null)
  27187. * @returns a new {BABYLON.CubeTextureAssetTask} object
  27188. */
  27189. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  27190. /**
  27191. *
  27192. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  27193. * @param taskName defines the name of the new task
  27194. * @param url defines the url of the file to load
  27195. * @param size defines the size you want for the cubemap (can be null)
  27196. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27197. * @param generateHarmonics defines if you want to automatically generate (true by default)
  27198. * @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)
  27199. * @param reserved Internal use only
  27200. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  27201. */
  27202. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  27203. private _decreaseWaitingTasksCount(task);
  27204. private _runTask(task);
  27205. /**
  27206. * Reset the {BABYLON.AssetsManager} and remove all tasks
  27207. * @return the current instance of the {BABYLON.AssetsManager}
  27208. */
  27209. reset(): AssetsManager;
  27210. /**
  27211. * Start the loading process
  27212. * @return the current instance of the {BABYLON.AssetsManager}
  27213. */
  27214. load(): AssetsManager;
  27215. }
  27216. }
  27217. declare module BABYLON {
  27218. /**
  27219. * Class used to enable access to IndexedDB
  27220. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  27221. */
  27222. class Database {
  27223. private callbackManifestChecked;
  27224. private currentSceneUrl;
  27225. private db;
  27226. private _enableSceneOffline;
  27227. private _enableTexturesOffline;
  27228. private manifestVersionFound;
  27229. private mustUpdateRessources;
  27230. private hasReachedQuota;
  27231. private isSupported;
  27232. private idbFactory;
  27233. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  27234. static IsUASupportingBlobStorage: boolean;
  27235. /** Gets a boolean indicating if Database storate is enabled */
  27236. static IDBStorageEnabled: boolean;
  27237. /**
  27238. * Gets a boolean indicating if scene must be saved in the database
  27239. */
  27240. readonly enableSceneOffline: boolean;
  27241. /**
  27242. * Gets a boolean indicating if textures must be saved in the database
  27243. */
  27244. readonly enableTexturesOffline: boolean;
  27245. /**
  27246. * Creates a new Database
  27247. * @param urlToScene defines the url to load the scene
  27248. * @param callbackManifestChecked defines the callback to use when manifest is checked
  27249. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  27250. */
  27251. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  27252. private static _ParseURL;
  27253. private static _ReturnFullUrlLocation;
  27254. private _checkManifestFile();
  27255. /**
  27256. * Open the database and make it available
  27257. * @param successCallback defines the callback to call on success
  27258. * @param errorCallback defines the callback to call on error
  27259. */
  27260. openAsync(successCallback: () => void, errorCallback: () => void): void;
  27261. /**
  27262. * Loads an image from the database
  27263. * @param url defines the url to load from
  27264. * @param image defines the target DOM image
  27265. */
  27266. loadImageFromDB(url: string, image: HTMLImageElement): void;
  27267. private _loadImageFromDBAsync(url, image, notInDBCallback);
  27268. private _saveImageIntoDBAsync(url, image);
  27269. private _checkVersionFromDB(url, versionLoaded);
  27270. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  27271. private _saveVersionIntoDBAsync(url, callback);
  27272. /**
  27273. * Loads a file from database
  27274. * @param url defines the URL to load from
  27275. * @param sceneLoaded defines a callback to call on success
  27276. * @param progressCallBack defines a callback to call when progress changed
  27277. * @param errorCallback defines a callback to call on error
  27278. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  27279. */
  27280. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  27281. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  27282. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  27283. }
  27284. }
  27285. declare module BABYLON {
  27286. interface DDSInfo {
  27287. width: number;
  27288. height: number;
  27289. mipmapCount: number;
  27290. isFourCC: boolean;
  27291. isRGB: boolean;
  27292. isLuminance: boolean;
  27293. isCube: boolean;
  27294. isCompressed: boolean;
  27295. dxgiFormat: number;
  27296. textureType: number;
  27297. /** Sphericle polynomial created for the dds texture */
  27298. sphericalPolynomial?: SphericalPolynomial;
  27299. }
  27300. class DDSTools {
  27301. static StoreLODInAlphaChannel: boolean;
  27302. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  27303. private static _FloatView;
  27304. private static _Int32View;
  27305. private static _ToHalfFloat(value);
  27306. private static _FromHalfFloat(value);
  27307. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27308. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27309. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27310. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27311. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27312. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  27313. private static _ExtractLongWordOrder(value);
  27314. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  27315. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  27316. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  27317. }
  27318. }
  27319. declare module BABYLON {
  27320. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27321. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27322. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27323. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27324. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27325. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27326. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27327. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27328. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27329. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27330. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27331. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27332. /**
  27333. * Decorator used to define property that can be serialized as reference to a camera
  27334. * @param sourceName defines the name of the property to decorate
  27335. */
  27336. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27337. class SerializationHelper {
  27338. static Serialize<T>(entity: T, serializationObject?: any): any;
  27339. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27340. static Clone<T>(creationFunction: () => T, source: T): T;
  27341. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27342. }
  27343. }
  27344. declare module BABYLON {
  27345. /**
  27346. * Wrapper class for promise with external resolve and reject.
  27347. */
  27348. class Deferred<T> {
  27349. /**
  27350. * The promise associated with this deferred object.
  27351. */
  27352. readonly promise: Promise<T>;
  27353. private _resolve;
  27354. private _reject;
  27355. /**
  27356. * The resolve method of the promise associated with this deferred object.
  27357. */
  27358. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  27359. /**
  27360. * The reject method of the promise associated with this deferred object.
  27361. */
  27362. readonly reject: (reason?: any) => void;
  27363. /**
  27364. * Constructor for this deferred object.
  27365. */
  27366. constructor();
  27367. }
  27368. }
  27369. declare module BABYLON {
  27370. class FilesInput {
  27371. static FilesToLoad: {
  27372. [key: string]: File;
  27373. };
  27374. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  27375. private _engine;
  27376. private _currentScene;
  27377. private _sceneLoadedCallback;
  27378. private _progressCallback;
  27379. private _additionalRenderLoopLogicCallback;
  27380. private _textureLoadingCallback;
  27381. private _startingProcessingFilesCallback;
  27382. private _onReloadCallback;
  27383. private _errorCallback;
  27384. private _elementToMonitor;
  27385. private _sceneFileToLoad;
  27386. private _filesToLoad;
  27387. 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);
  27388. private _dragEnterHandler;
  27389. private _dragOverHandler;
  27390. private _dropHandler;
  27391. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  27392. dispose(): void;
  27393. private renderFunction();
  27394. private drag(e);
  27395. private drop(eventDrop);
  27396. private _traverseFolder(folder, files, remaining, callback);
  27397. private _processFiles(files);
  27398. loadFiles(event: any): void;
  27399. private _processReload();
  27400. reload(): void;
  27401. }
  27402. }
  27403. declare module BABYLON {
  27404. /**
  27405. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  27406. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  27407. */
  27408. class KhronosTextureContainer {
  27409. arrayBuffer: any;
  27410. static HEADER_LEN: number;
  27411. static COMPRESSED_2D: number;
  27412. static COMPRESSED_3D: number;
  27413. static TEX_2D: number;
  27414. static TEX_3D: number;
  27415. glType: number;
  27416. glTypeSize: number;
  27417. glFormat: number;
  27418. glInternalFormat: number;
  27419. glBaseInternalFormat: number;
  27420. pixelWidth: number;
  27421. pixelHeight: number;
  27422. pixelDepth: number;
  27423. numberOfArrayElements: number;
  27424. numberOfFaces: number;
  27425. numberOfMipmapLevels: number;
  27426. bytesOfKeyValueData: number;
  27427. loadType: number;
  27428. /**
  27429. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  27430. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  27431. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  27432. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  27433. */
  27434. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  27435. switchEndainness(val: number): number;
  27436. /**
  27437. * It is assumed that the texture has already been created & is currently bound
  27438. */
  27439. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  27440. private _upload2DCompressedLevels(gl, loadMipmaps);
  27441. }
  27442. }
  27443. declare module BABYLON {
  27444. /**
  27445. * A class serves as a medium between the observable and its observers
  27446. */
  27447. class EventState {
  27448. /**
  27449. * Create a new EventState
  27450. * @param mask defines the mask associated with this state
  27451. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  27452. * @param target defines the original target of the state
  27453. * @param currentTarget defines the current target of the state
  27454. */
  27455. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  27456. /**
  27457. * Initialize the current event state
  27458. * @param mask defines the mask associated with this state
  27459. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  27460. * @param target defines the original target of the state
  27461. * @param currentTarget defines the current target of the state
  27462. * @returns the current event state
  27463. */
  27464. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  27465. /**
  27466. * An Observer can set this property to true to prevent subsequent observers of being notified
  27467. */
  27468. skipNextObservers: boolean;
  27469. /**
  27470. * Get the mask value that were used to trigger the event corresponding to this EventState object
  27471. */
  27472. mask: number;
  27473. /**
  27474. * The object that originally notified the event
  27475. */
  27476. target?: any;
  27477. /**
  27478. * The current object in the bubbling phase
  27479. */
  27480. currentTarget?: any;
  27481. /**
  27482. * This will be populated with the return value of the last function that was executed.
  27483. * If it is the first function in the callback chain it will be the event data.
  27484. */
  27485. lastReturnValue?: any;
  27486. }
  27487. /**
  27488. * Represent an Observer registered to a given Observable object.
  27489. */
  27490. class Observer<T> {
  27491. /**
  27492. * Defines the callback to call when the observer is notified
  27493. */
  27494. callback: (eventData: T, eventState: EventState) => void;
  27495. /**
  27496. * Defines the mask of the observer (used to filter notifications)
  27497. */
  27498. mask: number;
  27499. /**
  27500. * Defines the current scope used to restore the JS context
  27501. */
  27502. scope: any;
  27503. /** @hidden */
  27504. _willBeUnregistered: boolean;
  27505. /**
  27506. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  27507. */
  27508. unregisterOnNextCall: boolean;
  27509. /**
  27510. * Creates a new observer
  27511. * @param callback defines the callback to call when the observer is notified
  27512. * @param mask defines the mask of the observer (used to filter notifications)
  27513. * @param scope defines the current scope used to restore the JS context
  27514. */
  27515. constructor(
  27516. /**
  27517. * Defines the callback to call when the observer is notified
  27518. */
  27519. callback: (eventData: T, eventState: EventState) => void,
  27520. /**
  27521. * Defines the mask of the observer (used to filter notifications)
  27522. */
  27523. mask: number,
  27524. /**
  27525. * Defines the current scope used to restore the JS context
  27526. */
  27527. scope?: any);
  27528. }
  27529. /**
  27530. * Represent a list of observers registered to multiple Observables object.
  27531. */
  27532. class MultiObserver<T> {
  27533. private _observers;
  27534. private _observables;
  27535. /**
  27536. * Release associated resources
  27537. */
  27538. dispose(): void;
  27539. /**
  27540. * Raise a callback when one of the observable will notify
  27541. * @param observables defines a list of observables to watch
  27542. * @param callback defines the callback to call on notification
  27543. * @param mask defines the mask used to filter notifications
  27544. * @param scope defines the current scope used to restore the JS context
  27545. * @returns the new MultiObserver
  27546. */
  27547. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  27548. }
  27549. /**
  27550. * The Observable class is a simple implementation of the Observable pattern.
  27551. *
  27552. * 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.
  27553. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  27554. * 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).
  27555. * 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.
  27556. */
  27557. class Observable<T> {
  27558. private _observers;
  27559. private _eventState;
  27560. private _onObserverAdded;
  27561. /**
  27562. * Creates a new observable
  27563. * @param onObserverAdded defines a callback to call when a new observer is added
  27564. */
  27565. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  27566. /**
  27567. * Create a new Observer with the specified callback
  27568. * @param callback the callback that will be executed for that Observer
  27569. * @param mask the mask used to filter observers
  27570. * @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.
  27571. * @param scope optional scope for the callback to be called from
  27572. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  27573. * @returns the new observer created for the callback
  27574. */
  27575. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  27576. /**
  27577. * Remove an Observer from the Observable object
  27578. * @param observer the instance of the Observer to remove
  27579. * @returns false if it doesn't belong to this Observable
  27580. */
  27581. remove(observer: Nullable<Observer<T>>): boolean;
  27582. /**
  27583. * Remove a callback from the Observable object
  27584. * @param callback the callback to remove
  27585. * @param scope optional scope. If used only the callbacks with this scope will be removed
  27586. * @returns false if it doesn't belong to this Observable
  27587. */
  27588. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  27589. private _deferUnregister(observer);
  27590. /**
  27591. * Notify all Observers by calling their respective callback with the given data
  27592. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  27593. * @param eventData defines the data to send to all observers
  27594. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  27595. * @param target defines the original target of the state
  27596. * @param currentTarget defines the current target of the state
  27597. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  27598. */
  27599. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  27600. /**
  27601. * Calling this will execute each callback, expecting it to be a promise or return a value.
  27602. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  27603. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  27604. * and it is crucial that all callbacks will be executed.
  27605. * The order of the callbacks is kept, callbacks are not executed parallel.
  27606. *
  27607. * @param eventData The data to be sent to each callback
  27608. * @param mask is used to filter observers defaults to -1
  27609. * @param target defines the callback target (see EventState)
  27610. * @param currentTarget defines he current object in the bubbling phase
  27611. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  27612. */
  27613. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  27614. /**
  27615. * Notify a specific observer
  27616. * @param observer defines the observer to notify
  27617. * @param eventData defines the data to be sent to each callback
  27618. * @param mask is used to filter observers defaults to -1
  27619. */
  27620. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  27621. /**
  27622. * Gets a boolean indicating if the observable has at least one observer
  27623. * @returns true is the Observable has at least one Observer registered
  27624. */
  27625. hasObservers(): boolean;
  27626. /**
  27627. * Clear the list of observers
  27628. */
  27629. clear(): void;
  27630. /**
  27631. * Clone the current observable
  27632. * @returns a new observable
  27633. */
  27634. clone(): Observable<T>;
  27635. /**
  27636. * Does this observable handles observer registered with a given mask
  27637. * @param mask defines the mask to be tested
  27638. * @return whether or not one observer registered with the given mask is handeled
  27639. **/
  27640. hasSpecificMask(mask?: number): boolean;
  27641. }
  27642. }
  27643. declare module BABYLON {
  27644. /**
  27645. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  27646. */
  27647. class PerformanceMonitor {
  27648. private _enabled;
  27649. private _rollingFrameTime;
  27650. private _lastFrameTimeMs;
  27651. /**
  27652. * constructor
  27653. * @param frameSampleSize The number of samples required to saturate the sliding window
  27654. */
  27655. constructor(frameSampleSize?: number);
  27656. /**
  27657. * Samples current frame
  27658. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  27659. */
  27660. sampleFrame(timeMs?: number): void;
  27661. /**
  27662. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  27663. * @return Average frame time in milliseconds
  27664. */
  27665. readonly averageFrameTime: number;
  27666. /**
  27667. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  27668. * @return Frame time variance in milliseconds squared
  27669. */
  27670. readonly averageFrameTimeVariance: number;
  27671. /**
  27672. * Returns the frame time of the most recent frame
  27673. * @return Frame time in milliseconds
  27674. */
  27675. readonly instantaneousFrameTime: number;
  27676. /**
  27677. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  27678. * @return Framerate in frames per second
  27679. */
  27680. readonly averageFPS: number;
  27681. /**
  27682. * Returns the average framerate in frames per second using the most recent frame time
  27683. * @return Framerate in frames per second
  27684. */
  27685. readonly instantaneousFPS: number;
  27686. /**
  27687. * Returns true if enough samples have been taken to completely fill the sliding window
  27688. * @return true if saturated
  27689. */
  27690. readonly isSaturated: boolean;
  27691. /**
  27692. * Enables contributions to the sliding window sample set
  27693. */
  27694. enable(): void;
  27695. /**
  27696. * Disables contributions to the sliding window sample set
  27697. * Samples will not be interpolated over the disabled period
  27698. */
  27699. disable(): void;
  27700. /**
  27701. * Returns true if sampling is enabled
  27702. * @return true if enabled
  27703. */
  27704. readonly isEnabled: boolean;
  27705. /**
  27706. * Resets performance monitor
  27707. */
  27708. reset(): void;
  27709. }
  27710. /**
  27711. * RollingAverage
  27712. *
  27713. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  27714. */
  27715. class RollingAverage {
  27716. /**
  27717. * Current average
  27718. */
  27719. average: number;
  27720. /**
  27721. * Current variance
  27722. */
  27723. variance: number;
  27724. protected _samples: Array<number>;
  27725. protected _sampleCount: number;
  27726. protected _pos: number;
  27727. protected _m2: number;
  27728. /**
  27729. * constructor
  27730. * @param length The number of samples required to saturate the sliding window
  27731. */
  27732. constructor(length: number);
  27733. /**
  27734. * Adds a sample to the sample set
  27735. * @param v The sample value
  27736. */
  27737. add(v: number): void;
  27738. /**
  27739. * Returns previously added values or null if outside of history or outside the sliding window domain
  27740. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  27741. * @return Value previously recorded with add() or null if outside of range
  27742. */
  27743. history(i: number): number;
  27744. /**
  27745. * Returns true if enough samples have been taken to completely fill the sliding window
  27746. * @return true if sample-set saturated
  27747. */
  27748. isSaturated(): boolean;
  27749. /**
  27750. * Resets the rolling average (equivalent to 0 samples taken so far)
  27751. */
  27752. reset(): void;
  27753. /**
  27754. * Wraps a value around the sample range boundaries
  27755. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  27756. * @return Wrapped position in sample range
  27757. */
  27758. protected _wrapPosition(i: number): number;
  27759. }
  27760. }
  27761. declare module BABYLON {
  27762. /**
  27763. * Helper class that provides a small promise polyfill
  27764. */
  27765. class PromisePolyfill {
  27766. /**
  27767. * Static function used to check if the polyfill is required
  27768. * If this is the case then the function will inject the polyfill to window.Promise
  27769. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  27770. */
  27771. static Apply(force?: boolean): void;
  27772. }
  27773. }
  27774. declare module BABYLON {
  27775. /**
  27776. * Defines the root class used to create scene optimization to use with SceneOptimizer
  27777. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27778. */
  27779. class SceneOptimization {
  27780. /**
  27781. * Defines the priority of this optimization (0 by default which means first in the list)
  27782. */
  27783. priority: number;
  27784. /**
  27785. * Gets a string describing the action executed by the current optimization
  27786. * @returns description string
  27787. */
  27788. getDescription(): string;
  27789. /**
  27790. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27791. * @param scene defines the current scene where to apply this optimization
  27792. * @param optimizer defines the current optimizer
  27793. * @returns true if everything that can be done was applied
  27794. */
  27795. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27796. /**
  27797. * Creates the SceneOptimization object
  27798. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  27799. * @param desc defines the description associated with the optimization
  27800. */
  27801. constructor(
  27802. /**
  27803. * Defines the priority of this optimization (0 by default which means first in the list)
  27804. */
  27805. priority?: number);
  27806. }
  27807. /**
  27808. * Defines an optimization used to reduce the size of render target textures
  27809. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27810. */
  27811. class TextureOptimization extends SceneOptimization {
  27812. /**
  27813. * Defines the priority of this optimization (0 by default which means first in the list)
  27814. */
  27815. priority: number;
  27816. /**
  27817. * 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
  27818. */
  27819. maximumSize: number;
  27820. /**
  27821. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  27822. */
  27823. step: number;
  27824. /**
  27825. * Gets a string describing the action executed by the current optimization
  27826. * @returns description string
  27827. */
  27828. getDescription(): string;
  27829. /**
  27830. * Creates the TextureOptimization object
  27831. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  27832. * @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
  27833. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  27834. */
  27835. constructor(
  27836. /**
  27837. * Defines the priority of this optimization (0 by default which means first in the list)
  27838. */
  27839. priority?: number,
  27840. /**
  27841. * 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
  27842. */
  27843. maximumSize?: number,
  27844. /**
  27845. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  27846. */
  27847. step?: number);
  27848. /**
  27849. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27850. * @param scene defines the current scene where to apply this optimization
  27851. * @param optimizer defines the current optimizer
  27852. * @returns true if everything that can be done was applied
  27853. */
  27854. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27855. }
  27856. /**
  27857. * Defines an optimization used to increase or decrease the rendering resolution
  27858. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27859. */
  27860. class HardwareScalingOptimization extends SceneOptimization {
  27861. /**
  27862. * Defines the priority of this optimization (0 by default which means first in the list)
  27863. */
  27864. priority: number;
  27865. /**
  27866. * Defines the maximum scale to use (2 by default)
  27867. */
  27868. maximumScale: number;
  27869. /**
  27870. * Defines the step to use between two passes (0.5 by default)
  27871. */
  27872. step: number;
  27873. private _currentScale;
  27874. private _directionOffset;
  27875. /**
  27876. * Gets a string describing the action executed by the current optimization
  27877. * @return description string
  27878. */
  27879. getDescription(): string;
  27880. /**
  27881. * Creates the HardwareScalingOptimization object
  27882. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  27883. * @param maximumScale defines the maximum scale to use (2 by default)
  27884. * @param step defines the step to use between two passes (0.5 by default)
  27885. */
  27886. constructor(
  27887. /**
  27888. * Defines the priority of this optimization (0 by default which means first in the list)
  27889. */
  27890. priority?: number,
  27891. /**
  27892. * Defines the maximum scale to use (2 by default)
  27893. */
  27894. maximumScale?: number,
  27895. /**
  27896. * Defines the step to use between two passes (0.5 by default)
  27897. */
  27898. step?: number);
  27899. /**
  27900. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27901. * @param scene defines the current scene where to apply this optimization
  27902. * @param optimizer defines the current optimizer
  27903. * @returns true if everything that can be done was applied
  27904. */
  27905. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27906. }
  27907. /**
  27908. * Defines an optimization used to remove shadows
  27909. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27910. */
  27911. class ShadowsOptimization extends SceneOptimization {
  27912. /**
  27913. * Gets a string describing the action executed by the current optimization
  27914. * @return description string
  27915. */
  27916. getDescription(): string;
  27917. /**
  27918. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27919. * @param scene defines the current scene where to apply this optimization
  27920. * @param optimizer defines the current optimizer
  27921. * @returns true if everything that can be done was applied
  27922. */
  27923. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27924. }
  27925. /**
  27926. * Defines an optimization used to turn post-processes off
  27927. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27928. */
  27929. class PostProcessesOptimization extends SceneOptimization {
  27930. /**
  27931. * Gets a string describing the action executed by the current optimization
  27932. * @return description string
  27933. */
  27934. getDescription(): string;
  27935. /**
  27936. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27937. * @param scene defines the current scene where to apply this optimization
  27938. * @param optimizer defines the current optimizer
  27939. * @returns true if everything that can be done was applied
  27940. */
  27941. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27942. }
  27943. /**
  27944. * Defines an optimization used to turn lens flares off
  27945. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27946. */
  27947. class LensFlaresOptimization extends SceneOptimization {
  27948. /**
  27949. * Gets a string describing the action executed by the current optimization
  27950. * @return description string
  27951. */
  27952. getDescription(): string;
  27953. /**
  27954. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27955. * @param scene defines the current scene where to apply this optimization
  27956. * @param optimizer defines the current optimizer
  27957. * @returns true if everything that can be done was applied
  27958. */
  27959. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27960. }
  27961. /**
  27962. * Defines an optimization based on user defined callback.
  27963. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27964. */
  27965. class CustomOptimization extends SceneOptimization {
  27966. /**
  27967. * Callback called to apply the custom optimization.
  27968. */
  27969. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  27970. /**
  27971. * Callback called to get custom description
  27972. */
  27973. onGetDescription: () => string;
  27974. /**
  27975. * Gets a string describing the action executed by the current optimization
  27976. * @returns description string
  27977. */
  27978. getDescription(): string;
  27979. /**
  27980. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27981. * @param scene defines the current scene where to apply this optimization
  27982. * @param optimizer defines the current optimizer
  27983. * @returns true if everything that can be done was applied
  27984. */
  27985. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27986. }
  27987. /**
  27988. * Defines an optimization used to turn particles off
  27989. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27990. */
  27991. class ParticlesOptimization extends SceneOptimization {
  27992. /**
  27993. * Gets a string describing the action executed by the current optimization
  27994. * @return description string
  27995. */
  27996. getDescription(): string;
  27997. /**
  27998. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27999. * @param scene defines the current scene where to apply this optimization
  28000. * @param optimizer defines the current optimizer
  28001. * @returns true if everything that can be done was applied
  28002. */
  28003. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28004. }
  28005. /**
  28006. * Defines an optimization used to turn render targets off
  28007. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28008. */
  28009. class RenderTargetsOptimization extends SceneOptimization {
  28010. /**
  28011. * Gets a string describing the action executed by the current optimization
  28012. * @return description string
  28013. */
  28014. getDescription(): string;
  28015. /**
  28016. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28017. * @param scene defines the current scene where to apply this optimization
  28018. * @param optimizer defines the current optimizer
  28019. * @returns true if everything that can be done was applied
  28020. */
  28021. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28022. }
  28023. /**
  28024. * Defines an optimization used to merge meshes with compatible materials
  28025. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28026. */
  28027. class MergeMeshesOptimization extends SceneOptimization {
  28028. private static _UpdateSelectionTree;
  28029. /**
  28030. * Gets or sets a boolean which defines if optimization octree has to be updated
  28031. */
  28032. /**
  28033. * Gets or sets a boolean which defines if optimization octree has to be updated
  28034. */
  28035. static UpdateSelectionTree: boolean;
  28036. /**
  28037. * Gets a string describing the action executed by the current optimization
  28038. * @return description string
  28039. */
  28040. getDescription(): string;
  28041. private _canBeMerged;
  28042. /**
  28043. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28044. * @param scene defines the current scene where to apply this optimization
  28045. * @param optimizer defines the current optimizer
  28046. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  28047. * @returns true if everything that can be done was applied
  28048. */
  28049. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  28050. }
  28051. /**
  28052. * Defines a list of options used by SceneOptimizer
  28053. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28054. */
  28055. class SceneOptimizerOptions {
  28056. /**
  28057. * Defines the target frame rate to reach (60 by default)
  28058. */
  28059. targetFrameRate: number;
  28060. /**
  28061. * Defines the interval between two checkes (2000ms by default)
  28062. */
  28063. trackerDuration: number;
  28064. /**
  28065. * Gets the list of optimizations to apply
  28066. */
  28067. optimizations: SceneOptimization[];
  28068. /**
  28069. * Creates a new list of options used by SceneOptimizer
  28070. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  28071. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  28072. */
  28073. constructor(
  28074. /**
  28075. * Defines the target frame rate to reach (60 by default)
  28076. */
  28077. targetFrameRate?: number,
  28078. /**
  28079. * Defines the interval between two checkes (2000ms by default)
  28080. */
  28081. trackerDuration?: number);
  28082. /**
  28083. * Add a new optimization
  28084. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  28085. * @returns the current SceneOptimizerOptions
  28086. */
  28087. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  28088. /**
  28089. * Add a new custom optimization
  28090. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  28091. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  28092. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28093. * @returns the current SceneOptimizerOptions
  28094. */
  28095. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  28096. /**
  28097. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  28098. * @param targetFrameRate defines the target frame rate (60 by default)
  28099. * @returns a SceneOptimizerOptions object
  28100. */
  28101. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28102. /**
  28103. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  28104. * @param targetFrameRate defines the target frame rate (60 by default)
  28105. * @returns a SceneOptimizerOptions object
  28106. */
  28107. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28108. /**
  28109. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  28110. * @param targetFrameRate defines the target frame rate (60 by default)
  28111. * @returns a SceneOptimizerOptions object
  28112. */
  28113. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28114. }
  28115. /**
  28116. * Class used to run optimizations in order to reach a target frame rate
  28117. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28118. */
  28119. class SceneOptimizer implements IDisposable {
  28120. private _isRunning;
  28121. private _options;
  28122. private _scene;
  28123. private _currentPriorityLevel;
  28124. private _targetFrameRate;
  28125. private _trackerDuration;
  28126. private _currentFrameRate;
  28127. private _sceneDisposeObserver;
  28128. private _improvementMode;
  28129. /**
  28130. * Defines an observable called when the optimizer reaches the target frame rate
  28131. */
  28132. onSuccessObservable: Observable<SceneOptimizer>;
  28133. /**
  28134. * Defines an observable called when the optimizer enables an optimization
  28135. */
  28136. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  28137. /**
  28138. * Defines an observable called when the optimizer is not able to reach the target frame rate
  28139. */
  28140. onFailureObservable: Observable<SceneOptimizer>;
  28141. /**
  28142. * Gets a boolean indicating if the optimizer is in improvement mode
  28143. */
  28144. readonly isInImprovementMode: boolean;
  28145. /**
  28146. * Gets the current priority level (0 at start)
  28147. */
  28148. readonly currentPriorityLevel: number;
  28149. /**
  28150. * Gets the current frame rate checked by the SceneOptimizer
  28151. */
  28152. readonly currentFrameRate: number;
  28153. /**
  28154. * Gets or sets the current target frame rate (60 by default)
  28155. */
  28156. /**
  28157. * Gets or sets the current target frame rate (60 by default)
  28158. */
  28159. targetFrameRate: number;
  28160. /**
  28161. * Gets or sets the current interval between two checks (every 2000ms by default)
  28162. */
  28163. /**
  28164. * Gets or sets the current interval between two checks (every 2000ms by default)
  28165. */
  28166. trackerDuration: number;
  28167. /**
  28168. * Gets the list of active optimizations
  28169. */
  28170. readonly optimizations: SceneOptimization[];
  28171. /**
  28172. * Creates a new SceneOptimizer
  28173. * @param scene defines the scene to work on
  28174. * @param options defines the options to use with the SceneOptimizer
  28175. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  28176. * @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)
  28177. */
  28178. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  28179. /**
  28180. * Stops the current optimizer
  28181. */
  28182. stop(): void;
  28183. /**
  28184. * Reset the optimizer to initial step (current priority level = 0)
  28185. */
  28186. reset(): void;
  28187. /**
  28188. * Start the optimizer. By default it will try to reach a specific framerate
  28189. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  28190. */
  28191. start(): void;
  28192. private _checkCurrentState();
  28193. /**
  28194. * Release all resources
  28195. */
  28196. dispose(): void;
  28197. /**
  28198. * Helper function to create a SceneOptimizer with one single line of code
  28199. * @param scene defines the scene to work on
  28200. * @param options defines the options to use with the SceneOptimizer
  28201. * @param onSuccess defines a callback to call on success
  28202. * @param onFailure defines a callback to call on failure
  28203. * @returns the new SceneOptimizer object
  28204. */
  28205. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  28206. }
  28207. }
  28208. declare module BABYLON {
  28209. class SceneSerializer {
  28210. static ClearCache(): void;
  28211. static Serialize(scene: Scene): any;
  28212. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  28213. }
  28214. }
  28215. declare module BABYLON {
  28216. class SmartArray<T> {
  28217. data: Array<T>;
  28218. length: number;
  28219. protected _id: number;
  28220. [index: number]: T;
  28221. constructor(capacity: number);
  28222. push(value: T): void;
  28223. forEach(func: (content: T) => void): void;
  28224. sort(compareFn: (a: T, b: T) => number): void;
  28225. reset(): void;
  28226. dispose(): void;
  28227. concat(array: any): void;
  28228. indexOf(value: T): number;
  28229. contains(value: T): boolean;
  28230. private static _GlobalId;
  28231. }
  28232. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  28233. private _duplicateId;
  28234. [index: number]: T;
  28235. push(value: T): void;
  28236. pushNoDuplicate(value: T): boolean;
  28237. reset(): void;
  28238. concatWithNoDuplicate(array: any): void;
  28239. }
  28240. }
  28241. declare module BABYLON {
  28242. /**
  28243. * This class implement a typical dictionary using a string as key and the generic type T as value.
  28244. * The underlying implementation relies on an associative array to ensure the best performances.
  28245. * The value can be anything including 'null' but except 'undefined'
  28246. */
  28247. class StringDictionary<T> {
  28248. /**
  28249. * This will clear this dictionary and copy the content from the 'source' one.
  28250. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  28251. * @param source the dictionary to take the content from and copy to this dictionary
  28252. */
  28253. copyFrom(source: StringDictionary<T>): void;
  28254. /**
  28255. * Get a value based from its key
  28256. * @param key the given key to get the matching value from
  28257. * @return the value if found, otherwise undefined is returned
  28258. */
  28259. get(key: string): T | undefined;
  28260. /**
  28261. * Get a value from its key or add it if it doesn't exist.
  28262. * This method will ensure you that a given key/data will be present in the dictionary.
  28263. * @param key the given key to get the matching value from
  28264. * @param factory the factory that will create the value if the key is not present in the dictionary.
  28265. * The factory will only be invoked if there's no data for the given key.
  28266. * @return the value corresponding to the key.
  28267. */
  28268. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  28269. /**
  28270. * Get a value from its key if present in the dictionary otherwise add it
  28271. * @param key the key to get the value from
  28272. * @param val if there's no such key/value pair in the dictionary add it with this value
  28273. * @return the value corresponding to the key
  28274. */
  28275. getOrAdd(key: string, val: T): T;
  28276. /**
  28277. * Check if there's a given key in the dictionary
  28278. * @param key the key to check for
  28279. * @return true if the key is present, false otherwise
  28280. */
  28281. contains(key: string): boolean;
  28282. /**
  28283. * Add a new key and its corresponding value
  28284. * @param key the key to add
  28285. * @param value the value corresponding to the key
  28286. * @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
  28287. */
  28288. add(key: string, value: T): boolean;
  28289. set(key: string, value: T): boolean;
  28290. /**
  28291. * Get the element of the given key and remove it from the dictionary
  28292. * @param key
  28293. */
  28294. getAndRemove(key: string): Nullable<T>;
  28295. /**
  28296. * Remove a key/value from the dictionary.
  28297. * @param key the key to remove
  28298. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  28299. */
  28300. remove(key: string): boolean;
  28301. /**
  28302. * Clear the whole content of the dictionary
  28303. */
  28304. clear(): void;
  28305. readonly count: number;
  28306. /**
  28307. * Execute a callback on each key/val of the dictionary.
  28308. * Note that you can remove any element in this dictionary in the callback implementation
  28309. * @param callback the callback to execute on a given key/value pair
  28310. */
  28311. forEach(callback: (key: string, val: T) => void): void;
  28312. /**
  28313. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  28314. * If the callback returns null or undefined the method will iterate to the next key/value pair
  28315. * Note that you can remove any element in this dictionary in the callback implementation
  28316. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  28317. */
  28318. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  28319. private _count;
  28320. private _data;
  28321. }
  28322. }
  28323. declare module BABYLON {
  28324. class Tags {
  28325. static EnableFor(obj: any): void;
  28326. static DisableFor(obj: any): void;
  28327. static HasTags(obj: any): boolean;
  28328. static GetTags(obj: any, asString?: boolean): any;
  28329. static AddTagsTo(obj: any, tagsString: string): void;
  28330. static _AddTagTo(obj: any, tag: string): void;
  28331. static RemoveTagsFrom(obj: any, tagsString: string): void;
  28332. static _RemoveTagFrom(obj: any, tag: string): void;
  28333. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  28334. }
  28335. }
  28336. declare module BABYLON {
  28337. class TextureTools {
  28338. /**
  28339. * Uses the GPU to create a copy texture rescaled at a given size
  28340. * @param texture Texture to copy from
  28341. * @param width Desired width
  28342. * @param height Desired height
  28343. * @return Generated texture
  28344. */
  28345. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  28346. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  28347. private static _environmentBRDFBase64Texture;
  28348. }
  28349. }
  28350. declare module BABYLON {
  28351. class TGATools {
  28352. private static _TYPE_INDEXED;
  28353. private static _TYPE_RGB;
  28354. private static _TYPE_GREY;
  28355. private static _TYPE_RLE_INDEXED;
  28356. private static _TYPE_RLE_RGB;
  28357. private static _TYPE_RLE_GREY;
  28358. private static _ORIGIN_MASK;
  28359. private static _ORIGIN_SHIFT;
  28360. private static _ORIGIN_BL;
  28361. private static _ORIGIN_BR;
  28362. private static _ORIGIN_UL;
  28363. private static _ORIGIN_UR;
  28364. static GetTGAHeader(data: Uint8Array): any;
  28365. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  28366. 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;
  28367. 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;
  28368. 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;
  28369. 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;
  28370. 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;
  28371. 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;
  28372. }
  28373. }
  28374. declare module BABYLON {
  28375. interface IAnimatable {
  28376. animations: Array<Animation>;
  28377. }
  28378. class LoadFileError extends Error {
  28379. request: XMLHttpRequest | undefined;
  28380. private static _setPrototypeOf;
  28381. constructor(message: string, request?: XMLHttpRequest | undefined);
  28382. }
  28383. class RetryStrategy {
  28384. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  28385. }
  28386. interface IFileRequest {
  28387. /**
  28388. * Raised when the request is complete (success or error).
  28389. */
  28390. onCompleteObservable: Observable<IFileRequest>;
  28391. /**
  28392. * Aborts the request for a file.
  28393. */
  28394. abort: () => void;
  28395. }
  28396. class Tools {
  28397. static BaseUrl: string;
  28398. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  28399. /**
  28400. * Default behaviour for cors in the application.
  28401. * It can be a string if the expected behavior is identical in the entire app.
  28402. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  28403. */
  28404. static CorsBehavior: string | ((url: string | string[]) => string);
  28405. static UseFallbackTexture: boolean;
  28406. /**
  28407. * Use this object to register external classes like custom textures or material
  28408. * to allow the laoders to instantiate them
  28409. */
  28410. static RegisteredExternalClasses: {
  28411. [key: string]: Object;
  28412. };
  28413. static fallbackTexture: string;
  28414. /**
  28415. * Interpolates between a and b via alpha
  28416. * @param a The lower value (returned when alpha = 0)
  28417. * @param b The upper value (returned when alpha = 1)
  28418. * @param alpha The interpolation-factor
  28419. * @return The mixed value
  28420. */
  28421. static Mix(a: number, b: number, alpha: number): number;
  28422. static Instantiate(className: string): any;
  28423. /**
  28424. * Provides a slice function that will work even on IE
  28425. * @param data defines the array to slice
  28426. * @param start defines the start of the data (optional)
  28427. * @param end defines the end of the data (optional)
  28428. * @returns the new sliced array
  28429. */
  28430. static Slice<T>(data: T, start?: number, end?: number): T;
  28431. static SetImmediate(action: () => void): void;
  28432. static IsExponentOfTwo(value: number): boolean;
  28433. private static _tmpFloatArray;
  28434. /**
  28435. * Returns the nearest 32-bit single precision float representation of a Number
  28436. * @param value A Number. If the parameter is of a different type, it will get converted
  28437. * to a number or to NaN if it cannot be converted
  28438. * @returns number
  28439. */
  28440. static FloatRound(value: number): number;
  28441. /**
  28442. * Find the next highest power of two.
  28443. * @param x Number to start search from.
  28444. * @return Next highest power of two.
  28445. */
  28446. static CeilingPOT(x: number): number;
  28447. /**
  28448. * Find the next lowest power of two.
  28449. * @param x Number to start search from.
  28450. * @return Next lowest power of two.
  28451. */
  28452. static FloorPOT(x: number): number;
  28453. /**
  28454. * Find the nearest power of two.
  28455. * @param x Number to start search from.
  28456. * @return Next nearest power of two.
  28457. */
  28458. static NearestPOT(x: number): number;
  28459. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  28460. static GetFilename(path: string): string;
  28461. /**
  28462. * Extracts the "folder" part of a path (everything before the filename).
  28463. * @param uri The URI to extract the info from
  28464. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  28465. * @returns The "folder" part of the path
  28466. */
  28467. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  28468. static GetDOMTextContent(element: HTMLElement): string;
  28469. static ToDegrees(angle: number): number;
  28470. static ToRadians(angle: number): number;
  28471. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  28472. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  28473. minimum: Vector3;
  28474. maximum: Vector3;
  28475. };
  28476. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  28477. minimum: Vector3;
  28478. maximum: Vector3;
  28479. };
  28480. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  28481. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  28482. minimum: Vector2;
  28483. maximum: Vector2;
  28484. };
  28485. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  28486. static GetPointerPrefix(): string;
  28487. /**
  28488. * @param func - the function to be called
  28489. * @param requester - the object that will request the next frame. Falls back to window.
  28490. */
  28491. static QueueNewFrame(func: () => void, requester?: any): number;
  28492. static RequestFullscreen(element: HTMLElement): void;
  28493. static ExitFullscreen(): void;
  28494. static SetCorsBehavior(url: string | string[], element: {
  28495. crossOrigin: string | null;
  28496. }): void;
  28497. static CleanUrl(url: string): string;
  28498. static PreprocessUrl: (url: string) => string;
  28499. /**
  28500. * Loads an image as an HTMLImageElement.
  28501. * @param input url string, ArrayBuffer, or Blob to load
  28502. * @param onLoad callback called when the image successfully loads
  28503. * @param onError callback called when the image fails to load
  28504. * @param database database for caching
  28505. * @returns the HTMLImageElement of the loaded image
  28506. */
  28507. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  28508. 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;
  28509. /**
  28510. * Load a script (identified by an url). When the url returns, the
  28511. * content of this file is added into a new script element, attached to the DOM (body element)
  28512. */
  28513. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  28514. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  28515. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  28516. static FileAsURL(content: string): string;
  28517. static Format(value: number, decimals?: number): string;
  28518. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  28519. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  28520. static IsEmpty(obj: any): boolean;
  28521. static RegisterTopRootEvents(events: {
  28522. name: string;
  28523. handler: Nullable<(e: FocusEvent) => any>;
  28524. }[]): void;
  28525. static UnregisterTopRootEvents(events: {
  28526. name: string;
  28527. handler: Nullable<(e: FocusEvent) => any>;
  28528. }[]): void;
  28529. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  28530. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  28531. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  28532. /**
  28533. * Generates an image screenshot from the specified camera.
  28534. *
  28535. * @param engine The engine to use for rendering
  28536. * @param camera The camera to use for rendering
  28537. * @param size This parameter can be set to a single number or to an object with the
  28538. * following (optional) properties: precision, width, height. If a single number is passed,
  28539. * it will be used for both width and height. If an object is passed, the screenshot size
  28540. * will be derived from the parameters. The precision property is a multiplier allowing
  28541. * rendering at a higher or lower resolution.
  28542. * @param successCallback The callback receives a single parameter which contains the
  28543. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  28544. * src parameter of an <img> to display it.
  28545. * @param mimeType The MIME type of the screenshot image (default: image/png).
  28546. * Check your browser for supported MIME types.
  28547. * @param samples Texture samples (default: 1)
  28548. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  28549. * @param fileName A name for for the downloaded file.
  28550. * @constructor
  28551. */
  28552. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  28553. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  28554. /**
  28555. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28556. * Be aware Math.random() could cause collisions, but:
  28557. * "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"
  28558. */
  28559. static RandomId(): string;
  28560. /**
  28561. * Test if the given uri is a base64 string.
  28562. * @param uri The uri to test
  28563. * @return True if the uri is a base64 string or false otherwise.
  28564. */
  28565. static IsBase64(uri: string): boolean;
  28566. /**
  28567. * Decode the given base64 uri.
  28568. * @param uri The uri to decode
  28569. * @return The decoded base64 data.
  28570. */
  28571. static DecodeBase64(uri: string): ArrayBuffer;
  28572. private static _NoneLogLevel;
  28573. private static _MessageLogLevel;
  28574. private static _WarningLogLevel;
  28575. private static _ErrorLogLevel;
  28576. private static _LogCache;
  28577. static errorsCount: number;
  28578. static OnNewCacheEntry: (entry: string) => void;
  28579. static readonly NoneLogLevel: number;
  28580. static readonly MessageLogLevel: number;
  28581. static readonly WarningLogLevel: number;
  28582. static readonly ErrorLogLevel: number;
  28583. static readonly AllLogLevel: number;
  28584. private static _AddLogEntry(entry);
  28585. private static _FormatMessage(message);
  28586. private static _LogDisabled(message);
  28587. private static _LogEnabled(message);
  28588. private static _WarnDisabled(message);
  28589. private static _WarnEnabled(message);
  28590. private static _ErrorDisabled(message);
  28591. private static _ErrorEnabled(message);
  28592. static Log: (message: string) => void;
  28593. static Warn: (message: string) => void;
  28594. static Error: (message: string) => void;
  28595. static readonly LogCache: string;
  28596. static ClearLogCache(): void;
  28597. static LogLevels: number;
  28598. static IsWindowObjectExist(): boolean;
  28599. private static _PerformanceNoneLogLevel;
  28600. private static _PerformanceUserMarkLogLevel;
  28601. private static _PerformanceConsoleLogLevel;
  28602. private static _performance;
  28603. static readonly PerformanceNoneLogLevel: number;
  28604. static readonly PerformanceUserMarkLogLevel: number;
  28605. static readonly PerformanceConsoleLogLevel: number;
  28606. static PerformanceLogLevel: number;
  28607. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  28608. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  28609. static _StartUserMark(counterName: string, condition?: boolean): void;
  28610. static _EndUserMark(counterName: string, condition?: boolean): void;
  28611. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  28612. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  28613. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  28614. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  28615. static readonly Now: number;
  28616. /**
  28617. * This method will return the name of the class used to create the instance of the given object.
  28618. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  28619. * @param object the object to get the class name from
  28620. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  28621. */
  28622. static GetClassName(object: any, isType?: boolean): string;
  28623. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  28624. /**
  28625. * This method will return the name of the full name of the class, including its owning module (if any).
  28626. * 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).
  28627. * @param object the object to get the class name from
  28628. * @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.
  28629. */
  28630. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  28631. /**
  28632. * 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.
  28633. * @param array
  28634. */
  28635. static arrayOrStringFeeder(array: any): (i: number) => number;
  28636. /**
  28637. * Compute the hashCode of a stream of number
  28638. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  28639. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  28640. * @return the hash code computed
  28641. */
  28642. static hashCodeFromStream(feeder: (index: number) => number): number;
  28643. /**
  28644. * Returns a promise that resolves after the given amount of time.
  28645. * @param delay Number of milliseconds to delay
  28646. * @returns Promise that resolves after the given amount of time
  28647. */
  28648. static DelayAsync(delay: number): Promise<void>;
  28649. }
  28650. /**
  28651. * This class is used to track a performance counter which is number based.
  28652. * The user has access to many properties which give statistics of different nature
  28653. *
  28654. * The implementer can track two kinds of Performance Counter: time and count
  28655. * 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.
  28656. * 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.
  28657. */
  28658. class PerfCounter {
  28659. static Enabled: boolean;
  28660. /**
  28661. * Returns the smallest value ever
  28662. */
  28663. readonly min: number;
  28664. /**
  28665. * Returns the biggest value ever
  28666. */
  28667. readonly max: number;
  28668. /**
  28669. * Returns the average value since the performance counter is running
  28670. */
  28671. readonly average: number;
  28672. /**
  28673. * Returns the average value of the last second the counter was monitored
  28674. */
  28675. readonly lastSecAverage: number;
  28676. /**
  28677. * Returns the current value
  28678. */
  28679. readonly current: number;
  28680. readonly total: number;
  28681. readonly count: number;
  28682. constructor();
  28683. /**
  28684. * Call this method to start monitoring a new frame.
  28685. * 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.
  28686. */
  28687. fetchNewFrame(): void;
  28688. /**
  28689. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28690. * @param newCount the count value to add to the monitored count
  28691. * @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.
  28692. */
  28693. addCount(newCount: number, fetchResult: boolean): void;
  28694. /**
  28695. * Start monitoring this performance counter
  28696. */
  28697. beginMonitoring(): void;
  28698. /**
  28699. * Compute the time lapsed since the previous beginMonitoring() call.
  28700. * @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
  28701. */
  28702. endMonitoring(newFrame?: boolean): void;
  28703. private _fetchResult();
  28704. private _startMonitoringTime;
  28705. private _min;
  28706. private _max;
  28707. private _average;
  28708. private _current;
  28709. private _totalValueCount;
  28710. private _totalAccumulated;
  28711. private _lastSecAverage;
  28712. private _lastSecAccumulated;
  28713. private _lastSecTime;
  28714. private _lastSecValueCount;
  28715. }
  28716. /**
  28717. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  28718. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  28719. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  28720. * @param name The name of the class, case should be preserved
  28721. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  28722. */
  28723. function className(name: string, module?: string): (target: Object) => void;
  28724. /**
  28725. * An implementation of a loop for asynchronous functions.
  28726. */
  28727. class AsyncLoop {
  28728. iterations: number;
  28729. private _fn;
  28730. private _successCallback;
  28731. index: number;
  28732. private _done;
  28733. /**
  28734. * Constroctor.
  28735. * @param iterations the number of iterations.
  28736. * @param _fn the function to run each iteration
  28737. * @param _successCallback the callback that will be called upon succesful execution
  28738. * @param offset starting offset.
  28739. */
  28740. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  28741. /**
  28742. * Execute the next iteration. Must be called after the last iteration was finished.
  28743. */
  28744. executeNext(): void;
  28745. /**
  28746. * Break the loop and run the success callback.
  28747. */
  28748. breakLoop(): void;
  28749. /**
  28750. * Helper function
  28751. */
  28752. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  28753. /**
  28754. * A for-loop that will run a given number of iterations synchronous and the rest async.
  28755. * @param iterations total number of iterations
  28756. * @param syncedIterations number of synchronous iterations in each async iteration.
  28757. * @param fn the function to call each iteration.
  28758. * @param callback a success call back that will be called when iterating stops.
  28759. * @param breakFunction a break condition (optional)
  28760. * @param timeout timeout settings for the setTimeout function. default - 0.
  28761. * @constructor
  28762. */
  28763. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  28764. }
  28765. }
  28766. declare module BABYLON {
  28767. /**
  28768. * Defines the potential axis of a Joystick
  28769. */
  28770. enum JoystickAxis {
  28771. /** X axis */
  28772. X = 0,
  28773. /** Y axis */
  28774. Y = 1,
  28775. /** Z axis */
  28776. Z = 2,
  28777. }
  28778. /**
  28779. * Class used to define virtual joystick (used in touch mode)
  28780. */
  28781. class VirtualJoystick {
  28782. /**
  28783. * Gets or sets a boolean indicating that left and right values must be inverted
  28784. */
  28785. reverseLeftRight: boolean;
  28786. /**
  28787. * Gets or sets a boolean indicating that up and down values must be inverted
  28788. */
  28789. reverseUpDown: boolean;
  28790. /**
  28791. * Gets the offset value for the position (ie. the change of the position value)
  28792. */
  28793. deltaPosition: Vector3;
  28794. /**
  28795. * Gets a boolean indicating if the virtual joystick was pressed
  28796. */
  28797. pressed: boolean;
  28798. private static _globalJoystickIndex;
  28799. private static vjCanvas;
  28800. private static vjCanvasContext;
  28801. private static vjCanvasWidth;
  28802. private static vjCanvasHeight;
  28803. private static halfWidth;
  28804. private _action;
  28805. private _axisTargetedByLeftAndRight;
  28806. private _axisTargetedByUpAndDown;
  28807. private _joystickSensibility;
  28808. private _inversedSensibility;
  28809. private _joystickPointerID;
  28810. private _joystickColor;
  28811. private _joystickPointerPos;
  28812. private _joystickPreviousPointerPos;
  28813. private _joystickPointerStartPos;
  28814. private _deltaJoystickVector;
  28815. private _leftJoystick;
  28816. private _touches;
  28817. private _onPointerDownHandlerRef;
  28818. private _onPointerMoveHandlerRef;
  28819. private _onPointerUpHandlerRef;
  28820. private _onResize;
  28821. /**
  28822. * Creates a new virtual joystick
  28823. * @param leftJoystick defines that the joystick is for left hand (false by default)
  28824. */
  28825. constructor(leftJoystick?: boolean);
  28826. /**
  28827. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  28828. * @param newJoystickSensibility defines the new sensibility
  28829. */
  28830. setJoystickSensibility(newJoystickSensibility: number): void;
  28831. private _onPointerDown(e);
  28832. private _onPointerMove(e);
  28833. private _onPointerUp(e);
  28834. /**
  28835. * Change the color of the virtual joystick
  28836. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  28837. */
  28838. setJoystickColor(newColor: string): void;
  28839. /**
  28840. * Defines a callback to call when the joystick is touched
  28841. * @param action defines the callback
  28842. */
  28843. setActionOnTouch(action: () => any): void;
  28844. /**
  28845. * Defines which axis you'd like to control for left & right
  28846. * @param axis defines the axis to use
  28847. */
  28848. setAxisForLeftRight(axis: JoystickAxis): void;
  28849. /**
  28850. * Defines which axis you'd like to control for up & down
  28851. * @param axis defines the axis to use
  28852. */
  28853. setAxisForUpDown(axis: JoystickAxis): void;
  28854. private _drawVirtualJoystick();
  28855. /**
  28856. * Release internal HTML canvas
  28857. */
  28858. releaseCanvas(): void;
  28859. }
  28860. }
  28861. declare module BABYLON {
  28862. /**
  28863. * Helper class to push actions to a pool of workers.
  28864. */
  28865. class WorkerPool implements IDisposable {
  28866. private _workerInfos;
  28867. private _pendingActions;
  28868. /**
  28869. * Constructor
  28870. * @param workers Array of workers to use for actions
  28871. */
  28872. constructor(workers: Array<Worker>);
  28873. /**
  28874. * Terminates all workers and clears any pending actions.
  28875. */
  28876. dispose(): void;
  28877. /**
  28878. * Pushes an action to the worker pool. If all the workers are active, the action will be
  28879. * pended until a worker has completed its action.
  28880. * @param action The action to perform. Call onComplete when the action is complete.
  28881. */
  28882. push(action: (worker: Worker, onComplete: () => void) => void): void;
  28883. private _execute(workerInfo, action);
  28884. }
  28885. }
  28886. declare module BABYLON {
  28887. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  28888. readonly name: string;
  28889. private _zoomStopsAnimation;
  28890. private _idleRotationSpeed;
  28891. private _idleRotationWaitTime;
  28892. private _idleRotationSpinupTime;
  28893. /**
  28894. * Gets the flag that indicates if user zooming should stop animation.
  28895. */
  28896. /**
  28897. * Sets the flag that indicates if user zooming should stop animation.
  28898. */
  28899. zoomStopsAnimation: boolean;
  28900. /**
  28901. * Gets the default speed at which the camera rotates around the model.
  28902. */
  28903. /**
  28904. * Sets the default speed at which the camera rotates around the model.
  28905. */
  28906. idleRotationSpeed: number;
  28907. /**
  28908. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  28909. */
  28910. /**
  28911. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  28912. */
  28913. idleRotationWaitTime: number;
  28914. /**
  28915. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  28916. */
  28917. /**
  28918. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  28919. */
  28920. idleRotationSpinupTime: number;
  28921. /**
  28922. * Gets a value indicating if the camera is currently rotating because of this behavior
  28923. */
  28924. readonly rotationInProgress: boolean;
  28925. private _onPrePointerObservableObserver;
  28926. private _onAfterCheckInputsObserver;
  28927. private _attachedCamera;
  28928. private _isPointerDown;
  28929. private _lastFrameTime;
  28930. private _lastInteractionTime;
  28931. private _cameraRotationSpeed;
  28932. init(): void;
  28933. attach(camera: ArcRotateCamera): void;
  28934. detach(): void;
  28935. /**
  28936. * Returns true if user is scrolling.
  28937. * @return true if user is scrolling.
  28938. */
  28939. private _userIsZooming();
  28940. private _lastFrameRadius;
  28941. private _shouldAnimationStopForInteraction();
  28942. /**
  28943. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  28944. */
  28945. private _applyUserInteraction();
  28946. private _userIsMoving();
  28947. }
  28948. }
  28949. declare module BABYLON {
  28950. /**
  28951. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  28952. */
  28953. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  28954. readonly name: string;
  28955. /**
  28956. * The easing function used by animations
  28957. */
  28958. static EasingFunction: BackEase;
  28959. /**
  28960. * The easing mode used by animations
  28961. */
  28962. static EasingMode: number;
  28963. /**
  28964. * The duration of the animation, in milliseconds
  28965. */
  28966. transitionDuration: number;
  28967. /**
  28968. * Length of the distance animated by the transition when lower radius is reached
  28969. */
  28970. lowerRadiusTransitionRange: number;
  28971. /**
  28972. * Length of the distance animated by the transition when upper radius is reached
  28973. */
  28974. upperRadiusTransitionRange: number;
  28975. private _autoTransitionRange;
  28976. /**
  28977. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  28978. */
  28979. /**
  28980. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  28981. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  28982. */
  28983. autoTransitionRange: boolean;
  28984. private _attachedCamera;
  28985. private _onAfterCheckInputsObserver;
  28986. private _onMeshTargetChangedObserver;
  28987. init(): void;
  28988. attach(camera: ArcRotateCamera): void;
  28989. detach(): void;
  28990. private _radiusIsAnimating;
  28991. private _radiusBounceTransition;
  28992. private _animatables;
  28993. private _cachedWheelPrecision;
  28994. /**
  28995. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  28996. * @param radiusLimit The limit to check against.
  28997. * @return Bool to indicate if at limit.
  28998. */
  28999. private _isRadiusAtLimit(radiusLimit);
  29000. /**
  29001. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  29002. * @param radiusDelta The delta by which to animate to. Can be negative.
  29003. */
  29004. private _applyBoundRadiusAnimation(radiusDelta);
  29005. /**
  29006. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  29007. */
  29008. protected _clearAnimationLocks(): void;
  29009. /**
  29010. * Stops and removes all animations that have been applied to the camera
  29011. */
  29012. stopAllAnimations(): void;
  29013. }
  29014. }
  29015. declare module BABYLON {
  29016. class FramingBehavior implements Behavior<ArcRotateCamera> {
  29017. readonly name: string;
  29018. private _mode;
  29019. private _radiusScale;
  29020. private _positionScale;
  29021. private _defaultElevation;
  29022. private _elevationReturnTime;
  29023. private _elevationReturnWaitTime;
  29024. private _zoomStopsAnimation;
  29025. private _framingTime;
  29026. /**
  29027. * The easing function used by animations
  29028. */
  29029. static EasingFunction: ExponentialEase;
  29030. /**
  29031. * The easing mode used by animations
  29032. */
  29033. static EasingMode: number;
  29034. /**
  29035. * Gets current mode used by the behavior.
  29036. */
  29037. /**
  29038. * Sets the current mode used by the behavior
  29039. */
  29040. mode: number;
  29041. /**
  29042. * Gets the scale applied to the radius
  29043. */
  29044. /**
  29045. * Sets the scale applied to the radius (1 by default)
  29046. */
  29047. radiusScale: number;
  29048. /**
  29049. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  29050. */
  29051. /**
  29052. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  29053. */
  29054. positionScale: number;
  29055. /**
  29056. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29057. * behaviour is triggered, in radians.
  29058. */
  29059. /**
  29060. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29061. * behaviour is triggered, in radians.
  29062. */
  29063. defaultElevation: number;
  29064. /**
  29065. * Gets the time (in milliseconds) taken to return to the default beta position.
  29066. * Negative value indicates camera should not return to default.
  29067. */
  29068. /**
  29069. * Sets the time (in milliseconds) taken to return to the default beta position.
  29070. * Negative value indicates camera should not return to default.
  29071. */
  29072. elevationReturnTime: number;
  29073. /**
  29074. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29075. */
  29076. /**
  29077. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29078. */
  29079. elevationReturnWaitTime: number;
  29080. /**
  29081. * Gets the flag that indicates if user zooming should stop animation.
  29082. */
  29083. /**
  29084. * Sets the flag that indicates if user zooming should stop animation.
  29085. */
  29086. zoomStopsAnimation: boolean;
  29087. /**
  29088. * Gets the transition time when framing the mesh, in milliseconds
  29089. */
  29090. /**
  29091. * Sets the transition time when framing the mesh, in milliseconds
  29092. */
  29093. framingTime: number;
  29094. private _onPrePointerObservableObserver;
  29095. private _onAfterCheckInputsObserver;
  29096. private _onMeshTargetChangedObserver;
  29097. private _attachedCamera;
  29098. private _isPointerDown;
  29099. private _lastInteractionTime;
  29100. init(): void;
  29101. attach(camera: ArcRotateCamera): void;
  29102. detach(): void;
  29103. private _animatables;
  29104. private _betaIsAnimating;
  29105. private _betaTransition;
  29106. private _radiusTransition;
  29107. private _vectorTransition;
  29108. /**
  29109. * Targets the given mesh and updates zoom level accordingly.
  29110. * @param mesh The mesh to target.
  29111. * @param radius Optional. If a cached radius position already exists, overrides default.
  29112. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29113. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29114. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29115. */
  29116. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29117. /**
  29118. * Targets the given mesh with its children and updates zoom level accordingly.
  29119. * @param mesh The mesh to target.
  29120. * @param radius Optional. If a cached radius position already exists, overrides default.
  29121. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29122. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29123. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29124. */
  29125. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29126. /**
  29127. * Targets the given meshes with their children and updates zoom level accordingly.
  29128. * @param meshes The mesh to target.
  29129. * @param radius Optional. If a cached radius position already exists, overrides default.
  29130. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29131. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29132. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29133. */
  29134. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29135. /**
  29136. * Targets the given mesh and updates zoom level accordingly.
  29137. * @param mesh The mesh to target.
  29138. * @param radius Optional. If a cached radius position already exists, overrides default.
  29139. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29140. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29141. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29142. */
  29143. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29144. /**
  29145. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  29146. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  29147. * frustum width.
  29148. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  29149. * to fully enclose the mesh in the viewing frustum.
  29150. */
  29151. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  29152. /**
  29153. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  29154. * is automatically returned to its default position (expected to be above ground plane).
  29155. */
  29156. private _maintainCameraAboveGround();
  29157. /**
  29158. * Returns the frustum slope based on the canvas ratio and camera FOV
  29159. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  29160. */
  29161. private _getFrustumSlope();
  29162. /**
  29163. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  29164. */
  29165. private _clearAnimationLocks();
  29166. /**
  29167. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  29168. */
  29169. private _applyUserInteraction();
  29170. /**
  29171. * Stops and removes all animations that have been applied to the camera
  29172. */
  29173. stopAllAnimations(): void;
  29174. /**
  29175. * Gets a value indicating if the user is moving the camera
  29176. */
  29177. readonly isUserIsMoving: boolean;
  29178. /**
  29179. * The camera can move all the way towards the mesh.
  29180. */
  29181. static IgnoreBoundsSizeMode: number;
  29182. /**
  29183. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  29184. */
  29185. static FitFrustumSidesMode: number;
  29186. }
  29187. }
  29188. declare module BABYLON {
  29189. class VRCameraMetrics {
  29190. hResolution: number;
  29191. vResolution: number;
  29192. hScreenSize: number;
  29193. vScreenSize: number;
  29194. vScreenCenter: number;
  29195. eyeToScreenDistance: number;
  29196. lensSeparationDistance: number;
  29197. interpupillaryDistance: number;
  29198. distortionK: number[];
  29199. chromaAbCorrection: number[];
  29200. postProcessScaleFactor: number;
  29201. lensCenterOffset: number;
  29202. compensateDistortion: boolean;
  29203. readonly aspectRatio: number;
  29204. readonly aspectRatioFov: number;
  29205. readonly leftHMatrix: Matrix;
  29206. readonly rightHMatrix: Matrix;
  29207. readonly leftPreViewMatrix: Matrix;
  29208. readonly rightPreViewMatrix: Matrix;
  29209. static GetDefault(): VRCameraMetrics;
  29210. }
  29211. }
  29212. declare module BABYLON {
  29213. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  29214. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29215. getClassName(): string;
  29216. }
  29217. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  29218. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29219. getClassName(): string;
  29220. }
  29221. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  29222. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29223. getClassName(): string;
  29224. }
  29225. }
  29226. declare module BABYLON {
  29227. /**
  29228. * Options to modify the vr teleportation behavior.
  29229. */
  29230. interface VRTeleportationOptions {
  29231. /**
  29232. * The name of the mesh which should be used as the teleportation floor. (default: null)
  29233. */
  29234. floorMeshName?: string;
  29235. /**
  29236. * A list of meshes to be used as the teleportation floor. (default: empty)
  29237. */
  29238. floorMeshes?: Mesh[];
  29239. }
  29240. /**
  29241. * Options to modify the vr experience helper's behavior.
  29242. */
  29243. interface VRExperienceHelperOptions extends WebVROptions {
  29244. /**
  29245. * Create a DeviceOrientationCamera to be used as your out of vr camera.
  29246. */
  29247. createDeviceOrientationCamera?: boolean;
  29248. /**
  29249. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found.
  29250. */
  29251. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  29252. }
  29253. /**
  29254. * Helps to quickly add VR support to an existing scene.
  29255. * See http://doc.babylonjs.com/how_to/webvr_helper
  29256. */
  29257. class VRExperienceHelper {
  29258. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  29259. private _scene;
  29260. private _position;
  29261. private _btnVR;
  29262. private _btnVRDisplayed;
  29263. private _webVRsupported;
  29264. private _webVRready;
  29265. private _webVRrequesting;
  29266. private _webVRpresenting;
  29267. private _fullscreenVRpresenting;
  29268. private _canvas;
  29269. private _webVRCamera;
  29270. private _vrDeviceOrientationCamera;
  29271. private _deviceOrientationCamera;
  29272. private _existingCamera;
  29273. private _onKeyDown;
  29274. private _onVrDisplayPresentChange;
  29275. private _onVRDisplayChanged;
  29276. private _onVRRequestPresentStart;
  29277. private _onVRRequestPresentComplete;
  29278. /**
  29279. * Observable raised when entering VR.
  29280. */
  29281. onEnteringVRObservable: Observable<VRExperienceHelper>;
  29282. /**
  29283. * Observable raised when exiting VR.
  29284. */
  29285. onExitingVRObservable: Observable<VRExperienceHelper>;
  29286. /**
  29287. * Observable raised when controller mesh is loaded.
  29288. */
  29289. onControllerMeshLoadedObservable: Observable<WebVRController>;
  29290. /** Return this.onEnteringVRObservable
  29291. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  29292. */
  29293. readonly onEnteringVR: Observable<VRExperienceHelper>;
  29294. /** Return this.onExitingVRObservable
  29295. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  29296. */
  29297. readonly onExitingVR: Observable<VRExperienceHelper>;
  29298. /** Return this.onControllerMeshLoadedObservable
  29299. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  29300. */
  29301. readonly onControllerMeshLoaded: Observable<WebVRController>;
  29302. private _rayLength;
  29303. private _useCustomVRButton;
  29304. private _teleportationRequested;
  29305. private _teleportActive;
  29306. private _floorMeshName;
  29307. private _floorMeshesCollection;
  29308. private _rotationAllowed;
  29309. private _teleportBackwardsVector;
  29310. private _teleportationTarget;
  29311. private _isDefaultTeleportationTarget;
  29312. private _postProcessMove;
  29313. private _teleportationFillColor;
  29314. private _teleportationBorderColor;
  29315. private _rotationAngle;
  29316. private _haloCenter;
  29317. private _cameraGazer;
  29318. private _padSensibilityUp;
  29319. private _padSensibilityDown;
  29320. private leftController;
  29321. private rightController;
  29322. /**
  29323. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  29324. */
  29325. onNewMeshSelected: Observable<AbstractMesh>;
  29326. /**
  29327. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  29328. */
  29329. onNewMeshPicked: Observable<PickingInfo>;
  29330. private _circleEase;
  29331. /**
  29332. * Observable raised before camera teleportation
  29333. */
  29334. onBeforeCameraTeleport: Observable<Vector3>;
  29335. /**
  29336. * Observable raised after camera teleportation
  29337. */
  29338. onAfterCameraTeleport: Observable<Vector3>;
  29339. /**
  29340. * Observable raised when current selected mesh gets unselected
  29341. */
  29342. onSelectedMeshUnselected: Observable<AbstractMesh>;
  29343. private _raySelectionPredicate;
  29344. /**
  29345. * To be optionaly changed by user to define custom ray selection
  29346. */
  29347. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  29348. /**
  29349. * To be optionaly changed by user to define custom selection logic (after ray selection)
  29350. */
  29351. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  29352. /**
  29353. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  29354. */
  29355. teleportationEnabled: boolean;
  29356. private _defaultHeight;
  29357. private _teleportationInitialized;
  29358. private _interactionsEnabled;
  29359. private _interactionsRequested;
  29360. private _displayGaze;
  29361. private _displayLaserPointer;
  29362. /**
  29363. * The mesh used to display where the user is going to teleport.
  29364. */
  29365. /**
  29366. * Sets the mesh to be used to display where the user is going to teleport.
  29367. */
  29368. teleportationTarget: Mesh;
  29369. /**
  29370. * The mesh used to display where the user is selecting,
  29371. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  29372. * See http://doc.babylonjs.com/resources/baking_transformations
  29373. */
  29374. gazeTrackerMesh: Mesh;
  29375. /**
  29376. * If the ray of the gaze should be displayed.
  29377. */
  29378. /**
  29379. * Sets if the ray of the gaze should be displayed.
  29380. */
  29381. displayGaze: boolean;
  29382. /**
  29383. * If the ray of the LaserPointer should be displayed.
  29384. */
  29385. /**
  29386. * Sets if the ray of the LaserPointer should be displayed.
  29387. */
  29388. displayLaserPointer: boolean;
  29389. /**
  29390. * The deviceOrientationCamera used as the camera when not in VR.
  29391. */
  29392. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  29393. /**
  29394. * Based on the current WebVR support, returns the current VR camera used.
  29395. */
  29396. readonly currentVRCamera: Nullable<Camera>;
  29397. /**
  29398. * The webVRCamera which is used when in VR.
  29399. */
  29400. readonly webVRCamera: WebVRFreeCamera;
  29401. /**
  29402. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  29403. */
  29404. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  29405. private readonly _teleportationRequestInitiated;
  29406. /**
  29407. * Instantiates a VRExperienceHelper.
  29408. * Helps to quickly add VR support to an existing scene.
  29409. * @param scene The scene the VRExperienceHelper belongs to.
  29410. * @param webVROptions Options to modify the vr experience helper's behavior.
  29411. */
  29412. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  29413. private _onDefaultMeshLoaded(webVRController);
  29414. private _onResize;
  29415. private _onFullscreenChange;
  29416. /**
  29417. * Gets a value indicating if we are currently in VR mode.
  29418. */
  29419. readonly isInVRMode: boolean;
  29420. private onVrDisplayPresentChange();
  29421. private onVRDisplayChanged(eventArgs);
  29422. private moveButtonToBottomRight();
  29423. private displayVRButton();
  29424. private updateButtonVisibility();
  29425. /**
  29426. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  29427. * Otherwise, will use the fullscreen API.
  29428. */
  29429. enterVR(): void;
  29430. /**
  29431. * Attempt to exit VR, or fullscreen.
  29432. */
  29433. exitVR(): void;
  29434. /**
  29435. * The position of the vr experience helper.
  29436. */
  29437. /**
  29438. * Sets the position of the vr experience helper.
  29439. */
  29440. position: Vector3;
  29441. /**
  29442. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  29443. */
  29444. enableInteractions(): void;
  29445. private beforeRender;
  29446. private _isTeleportationFloor(mesh);
  29447. /**
  29448. * Adds a floor mesh to be used for teleportation.
  29449. * @param floorMesh the mesh to be used for teleportation.
  29450. */
  29451. addFloorMesh(floorMesh: Mesh): void;
  29452. /**
  29453. * Removes a floor mesh from being used for teleportation.
  29454. * @param floorMesh the mesh to be removed.
  29455. */
  29456. removeFloorMesh(floorMesh: Mesh): void;
  29457. /**
  29458. * Enables interactions and teleportation using the VR controllers and gaze.
  29459. * @param vrTeleportationOptions options to modify teleportation behavior.
  29460. */
  29461. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  29462. private _onNewGamepadConnected;
  29463. private _tryEnableInteractionOnController;
  29464. private _onNewGamepadDisconnected;
  29465. private _enableInteractionOnController(controller);
  29466. private _checkTeleportWithRay(stateObject, gazer);
  29467. private _checkRotate(stateObject, gazer);
  29468. private _checkTeleportBackwards(stateObject, gazer);
  29469. private _enableTeleportationOnController(controller);
  29470. private _createTeleportationCircles();
  29471. private _displayTeleportationTarget();
  29472. private _hideTeleportationTarget();
  29473. private _rotateCamera(right);
  29474. private _moveTeleportationSelectorTo(hit, gazer, ray);
  29475. private _workingVector;
  29476. private _workingQuaternion;
  29477. private _workingMatrix;
  29478. private _teleportCamera(location);
  29479. private _convertNormalToDirectionOfRay(normal, ray);
  29480. private _castRayAndSelectObject(gazer);
  29481. private _notifySelectedMeshUnselected(mesh);
  29482. /**
  29483. * Sets the color of the laser ray from the vr controllers.
  29484. * @param color new color for the ray.
  29485. */
  29486. changeLaserColor(color: Color3): void;
  29487. /**
  29488. * Sets the color of the ray from the vr headsets gaze.
  29489. * @param color new color for the ray.
  29490. */
  29491. changeGazeColor(color: Color3): void;
  29492. /**
  29493. * Exits VR and disposes of the vr experience helper
  29494. */
  29495. dispose(): void;
  29496. /**
  29497. * Gets the name of the VRExperienceHelper class
  29498. * @returns "VRExperienceHelper"
  29499. */
  29500. getClassName(): string;
  29501. }
  29502. }
  29503. declare module BABYLON {
  29504. /**
  29505. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  29506. * IMPORTANT!! The data is right-hand data.
  29507. * @export
  29508. * @interface DevicePose
  29509. */
  29510. interface DevicePose {
  29511. /**
  29512. * The position of the device, values in array are [x,y,z].
  29513. */
  29514. readonly position: Nullable<Float32Array>;
  29515. /**
  29516. * The linearVelocity of the device, values in array are [x,y,z].
  29517. */
  29518. readonly linearVelocity: Nullable<Float32Array>;
  29519. /**
  29520. * The linearAcceleration of the device, values in array are [x,y,z].
  29521. */
  29522. readonly linearAcceleration: Nullable<Float32Array>;
  29523. /**
  29524. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  29525. */
  29526. readonly orientation: Nullable<Float32Array>;
  29527. /**
  29528. * The angularVelocity of the device, values in array are [x,y,z].
  29529. */
  29530. readonly angularVelocity: Nullable<Float32Array>;
  29531. /**
  29532. * The angularAcceleration of the device, values in array are [x,y,z].
  29533. */
  29534. readonly angularAcceleration: Nullable<Float32Array>;
  29535. }
  29536. /**
  29537. * Interface representing a pose controlled object in Babylon.
  29538. * A pose controlled object has both regular pose values as well as pose values
  29539. * from an external device such as a VR head mounted display
  29540. */
  29541. interface PoseControlled {
  29542. /**
  29543. * The position of the object in babylon space.
  29544. */
  29545. position: Vector3;
  29546. /**
  29547. * The rotation quaternion of the object in babylon space.
  29548. */
  29549. rotationQuaternion: Quaternion;
  29550. /**
  29551. * The position of the device in babylon space.
  29552. */
  29553. devicePosition?: Vector3;
  29554. /**
  29555. * The rotation quaternion of the device in babylon space.
  29556. */
  29557. deviceRotationQuaternion: Quaternion;
  29558. /**
  29559. * The raw pose coming from the device.
  29560. */
  29561. rawPose: Nullable<DevicePose>;
  29562. /**
  29563. * The scale of the device to be used when translating from device space to babylon space.
  29564. */
  29565. deviceScaleFactor: number;
  29566. /**
  29567. * Updates the poseControlled values based on the input device pose.
  29568. * @param poseData the pose data to update the object with
  29569. */
  29570. updateFromDevice(poseData: DevicePose): void;
  29571. }
  29572. /**
  29573. * Set of options to customize the webVRCamera
  29574. */
  29575. interface WebVROptions {
  29576. /**
  29577. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  29578. */
  29579. trackPosition?: boolean;
  29580. /**
  29581. * Sets the scale of the vrDevice in babylon space. (default: 1)
  29582. */
  29583. positionScale?: number;
  29584. /**
  29585. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  29586. */
  29587. displayName?: string;
  29588. /**
  29589. * Should the native controller meshes be initialized. (default: true)
  29590. */
  29591. controllerMeshes?: boolean;
  29592. /**
  29593. * Creating a default HemiLight only on controllers. (default: true)
  29594. */
  29595. defaultLightingOnControllers?: boolean;
  29596. /**
  29597. * If you don't want to use the default VR button of the helper. (default: false)
  29598. */
  29599. useCustomVRButton?: boolean;
  29600. /**
  29601. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  29602. */
  29603. customVRButton?: HTMLButtonElement;
  29604. /**
  29605. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  29606. */
  29607. rayLength?: number;
  29608. /**
  29609. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  29610. */
  29611. defaultHeight?: number;
  29612. }
  29613. /**
  29614. * This represents a WebVR camera.
  29615. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  29616. * @example http://doc.babylonjs.com/how_to/webvr_camera
  29617. */
  29618. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  29619. private webVROptions;
  29620. /**
  29621. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  29622. */
  29623. _vrDevice: any;
  29624. /**
  29625. * The rawPose of the vrDevice.
  29626. */
  29627. rawPose: Nullable<DevicePose>;
  29628. private _onVREnabled;
  29629. private _specsVersion;
  29630. private _attached;
  29631. private _frameData;
  29632. protected _descendants: Array<Node>;
  29633. private _deviceRoomPosition;
  29634. private _deviceRoomRotationQuaternion;
  29635. private _standingMatrix;
  29636. /**
  29637. * Represents device position in babylon space.
  29638. */
  29639. devicePosition: Vector3;
  29640. /**
  29641. * Represents device rotation in babylon space.
  29642. */
  29643. deviceRotationQuaternion: Quaternion;
  29644. /**
  29645. * The scale of the device to be used when translating from device space to babylon space.
  29646. */
  29647. deviceScaleFactor: number;
  29648. private _deviceToWorld;
  29649. private _worldToDevice;
  29650. /**
  29651. * References to the webVR controllers for the vrDevice.
  29652. */
  29653. controllers: Array<WebVRController>;
  29654. /**
  29655. * Emits an event when a controller is attached.
  29656. */
  29657. onControllersAttachedObservable: Observable<WebVRController[]>;
  29658. /**
  29659. * Emits an event when a controller's mesh has been loaded;
  29660. */
  29661. onControllerMeshLoadedObservable: Observable<WebVRController>;
  29662. /**
  29663. * If the rig cameras be used as parent instead of this camera.
  29664. */
  29665. rigParenting: boolean;
  29666. private _lightOnControllers;
  29667. private _defaultHeight?;
  29668. /**
  29669. * Instantiates a WebVRFreeCamera.
  29670. * @param name The name of the WebVRFreeCamera
  29671. * @param position The starting anchor position for the camera
  29672. * @param scene The scene the camera belongs to
  29673. * @param webVROptions a set of customizable options for the webVRCamera
  29674. */
  29675. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  29676. /**
  29677. * Gets the device distance from the ground in meters.
  29678. * @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.
  29679. */
  29680. deviceDistanceToRoomGround(): number;
  29681. /**
  29682. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  29683. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  29684. */
  29685. useStandingMatrix(callback?: (bool: boolean) => void): void;
  29686. /**
  29687. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  29688. * @returns A promise with a boolean set to if the standing matrix is supported.
  29689. */
  29690. useStandingMatrixAsync(): Promise<boolean>;
  29691. /**
  29692. * Disposes the camera
  29693. */
  29694. dispose(): void;
  29695. /**
  29696. * Gets a vrController by name.
  29697. * @param name The name of the controller to retreive
  29698. * @returns the controller matching the name specified or null if not found
  29699. */
  29700. getControllerByName(name: string): Nullable<WebVRController>;
  29701. private _leftController;
  29702. /**
  29703. * The controller corrisponding to the users left hand.
  29704. */
  29705. readonly leftController: Nullable<WebVRController>;
  29706. private _rightController;
  29707. /**
  29708. * The controller corrisponding to the users right hand.
  29709. */
  29710. readonly rightController: Nullable<WebVRController>;
  29711. /**
  29712. * Casts a ray forward from the vrCamera's gaze.
  29713. * @param length Length of the ray (default: 100)
  29714. * @returns the ray corrisponding to the gaze
  29715. */
  29716. getForwardRay(length?: number): Ray;
  29717. /**
  29718. * Updates the camera based on device's frame data
  29719. */
  29720. _checkInputs(): void;
  29721. /**
  29722. * Updates the poseControlled values based on the input device pose.
  29723. * @param poseData Pose coming from the device
  29724. */
  29725. updateFromDevice(poseData: DevicePose): void;
  29726. /**
  29727. * WebVR's attach control will start broadcasting frames to the device.
  29728. * Note that in certain browsers (chrome for example) this function must be called
  29729. * within a user-interaction callback. Example:
  29730. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  29731. *
  29732. * @param element html element to attach the vrDevice to
  29733. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  29734. */
  29735. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29736. /**
  29737. * Detaches the camera from the html element and disables VR
  29738. *
  29739. * @param element html element to detach from
  29740. */
  29741. detachControl(element: HTMLElement): void;
  29742. /**
  29743. * @returns the name of this class
  29744. */
  29745. getClassName(): string;
  29746. /**
  29747. * Calls resetPose on the vrDisplay
  29748. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  29749. */
  29750. resetToCurrentRotation(): void;
  29751. /**
  29752. * Updates the rig cameras (left and right eye)
  29753. */
  29754. _updateRigCameras(): void;
  29755. private _workingVector;
  29756. private _oneVector;
  29757. private _workingMatrix;
  29758. private updateCacheCalled;
  29759. /**
  29760. * Updates the cached values of the camera
  29761. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  29762. */
  29763. _updateCache(ignoreParentClass?: boolean): void;
  29764. /**
  29765. * Updates the current device position and rotation in the babylon world
  29766. */
  29767. update(): void;
  29768. /**
  29769. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  29770. * @returns an identity matrix
  29771. */
  29772. _getViewMatrix(): Matrix;
  29773. /**
  29774. * This function is called by the two RIG cameras.
  29775. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  29776. */
  29777. protected _getWebVRViewMatrix(): Matrix;
  29778. protected _getWebVRProjectionMatrix(): Matrix;
  29779. private _onGamepadConnectedObserver;
  29780. private _onGamepadDisconnectedObserver;
  29781. /**
  29782. * Initializes the controllers and their meshes
  29783. */
  29784. initControllers(): void;
  29785. }
  29786. }
  29787. declare module BABYLON {
  29788. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  29789. camera: ArcRotateCamera;
  29790. gamepad: Nullable<Gamepad>;
  29791. private _onGamepadConnectedObserver;
  29792. private _onGamepadDisconnectedObserver;
  29793. gamepadRotationSensibility: number;
  29794. gamepadMoveSensibility: number;
  29795. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29796. detachControl(element: Nullable<HTMLElement>): void;
  29797. checkInputs(): void;
  29798. getClassName(): string;
  29799. getSimpleName(): string;
  29800. }
  29801. }
  29802. declare module BABYLON {
  29803. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  29804. camera: ArcRotateCamera;
  29805. private _keys;
  29806. keysUp: number[];
  29807. keysDown: number[];
  29808. keysLeft: number[];
  29809. keysRight: number[];
  29810. keysReset: number[];
  29811. panningSensibility: number;
  29812. zoomingSensibility: number;
  29813. useAltToZoom: boolean;
  29814. private _ctrlPressed;
  29815. private _altPressed;
  29816. private _onCanvasBlurObserver;
  29817. private _onKeyboardObserver;
  29818. private _engine;
  29819. private _scene;
  29820. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29821. detachControl(element: Nullable<HTMLElement>): void;
  29822. checkInputs(): void;
  29823. getClassName(): string;
  29824. getSimpleName(): string;
  29825. }
  29826. }
  29827. declare module BABYLON {
  29828. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  29829. camera: ArcRotateCamera;
  29830. private _wheel;
  29831. private _observer;
  29832. wheelPrecision: number;
  29833. /**
  29834. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  29835. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  29836. */
  29837. wheelDeltaPercentage: number;
  29838. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29839. detachControl(element: Nullable<HTMLElement>): void;
  29840. getClassName(): string;
  29841. getSimpleName(): string;
  29842. }
  29843. }
  29844. declare module BABYLON {
  29845. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  29846. camera: ArcRotateCamera;
  29847. buttons: number[];
  29848. angularSensibilityX: number;
  29849. angularSensibilityY: number;
  29850. pinchPrecision: number;
  29851. /**
  29852. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  29853. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  29854. */
  29855. pinchDeltaPercentage: number;
  29856. panningSensibility: number;
  29857. multiTouchPanning: boolean;
  29858. multiTouchPanAndZoom: boolean;
  29859. private _isPanClick;
  29860. pinchInwards: boolean;
  29861. private _pointerInput;
  29862. private _observer;
  29863. private _onMouseMove;
  29864. private _onGestureStart;
  29865. private _onGesture;
  29866. private _MSGestureHandler;
  29867. private _onLostFocus;
  29868. private _onContextMenu;
  29869. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29870. detachControl(element: Nullable<HTMLElement>): void;
  29871. getClassName(): string;
  29872. getSimpleName(): string;
  29873. }
  29874. }
  29875. declare module BABYLON {
  29876. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  29877. camera: ArcRotateCamera;
  29878. alphaCorrection: number;
  29879. betaCorrection: number;
  29880. gammaCorrection: number;
  29881. private _alpha;
  29882. private _gamma;
  29883. private _dirty;
  29884. private _deviceOrientationHandler;
  29885. constructor();
  29886. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29887. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  29888. checkInputs(): void;
  29889. detachControl(element: Nullable<HTMLElement>): void;
  29890. getClassName(): string;
  29891. getSimpleName(): string;
  29892. }
  29893. }
  29894. declare module BABYLON {
  29895. /**
  29896. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  29897. * Screen rotation is taken into account.
  29898. */
  29899. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  29900. private _camera;
  29901. private _screenOrientationAngle;
  29902. private _constantTranform;
  29903. private _screenQuaternion;
  29904. private _alpha;
  29905. private _beta;
  29906. private _gamma;
  29907. constructor();
  29908. camera: FreeCamera;
  29909. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29910. private _orientationChanged;
  29911. private _deviceOrientation;
  29912. detachControl(element: Nullable<HTMLElement>): void;
  29913. checkInputs(): void;
  29914. getClassName(): string;
  29915. getSimpleName(): string;
  29916. }
  29917. }
  29918. declare module BABYLON {
  29919. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  29920. camera: FreeCamera;
  29921. gamepad: Nullable<Gamepad>;
  29922. private _onGamepadConnectedObserver;
  29923. private _onGamepadDisconnectedObserver;
  29924. gamepadAngularSensibility: number;
  29925. gamepadMoveSensibility: number;
  29926. private _cameraTransform;
  29927. private _deltaTransform;
  29928. private _vector3;
  29929. private _vector2;
  29930. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29931. detachControl(element: Nullable<HTMLElement>): void;
  29932. checkInputs(): void;
  29933. getClassName(): string;
  29934. getSimpleName(): string;
  29935. }
  29936. }
  29937. declare module BABYLON {
  29938. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  29939. camera: FreeCamera;
  29940. private _keys;
  29941. private _onCanvasBlurObserver;
  29942. private _onKeyboardObserver;
  29943. private _engine;
  29944. private _scene;
  29945. keysUp: number[];
  29946. keysDown: number[];
  29947. keysLeft: number[];
  29948. keysRight: number[];
  29949. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29950. detachControl(element: Nullable<HTMLElement>): void;
  29951. checkInputs(): void;
  29952. getClassName(): string;
  29953. _onLostFocus(e: FocusEvent): void;
  29954. getSimpleName(): string;
  29955. }
  29956. }
  29957. declare module BABYLON {
  29958. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  29959. touchEnabled: boolean;
  29960. camera: FreeCamera;
  29961. buttons: number[];
  29962. angularSensibility: number;
  29963. private _pointerInput;
  29964. private _onMouseMove;
  29965. private _observer;
  29966. private previousPosition;
  29967. constructor(touchEnabled?: boolean);
  29968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29969. detachControl(element: Nullable<HTMLElement>): void;
  29970. getClassName(): string;
  29971. getSimpleName(): string;
  29972. }
  29973. }
  29974. declare module BABYLON {
  29975. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  29976. camera: FreeCamera;
  29977. private _offsetX;
  29978. private _offsetY;
  29979. private _pointerPressed;
  29980. private _pointerInput;
  29981. private _observer;
  29982. private _onLostFocus;
  29983. touchAngularSensibility: number;
  29984. touchMoveSensibility: number;
  29985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29986. detachControl(element: Nullable<HTMLElement>): void;
  29987. checkInputs(): void;
  29988. getClassName(): string;
  29989. getSimpleName(): string;
  29990. }
  29991. }
  29992. declare module BABYLON {
  29993. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  29994. camera: FreeCamera;
  29995. private _leftjoystick;
  29996. private _rightjoystick;
  29997. getLeftJoystick(): VirtualJoystick;
  29998. getRightJoystick(): VirtualJoystick;
  29999. checkInputs(): void;
  30000. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30001. detachControl(element: Nullable<HTMLElement>): void;
  30002. getClassName(): string;
  30003. getSimpleName(): string;
  30004. }
  30005. }
  30006. declare module BABYLON {
  30007. interface IOctreeContainer<T> {
  30008. blocks: Array<OctreeBlock<T>>;
  30009. }
  30010. class Octree<T> {
  30011. maxDepth: number;
  30012. blocks: Array<OctreeBlock<T>>;
  30013. dynamicContent: T[];
  30014. private _maxBlockCapacity;
  30015. private _selectionContent;
  30016. private _creationFunc;
  30017. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  30018. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  30019. addMesh(entry: T): void;
  30020. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  30021. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  30022. intersectsRay(ray: Ray): SmartArray<T>;
  30023. 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;
  30024. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  30025. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  30026. }
  30027. }
  30028. declare module BABYLON {
  30029. class OctreeBlock<T> {
  30030. entries: T[];
  30031. blocks: Array<OctreeBlock<T>>;
  30032. private _depth;
  30033. private _maxDepth;
  30034. private _capacity;
  30035. private _minPoint;
  30036. private _maxPoint;
  30037. private _boundingVectors;
  30038. private _creationFunc;
  30039. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  30040. readonly capacity: number;
  30041. readonly minPoint: Vector3;
  30042. readonly maxPoint: Vector3;
  30043. addEntry(entry: T): void;
  30044. addEntries(entries: T[]): void;
  30045. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  30046. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  30047. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  30048. createInnerBlocks(): void;
  30049. }
  30050. }
  30051. declare module BABYLON {
  30052. /**
  30053. * Google Daydream controller
  30054. */
  30055. class DaydreamController extends WebVRController {
  30056. /**
  30057. * Base Url for the controller model.
  30058. */
  30059. static MODEL_BASE_URL: string;
  30060. /**
  30061. * File name for the controller model.
  30062. */
  30063. static MODEL_FILENAME: string;
  30064. /**
  30065. * Gamepad Id prefix used to identify Daydream Controller.
  30066. */
  30067. static readonly GAMEPAD_ID_PREFIX: string;
  30068. /**
  30069. * Creates a new DaydreamController from a gamepad
  30070. * @param vrGamepad the gamepad that the controller should be created from
  30071. */
  30072. constructor(vrGamepad: any);
  30073. /**
  30074. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30075. * @param scene scene in which to add meshes
  30076. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30077. */
  30078. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30079. /**
  30080. * Called once for each button that changed state since the last frame
  30081. * @param buttonIdx Which button index changed
  30082. * @param state New state of the button
  30083. * @param changes Which properties on the state changed since last frame
  30084. */
  30085. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30086. }
  30087. }
  30088. declare module BABYLON {
  30089. /**
  30090. * Gear VR Controller
  30091. */
  30092. class GearVRController extends WebVRController {
  30093. /**
  30094. * Base Url for the controller model.
  30095. */
  30096. static MODEL_BASE_URL: string;
  30097. /**
  30098. * File name for the controller model.
  30099. */
  30100. static MODEL_FILENAME: string;
  30101. /**
  30102. * Gamepad Id prefix used to identify this controller.
  30103. */
  30104. static readonly GAMEPAD_ID_PREFIX: string;
  30105. private readonly _buttonIndexToObservableNameMap;
  30106. /**
  30107. * Creates a new GearVRController from a gamepad
  30108. * @param vrGamepad the gamepad that the controller should be created from
  30109. */
  30110. constructor(vrGamepad: any);
  30111. /**
  30112. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30113. * @param scene scene in which to add meshes
  30114. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30115. */
  30116. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30117. /**
  30118. * Called once for each button that changed state since the last frame
  30119. * @param buttonIdx Which button index changed
  30120. * @param state New state of the button
  30121. * @param changes Which properties on the state changed since last frame
  30122. */
  30123. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30124. }
  30125. }
  30126. declare module BABYLON {
  30127. /**
  30128. * Generic Controller
  30129. */
  30130. class GenericController extends WebVRController {
  30131. /**
  30132. * Base Url for the controller model.
  30133. */
  30134. static readonly MODEL_BASE_URL: string;
  30135. /**
  30136. * File name for the controller model.
  30137. */
  30138. static readonly MODEL_FILENAME: string;
  30139. /**
  30140. * Creates a new GenericController from a gamepad
  30141. * @param vrGamepad the gamepad that the controller should be created from
  30142. */
  30143. constructor(vrGamepad: any);
  30144. /**
  30145. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30146. * @param scene scene in which to add meshes
  30147. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30148. */
  30149. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30150. /**
  30151. * Called once for each button that changed state since the last frame
  30152. * @param buttonIdx Which button index changed
  30153. * @param state New state of the button
  30154. * @param changes Which properties on the state changed since last frame
  30155. */
  30156. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30157. }
  30158. }
  30159. declare module BABYLON {
  30160. /**
  30161. * Oculus Touch Controller
  30162. */
  30163. class OculusTouchController extends WebVRController {
  30164. /**
  30165. * Base Url for the controller model.
  30166. */
  30167. static MODEL_BASE_URL: string;
  30168. /**
  30169. * File name for the left controller model.
  30170. */
  30171. static MODEL_LEFT_FILENAME: string;
  30172. /**
  30173. * File name for the right controller model.
  30174. */
  30175. static MODEL_RIGHT_FILENAME: string;
  30176. /**
  30177. * Fired when the secondary trigger on this controller is modified
  30178. */
  30179. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  30180. /**
  30181. * Fired when the thumb rest on this controller is modified
  30182. */
  30183. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  30184. /**
  30185. * Creates a new OculusTouchController from a gamepad
  30186. * @param vrGamepad the gamepad that the controller should be created from
  30187. */
  30188. constructor(vrGamepad: any);
  30189. /**
  30190. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30191. * @param scene scene in which to add meshes
  30192. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30193. */
  30194. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30195. /**
  30196. * Fired when the A button on this controller is modified
  30197. */
  30198. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30199. /**
  30200. * Fired when the B button on this controller is modified
  30201. */
  30202. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30203. /**
  30204. * Fired when the X button on this controller is modified
  30205. */
  30206. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30207. /**
  30208. * Fired when the Y button on this controller is modified
  30209. */
  30210. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30211. /**
  30212. * Called once for each button that changed state since the last frame
  30213. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  30214. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  30215. * 2) secondary trigger (same)
  30216. * 3) A (right) X (left), touch, pressed = value
  30217. * 4) B / Y
  30218. * 5) thumb rest
  30219. * @param buttonIdx Which button index changed
  30220. * @param state New state of the button
  30221. * @param changes Which properties on the state changed since last frame
  30222. */
  30223. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30224. }
  30225. }
  30226. declare module BABYLON {
  30227. /**
  30228. * Defines the types of pose enabled controllers that are supported
  30229. */
  30230. enum PoseEnabledControllerType {
  30231. /**
  30232. * HTC Vive
  30233. */
  30234. VIVE = 0,
  30235. /**
  30236. * Oculus Rift
  30237. */
  30238. OCULUS = 1,
  30239. /**
  30240. * Windows mixed reality
  30241. */
  30242. WINDOWS = 2,
  30243. /**
  30244. * Samsung gear VR
  30245. */
  30246. GEAR_VR = 3,
  30247. /**
  30248. * Google Daydream
  30249. */
  30250. DAYDREAM = 4,
  30251. /**
  30252. * Generic
  30253. */
  30254. GENERIC = 5,
  30255. }
  30256. /**
  30257. * Defines the MutableGamepadButton interface for the state of a gamepad button
  30258. */
  30259. interface MutableGamepadButton {
  30260. /**
  30261. * Value of the button/trigger
  30262. */
  30263. value: number;
  30264. /**
  30265. * If the button/trigger is currently touched
  30266. */
  30267. touched: boolean;
  30268. /**
  30269. * If the button/trigger is currently pressed
  30270. */
  30271. pressed: boolean;
  30272. }
  30273. /**
  30274. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  30275. * @hidden
  30276. */
  30277. interface ExtendedGamepadButton extends GamepadButton {
  30278. /**
  30279. * If the button/trigger is currently pressed
  30280. */
  30281. readonly pressed: boolean;
  30282. /**
  30283. * If the button/trigger is currently touched
  30284. */
  30285. readonly touched: boolean;
  30286. /**
  30287. * Value of the button/trigger
  30288. */
  30289. readonly value: number;
  30290. }
  30291. /**
  30292. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30293. */
  30294. class PoseEnabledControllerHelper {
  30295. /**
  30296. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30297. * @param vrGamepad the gamepad to initialized
  30298. * @returns a vr controller of the type the gamepad identified as
  30299. */
  30300. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  30301. }
  30302. /**
  30303. * Defines the PoseEnabledController object that contains state of a vr capable controller
  30304. */
  30305. class PoseEnabledController extends Gamepad implements PoseControlled {
  30306. private _deviceRoomPosition;
  30307. private _deviceRoomRotationQuaternion;
  30308. /**
  30309. * The device position in babylon space
  30310. */
  30311. devicePosition: Vector3;
  30312. /**
  30313. * The device rotation in babylon space
  30314. */
  30315. deviceRotationQuaternion: Quaternion;
  30316. /**
  30317. * The scale factor of the device in babylon space
  30318. */
  30319. deviceScaleFactor: number;
  30320. /**
  30321. * (Likely devicePosition should be used instead) The device position in its room space
  30322. */
  30323. position: Vector3;
  30324. /**
  30325. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  30326. */
  30327. rotationQuaternion: Quaternion;
  30328. /**
  30329. * The type of controller (Eg. Windows mixed reality)
  30330. */
  30331. controllerType: PoseEnabledControllerType;
  30332. protected _calculatedPosition: Vector3;
  30333. private _calculatedRotation;
  30334. /**
  30335. * The raw pose from the device
  30336. */
  30337. rawPose: DevicePose;
  30338. /**
  30339. * Internal, the mesh attached to the controller
  30340. */
  30341. _mesh: Nullable<AbstractMesh>;
  30342. private _poseControlledCamera;
  30343. private _leftHandSystemQuaternion;
  30344. /**
  30345. * Internal, matrix used to convert room space to babylon space
  30346. */
  30347. _deviceToWorld: Matrix;
  30348. /**
  30349. * Node to be used when casting a ray from the controller
  30350. */
  30351. _pointingPoseNode: Nullable<AbstractMesh>;
  30352. /**
  30353. * Name of the child mesh that can be used to cast a ray from the controller
  30354. */
  30355. static readonly POINTING_POSE: string;
  30356. /**
  30357. * Creates a new PoseEnabledController from a gamepad
  30358. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  30359. */
  30360. constructor(browserGamepad: any);
  30361. private _workingMatrix;
  30362. /**
  30363. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  30364. */
  30365. update(): void;
  30366. /**
  30367. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  30368. * @param poseData raw pose fromthe device
  30369. */
  30370. updateFromDevice(poseData: DevicePose): void;
  30371. /**
  30372. * @hidden
  30373. */
  30374. _meshAttachedObservable: Observable<AbstractMesh>;
  30375. /**
  30376. * Attaches a mesh to the controller
  30377. * @param mesh the mesh to be attached
  30378. */
  30379. attachToMesh(mesh: AbstractMesh): void;
  30380. /**
  30381. * Attaches the controllers mesh to a camera
  30382. * @param camera the camera the mesh should be attached to
  30383. */
  30384. attachToPoseControlledCamera(camera: TargetCamera): void;
  30385. /**
  30386. * Disposes of the controller
  30387. */
  30388. dispose(): void;
  30389. /**
  30390. * The mesh that is attached to the controller
  30391. */
  30392. readonly mesh: Nullable<AbstractMesh>;
  30393. /**
  30394. * Gets the ray of the controller in the direction the controller is pointing
  30395. * @param length the length the resulting ray should be
  30396. * @returns a ray in the direction the controller is pointing
  30397. */
  30398. getForwardRay(length?: number): Ray;
  30399. }
  30400. }
  30401. declare module BABYLON {
  30402. /**
  30403. * Vive Controller
  30404. */
  30405. class ViveController extends WebVRController {
  30406. /**
  30407. * Base Url for the controller model.
  30408. */
  30409. static MODEL_BASE_URL: string;
  30410. /**
  30411. * File name for the controller model.
  30412. */
  30413. static MODEL_FILENAME: string;
  30414. /**
  30415. * Creates a new ViveController from a gamepad
  30416. * @param vrGamepad the gamepad that the controller should be created from
  30417. */
  30418. constructor(vrGamepad: any);
  30419. /**
  30420. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30421. * @param scene scene in which to add meshes
  30422. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30423. */
  30424. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30425. /**
  30426. * Fired when the left button on this controller is modified
  30427. */
  30428. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30429. /**
  30430. * Fired when the right button on this controller is modified
  30431. */
  30432. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30433. /**
  30434. * Fired when the menu button on this controller is modified
  30435. */
  30436. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30437. /**
  30438. * Called once for each button that changed state since the last frame
  30439. * Vive mapping:
  30440. * 0: touchpad
  30441. * 1: trigger
  30442. * 2: left AND right buttons
  30443. * 3: menu button
  30444. * @param buttonIdx Which button index changed
  30445. * @param state New state of the button
  30446. * @param changes Which properties on the state changed since last frame
  30447. */
  30448. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30449. }
  30450. }
  30451. declare module BABYLON {
  30452. /**
  30453. * Defines the WebVRController object that represents controllers tracked in 3D space
  30454. */
  30455. abstract class WebVRController extends PoseEnabledController {
  30456. /**
  30457. * Internal, the default controller model for the controller
  30458. */
  30459. protected _defaultModel: AbstractMesh;
  30460. /**
  30461. * Fired when the trigger state has changed
  30462. */
  30463. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  30464. /**
  30465. * Fired when the main button state has changed
  30466. */
  30467. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30468. /**
  30469. * Fired when the secondary button state has changed
  30470. */
  30471. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30472. /**
  30473. * Fired when the pad state has changed
  30474. */
  30475. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  30476. /**
  30477. * Fired when controllers stick values have changed
  30478. */
  30479. onPadValuesChangedObservable: Observable<StickValues>;
  30480. /**
  30481. * Array of button availible on the controller
  30482. */
  30483. protected _buttons: Array<MutableGamepadButton>;
  30484. private _onButtonStateChange;
  30485. /**
  30486. * Fired when a controller button's state has changed
  30487. * @param callback the callback containing the button that was modified
  30488. */
  30489. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  30490. /**
  30491. * X and Y axis corrisponding to the controllers joystick
  30492. */
  30493. pad: StickValues;
  30494. /**
  30495. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  30496. */
  30497. hand: string;
  30498. /**
  30499. * The default controller model for the controller
  30500. */
  30501. readonly defaultModel: AbstractMesh;
  30502. /**
  30503. * Creates a new WebVRController from a gamepad
  30504. * @param vrGamepad the gamepad that the WebVRController should be created from
  30505. */
  30506. constructor(vrGamepad: any);
  30507. /**
  30508. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  30509. */
  30510. update(): void;
  30511. /**
  30512. * Function to be called when a button is modified
  30513. */
  30514. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30515. /**
  30516. * Loads a mesh and attaches it to the controller
  30517. * @param scene the scene the mesh should be added to
  30518. * @param meshLoaded callback for when the mesh has been loaded
  30519. */
  30520. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30521. private _setButtonValue(newState, currentState, buttonIndex);
  30522. private _changes;
  30523. private _checkChanges(newState, currentState);
  30524. /**
  30525. * Disposes of th webVRCOntroller
  30526. */
  30527. dispose(): void;
  30528. }
  30529. }
  30530. declare module BABYLON {
  30531. /**
  30532. * Defines the WindowsMotionController object that the state of the windows motion controller
  30533. */
  30534. class WindowsMotionController extends WebVRController {
  30535. /**
  30536. * The base url used to load the left and right controller models
  30537. */
  30538. static MODEL_BASE_URL: string;
  30539. /**
  30540. * The name of the left controller model file
  30541. */
  30542. static MODEL_LEFT_FILENAME: string;
  30543. /**
  30544. * The name of the right controller model file
  30545. */
  30546. static MODEL_RIGHT_FILENAME: string;
  30547. /**
  30548. * The controller name prefix for this controller type
  30549. */
  30550. static readonly GAMEPAD_ID_PREFIX: string;
  30551. /**
  30552. * The controller id pattern for this controller type
  30553. */
  30554. private static readonly GAMEPAD_ID_PATTERN;
  30555. private _loadedMeshInfo;
  30556. private readonly _mapping;
  30557. /**
  30558. * Fired when the trackpad on this controller is clicked
  30559. */
  30560. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  30561. /**
  30562. * Fired when the trackpad on this controller is modified
  30563. */
  30564. onTrackpadValuesChangedObservable: Observable<StickValues>;
  30565. /**
  30566. * The current x and y values of this controller's trackpad
  30567. */
  30568. trackpad: StickValues;
  30569. /**
  30570. * Creates a new WindowsMotionController from a gamepad
  30571. * @param vrGamepad the gamepad that the controller should be created from
  30572. */
  30573. constructor(vrGamepad: any);
  30574. /**
  30575. * Fired when the trigger on this controller is modified
  30576. */
  30577. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30578. /**
  30579. * Fired when the menu button on this controller is modified
  30580. */
  30581. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30582. /**
  30583. * Fired when the grip button on this controller is modified
  30584. */
  30585. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30586. /**
  30587. * Fired when the thumbstick button on this controller is modified
  30588. */
  30589. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30590. /**
  30591. * Fired when the touchpad button on this controller is modified
  30592. */
  30593. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30594. /**
  30595. * Fired when the touchpad values on this controller are modified
  30596. */
  30597. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  30598. /**
  30599. * Called once per frame by the engine.
  30600. */
  30601. update(): void;
  30602. /**
  30603. * Called once for each button that changed state since the last frame
  30604. * @param buttonIdx Which button index changed
  30605. * @param state New state of the button
  30606. * @param changes Which properties on the state changed since last frame
  30607. */
  30608. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30609. /**
  30610. * Moves the buttons on the controller mesh based on their current state
  30611. * @param buttonName the name of the button to move
  30612. * @param buttonValue the value of the button which determines the buttons new position
  30613. */
  30614. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  30615. /**
  30616. * Moves the axis on the controller mesh based on its current state
  30617. * @param axis the index of the axis
  30618. * @param axisValue the value of the axis which determines the meshes new position
  30619. * @hidden
  30620. */
  30621. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  30622. /**
  30623. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30624. * @param scene scene in which to add meshes
  30625. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30626. */
  30627. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  30628. /**
  30629. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  30630. * can be transformed by button presses and axes values, based on this._mapping.
  30631. *
  30632. * @param scene scene in which the meshes exist
  30633. * @param meshes list of meshes that make up the controller model to process
  30634. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  30635. */
  30636. private processModel(scene, meshes);
  30637. private createMeshInfo(rootNode);
  30638. /**
  30639. * Gets the ray of the controller in the direction the controller is pointing
  30640. * @param length the length the resulting ray should be
  30641. * @returns a ray in the direction the controller is pointing
  30642. */
  30643. getForwardRay(length?: number): Ray;
  30644. /**
  30645. * Disposes of the controller
  30646. */
  30647. dispose(): void;
  30648. }
  30649. }
  30650. declare module BABYLON {
  30651. /**
  30652. * Interface to implement to create a shadow generator compatible with BJS.
  30653. */
  30654. interface IShadowGenerator {
  30655. /**
  30656. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30657. * @returns The render target texture if present otherwise, null
  30658. */
  30659. getShadowMap(): Nullable<RenderTargetTexture>;
  30660. /**
  30661. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30662. * @returns The render target texture if the shadow map is present otherwise, null
  30663. */
  30664. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30665. /**
  30666. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30667. * @param subMesh The submesh we want to render in the shadow map
  30668. * @param useInstances Defines wether will draw in the map using instances
  30669. * @returns true if ready otherwise, false
  30670. */
  30671. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  30672. /**
  30673. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30674. * @param defines Defines of the material we want to update
  30675. * @param lightIndex Index of the light in the enabled light list of the material
  30676. */
  30677. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  30678. /**
  30679. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30680. * defined in the generator but impacting the effect).
  30681. * It implies the unifroms available on the materials are the standard BJS ones.
  30682. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30683. * @param effect The effect we are binfing the information for
  30684. */
  30685. bindShadowLight(lightIndex: string, effect: Effect): void;
  30686. /**
  30687. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30688. * (eq to shadow prjection matrix * light transform matrix)
  30689. * @returns The transform matrix used to create the shadow map
  30690. */
  30691. getTransformMatrix(): Matrix;
  30692. /**
  30693. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30694. * Cube and 2D textures for instance.
  30695. */
  30696. recreateShadowMap(): void;
  30697. /**
  30698. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30699. * @param onCompiled Callback triggered at the and of the effects compilation
  30700. * @param options Sets of optional options forcing the compilation with different modes
  30701. */
  30702. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  30703. useInstances: boolean;
  30704. }>): void;
  30705. /**
  30706. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30707. * @param options Sets of optional options forcing the compilation with different modes
  30708. * @returns A promise that resolves when the compilation completes
  30709. */
  30710. forceCompilationAsync(options?: Partial<{
  30711. useInstances: boolean;
  30712. }>): Promise<void>;
  30713. /**
  30714. * Serializes the shadow generator setup to a json object.
  30715. * @returns The serialized JSON object
  30716. */
  30717. serialize(): any;
  30718. /**
  30719. * Disposes the Shadow map and related Textures and effects.
  30720. */
  30721. dispose(): void;
  30722. }
  30723. /**
  30724. * Default implementation IShadowGenerator.
  30725. * This is the main object responsible of generating shadows in the framework.
  30726. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  30727. */
  30728. class ShadowGenerator implements IShadowGenerator {
  30729. /**
  30730. * Shadow generator mode None: no filtering applied.
  30731. */
  30732. static readonly FILTER_NONE: number;
  30733. /**
  30734. * Shadow generator mode ESM: Exponential Shadow Mapping.
  30735. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30736. */
  30737. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  30738. /**
  30739. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  30740. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  30741. */
  30742. static readonly FILTER_POISSONSAMPLING: number;
  30743. /**
  30744. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  30745. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30746. */
  30747. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  30748. /**
  30749. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  30750. * edge artifacts on steep falloff.
  30751. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30752. */
  30753. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  30754. /**
  30755. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  30756. * edge artifacts on steep falloff.
  30757. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30758. */
  30759. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  30760. /**
  30761. * Shadow generator mode PCF: Percentage Closer Filtering
  30762. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30763. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  30764. */
  30765. static readonly FILTER_PCF: number;
  30766. /**
  30767. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  30768. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30769. * Contact Hardening
  30770. */
  30771. static readonly FILTER_PCSS: number;
  30772. /**
  30773. * Reserved for PCF and PCSS
  30774. * Highest Quality.
  30775. *
  30776. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  30777. *
  30778. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  30779. */
  30780. static readonly QUALITY_HIGH: number;
  30781. /**
  30782. * Reserved for PCF and PCSS
  30783. * Good tradeoff for quality/perf cross devices
  30784. *
  30785. * Execute PCF on a 3*3 kernel.
  30786. *
  30787. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  30788. */
  30789. static readonly QUALITY_MEDIUM: number;
  30790. /**
  30791. * Reserved for PCF and PCSS
  30792. * The lowest quality but the fastest.
  30793. *
  30794. * Execute PCF on a 1*1 kernel.
  30795. *
  30796. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  30797. */
  30798. static readonly QUALITY_LOW: number;
  30799. private _bias;
  30800. /**
  30801. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  30802. */
  30803. /**
  30804. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  30805. */
  30806. bias: number;
  30807. private _normalBias;
  30808. /**
  30809. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30810. */
  30811. /**
  30812. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30813. */
  30814. normalBias: number;
  30815. private _blurBoxOffset;
  30816. /**
  30817. * Gets the blur box offset: offset applied during the blur pass.
  30818. * Only usefull if useKernelBlur = false
  30819. */
  30820. /**
  30821. * Sets the blur box offset: offset applied during the blur pass.
  30822. * Only usefull if useKernelBlur = false
  30823. */
  30824. blurBoxOffset: number;
  30825. private _blurScale;
  30826. /**
  30827. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  30828. * 2 means half of the size.
  30829. */
  30830. /**
  30831. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  30832. * 2 means half of the size.
  30833. */
  30834. blurScale: number;
  30835. private _blurKernel;
  30836. /**
  30837. * Gets the blur kernel: kernel size of the blur pass.
  30838. * Only usefull if useKernelBlur = true
  30839. */
  30840. /**
  30841. * Sets the blur kernel: kernel size of the blur pass.
  30842. * Only usefull if useKernelBlur = true
  30843. */
  30844. blurKernel: number;
  30845. private _useKernelBlur;
  30846. /**
  30847. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  30848. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  30849. */
  30850. /**
  30851. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  30852. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  30853. */
  30854. useKernelBlur: boolean;
  30855. private _depthScale;
  30856. /**
  30857. * Gets the depth scale used in ESM mode.
  30858. */
  30859. /**
  30860. * Sets the depth scale used in ESM mode.
  30861. * This can override the scale stored on the light.
  30862. */
  30863. depthScale: number;
  30864. private _filter;
  30865. /**
  30866. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  30867. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30868. */
  30869. /**
  30870. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  30871. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30872. */
  30873. filter: number;
  30874. /**
  30875. * Gets if the current filter is set to Poisson Sampling.
  30876. */
  30877. /**
  30878. * Sets the current filter to Poisson Sampling.
  30879. */
  30880. usePoissonSampling: boolean;
  30881. /**
  30882. * Gets if the current filter is set to VSM.
  30883. * DEPRECATED. Should use useExponentialShadowMap instead.
  30884. */
  30885. /**
  30886. * Sets the current filter is to VSM.
  30887. * DEPRECATED. Should use useExponentialShadowMap instead.
  30888. */
  30889. useVarianceShadowMap: boolean;
  30890. /**
  30891. * Gets if the current filter is set to blurred VSM.
  30892. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  30893. */
  30894. /**
  30895. * Sets the current filter is to blurred VSM.
  30896. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  30897. */
  30898. useBlurVarianceShadowMap: boolean;
  30899. /**
  30900. * Gets if the current filter is set to ESM.
  30901. */
  30902. /**
  30903. * Sets the current filter is to ESM.
  30904. */
  30905. useExponentialShadowMap: boolean;
  30906. /**
  30907. * Gets if the current filter is set to filtered ESM.
  30908. */
  30909. /**
  30910. * Gets if the current filter is set to filtered ESM.
  30911. */
  30912. useBlurExponentialShadowMap: boolean;
  30913. /**
  30914. * Gets if the current filter is set to "close ESM" (using the inverse of the
  30915. * exponential to prevent steep falloff artifacts).
  30916. */
  30917. /**
  30918. * Sets the current filter to "close ESM" (using the inverse of the
  30919. * exponential to prevent steep falloff artifacts).
  30920. */
  30921. useCloseExponentialShadowMap: boolean;
  30922. /**
  30923. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  30924. * exponential to prevent steep falloff artifacts).
  30925. */
  30926. /**
  30927. * Sets the current filter to filtered "close ESM" (using the inverse of the
  30928. * exponential to prevent steep falloff artifacts).
  30929. */
  30930. useBlurCloseExponentialShadowMap: boolean;
  30931. /**
  30932. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  30933. */
  30934. /**
  30935. * Sets the current filter to "PCF" (percentage closer filtering).
  30936. */
  30937. usePercentageCloserFiltering: boolean;
  30938. private _filteringQuality;
  30939. /**
  30940. * Gets the PCF or PCSS Quality.
  30941. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30942. */
  30943. /**
  30944. * Sets the PCF or PCSS Quality.
  30945. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30946. */
  30947. filteringQuality: number;
  30948. /**
  30949. * Gets if the current filter is set to "PCSS" (contact hardening).
  30950. */
  30951. /**
  30952. * Sets the current filter to "PCSS" (contact hardening).
  30953. */
  30954. useContactHardeningShadow: boolean;
  30955. private _contactHardeningLightSizeUVRatio;
  30956. /**
  30957. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30958. * Using a ratio helps keeping shape stability independently of the map size.
  30959. *
  30960. * It does not account for the light projection as it was having too much
  30961. * instability during the light setup or during light position changes.
  30962. *
  30963. * Only valid if useContactHardeningShadow is true.
  30964. */
  30965. /**
  30966. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30967. * Using a ratio helps keeping shape stability independently of the map size.
  30968. *
  30969. * It does not account for the light projection as it was having too much
  30970. * instability during the light setup or during light position changes.
  30971. *
  30972. * Only valid if useContactHardeningShadow is true.
  30973. */
  30974. contactHardeningLightSizeUVRatio: number;
  30975. private _darkness;
  30976. /**
  30977. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  30978. * 0 means strongest and 1 would means no shadow.
  30979. * @returns the darkness.
  30980. */
  30981. getDarkness(): number;
  30982. /**
  30983. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  30984. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  30985. * @returns the shadow generator allowing fluent coding.
  30986. */
  30987. setDarkness(darkness: number): ShadowGenerator;
  30988. private _transparencyShadow;
  30989. /**
  30990. * Sets the ability to have transparent shadow (boolean).
  30991. * @param transparent True if transparent else False
  30992. * @returns the shadow generator allowing fluent coding
  30993. */
  30994. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  30995. private _shadowMap;
  30996. private _shadowMap2;
  30997. /**
  30998. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30999. * @returns The render target texture if present otherwise, null
  31000. */
  31001. getShadowMap(): Nullable<RenderTargetTexture>;
  31002. /**
  31003. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  31004. * @returns The render target texture if the shadow map is present otherwise, null
  31005. */
  31006. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  31007. /**
  31008. * Helper function to add a mesh and its descendants to the list of shadow casters.
  31009. * @param mesh Mesh to add
  31010. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  31011. * @returns the Shadow Generator itself
  31012. */
  31013. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  31014. /**
  31015. * Helper function to remove a mesh and its descendants from the list of shadow casters
  31016. * @param mesh Mesh to remove
  31017. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  31018. * @returns the Shadow Generator itself
  31019. */
  31020. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  31021. /**
  31022. * Controls the extent to which the shadows fade out at the edge of the frustum
  31023. * Used only by directionals and spots
  31024. */
  31025. frustumEdgeFalloff: number;
  31026. private _light;
  31027. /**
  31028. * Returns the associated light object.
  31029. * @returns the light generating the shadow
  31030. */
  31031. getLight(): IShadowLight;
  31032. /**
  31033. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  31034. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  31035. * It might on the other hand introduce peter panning.
  31036. */
  31037. forceBackFacesOnly: boolean;
  31038. private _scene;
  31039. private _lightDirection;
  31040. private _effect;
  31041. private _viewMatrix;
  31042. private _projectionMatrix;
  31043. private _transformMatrix;
  31044. private _cachedPosition;
  31045. private _cachedDirection;
  31046. private _cachedDefines;
  31047. private _currentRenderID;
  31048. private _boxBlurPostprocess;
  31049. private _kernelBlurXPostprocess;
  31050. private _kernelBlurYPostprocess;
  31051. private _blurPostProcesses;
  31052. private _mapSize;
  31053. private _currentFaceIndex;
  31054. private _currentFaceIndexCache;
  31055. private _textureType;
  31056. private _defaultTextureMatrix;
  31057. /**
  31058. * Creates a ShadowGenerator object.
  31059. * A ShadowGenerator is the required tool to use the shadows.
  31060. * Each light casting shadows needs to use its own ShadowGenerator.
  31061. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  31062. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  31063. * @param light The light object generating the shadows.
  31064. * @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.
  31065. */
  31066. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  31067. private _initializeGenerator();
  31068. private _initializeShadowMap();
  31069. private _initializeBlurRTTAndPostProcesses();
  31070. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  31071. private _renderSubMeshForShadowMap(subMesh);
  31072. private _applyFilterValues();
  31073. /**
  31074. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31075. * @param onCompiled Callback triggered at the and of the effects compilation
  31076. * @param options Sets of optional options forcing the compilation with different modes
  31077. */
  31078. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  31079. useInstances: boolean;
  31080. }>): void;
  31081. /**
  31082. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31083. * @param options Sets of optional options forcing the compilation with different modes
  31084. * @returns A promise that resolves when the compilation completes
  31085. */
  31086. forceCompilationAsync(options?: Partial<{
  31087. useInstances: boolean;
  31088. }>): Promise<void>;
  31089. /**
  31090. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  31091. * @param subMesh The submesh we want to render in the shadow map
  31092. * @param useInstances Defines wether will draw in the map using instances
  31093. * @returns true if ready otherwise, false
  31094. */
  31095. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  31096. /**
  31097. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  31098. * @param defines Defines of the material we want to update
  31099. * @param lightIndex Index of the light in the enabled light list of the material
  31100. */
  31101. prepareDefines(defines: any, lightIndex: number): void;
  31102. /**
  31103. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  31104. * defined in the generator but impacting the effect).
  31105. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  31106. * @param effect The effect we are binfing the information for
  31107. */
  31108. bindShadowLight(lightIndex: string, effect: Effect): void;
  31109. /**
  31110. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  31111. * (eq to shadow prjection matrix * light transform matrix)
  31112. * @returns The transform matrix used to create the shadow map
  31113. */
  31114. getTransformMatrix(): Matrix;
  31115. /**
  31116. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  31117. * Cube and 2D textures for instance.
  31118. */
  31119. recreateShadowMap(): void;
  31120. private _disposeBlurPostProcesses();
  31121. private _disposeRTTandPostProcesses();
  31122. /**
  31123. * Disposes the ShadowGenerator.
  31124. * Returns nothing.
  31125. */
  31126. dispose(): void;
  31127. /**
  31128. * Serializes the shadow generator setup to a json object.
  31129. * @returns The serialized JSON object
  31130. */
  31131. serialize(): any;
  31132. /**
  31133. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  31134. * @param parsedShadowGenerator The JSON object to parse
  31135. * @param scene The scene to create the shadow map for
  31136. * @returns The parsed shadow generator
  31137. */
  31138. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  31139. }
  31140. }
  31141. declare module BABYLON {
  31142. }
  31143. declare module BABYLON {
  31144. /**
  31145. * Background material used to create an efficient environement around your scene.
  31146. */
  31147. class BackgroundMaterial extends PushMaterial {
  31148. /**
  31149. * Standard reflectance value at parallel view angle.
  31150. */
  31151. static StandardReflectance0: number;
  31152. /**
  31153. * Standard reflectance value at grazing angle.
  31154. */
  31155. static StandardReflectance90: number;
  31156. protected _primaryColor: Color3;
  31157. /**
  31158. * Key light Color (multiply against the environement texture)
  31159. */
  31160. primaryColor: Color3;
  31161. protected __perceptualColor: Nullable<Color3>;
  31162. /**
  31163. * Experimental Internal Use Only.
  31164. *
  31165. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  31166. * This acts as a helper to set the primary color to a more "human friendly" value.
  31167. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  31168. * output color as close as possible from the chosen value.
  31169. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  31170. * part of lighting setup.)
  31171. */
  31172. _perceptualColor: Nullable<Color3>;
  31173. protected _primaryColorShadowLevel: float;
  31174. /**
  31175. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  31176. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  31177. */
  31178. primaryColorShadowLevel: float;
  31179. protected _primaryColorHighlightLevel: float;
  31180. /**
  31181. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  31182. * The primary color is used at the level chosen to define what the white area would look.
  31183. */
  31184. primaryColorHighlightLevel: float;
  31185. protected _reflectionTexture: Nullable<BaseTexture>;
  31186. /**
  31187. * Reflection Texture used in the material.
  31188. * Should be author in a specific way for the best result (refer to the documentation).
  31189. */
  31190. reflectionTexture: Nullable<BaseTexture>;
  31191. protected _reflectionBlur: float;
  31192. /**
  31193. * Reflection Texture level of blur.
  31194. *
  31195. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  31196. * texture twice.
  31197. */
  31198. reflectionBlur: float;
  31199. protected _diffuseTexture: Nullable<BaseTexture>;
  31200. /**
  31201. * Diffuse Texture used in the material.
  31202. * Should be author in a specific way for the best result (refer to the documentation).
  31203. */
  31204. diffuseTexture: Nullable<BaseTexture>;
  31205. protected _shadowLights: Nullable<IShadowLight[]>;
  31206. /**
  31207. * Specify the list of lights casting shadow on the material.
  31208. * All scene shadow lights will be included if null.
  31209. */
  31210. shadowLights: Nullable<IShadowLight[]>;
  31211. protected _shadowLevel: float;
  31212. /**
  31213. * Helps adjusting the shadow to a softer level if required.
  31214. * 0 means black shadows and 1 means no shadows.
  31215. */
  31216. shadowLevel: float;
  31217. protected _sceneCenter: Vector3;
  31218. /**
  31219. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  31220. * It is usually zero but might be interesting to modify according to your setup.
  31221. */
  31222. sceneCenter: Vector3;
  31223. protected _opacityFresnel: boolean;
  31224. /**
  31225. * This helps specifying that the material is falling off to the sky box at grazing angle.
  31226. * This helps ensuring a nice transition when the camera goes under the ground.
  31227. */
  31228. opacityFresnel: boolean;
  31229. protected _reflectionFresnel: boolean;
  31230. /**
  31231. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  31232. * This helps adding a mirror texture on the ground.
  31233. */
  31234. reflectionFresnel: boolean;
  31235. protected _reflectionFalloffDistance: number;
  31236. /**
  31237. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  31238. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  31239. */
  31240. reflectionFalloffDistance: number;
  31241. protected _reflectionAmount: number;
  31242. /**
  31243. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  31244. */
  31245. reflectionAmount: number;
  31246. protected _reflectionReflectance0: number;
  31247. /**
  31248. * This specifies the weight of the reflection at grazing angle.
  31249. */
  31250. reflectionReflectance0: number;
  31251. protected _reflectionReflectance90: number;
  31252. /**
  31253. * This specifies the weight of the reflection at a perpendicular point of view.
  31254. */
  31255. reflectionReflectance90: number;
  31256. /**
  31257. * Sets the reflection reflectance fresnel values according to the default standard
  31258. * empirically know to work well :-)
  31259. */
  31260. reflectionStandardFresnelWeight: number;
  31261. protected _useRGBColor: boolean;
  31262. /**
  31263. * Helps to directly use the maps channels instead of their level.
  31264. */
  31265. useRGBColor: boolean;
  31266. protected _enableNoise: boolean;
  31267. /**
  31268. * This helps reducing the banding effect that could occur on the background.
  31269. */
  31270. enableNoise: boolean;
  31271. /**
  31272. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  31273. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  31274. * Recommended to be keep at 1.0 except for special cases.
  31275. */
  31276. fovMultiplier: number;
  31277. private _fovMultiplier;
  31278. /**
  31279. * Enable the FOV adjustment feature controlled by fovMultiplier.
  31280. */
  31281. useEquirectangularFOV: boolean;
  31282. private _maxSimultaneousLights;
  31283. /**
  31284. * Number of Simultaneous lights allowed on the material.
  31285. */
  31286. maxSimultaneousLights: int;
  31287. /**
  31288. * Default configuration related to image processing available in the Background Material.
  31289. */
  31290. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31291. /**
  31292. * Keep track of the image processing observer to allow dispose and replace.
  31293. */
  31294. private _imageProcessingObserver;
  31295. /**
  31296. * Attaches a new image processing configuration to the PBR Material.
  31297. * @param configuration (if null the scene configuration will be use)
  31298. */
  31299. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31300. /**
  31301. * Gets the image processing configuration used either in this material.
  31302. */
  31303. /**
  31304. * Sets the Default image processing configuration used either in the this material.
  31305. *
  31306. * If sets to null, the scene one is in use.
  31307. */
  31308. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  31309. /**
  31310. * Gets wether the color curves effect is enabled.
  31311. */
  31312. /**
  31313. * Sets wether the color curves effect is enabled.
  31314. */
  31315. cameraColorCurvesEnabled: boolean;
  31316. /**
  31317. * Gets wether the color grading effect is enabled.
  31318. */
  31319. /**
  31320. * Gets wether the color grading effect is enabled.
  31321. */
  31322. cameraColorGradingEnabled: boolean;
  31323. /**
  31324. * Gets wether tonemapping is enabled or not.
  31325. */
  31326. /**
  31327. * Sets wether tonemapping is enabled or not
  31328. */
  31329. cameraToneMappingEnabled: boolean;
  31330. /**
  31331. * The camera exposure used on this material.
  31332. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31333. * This corresponds to a photographic exposure.
  31334. */
  31335. /**
  31336. * The camera exposure used on this material.
  31337. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31338. * This corresponds to a photographic exposure.
  31339. */
  31340. cameraExposure: float;
  31341. /**
  31342. * Gets The camera contrast used on this material.
  31343. */
  31344. /**
  31345. * Sets The camera contrast used on this material.
  31346. */
  31347. cameraContrast: float;
  31348. /**
  31349. * Gets the Color Grading 2D Lookup Texture.
  31350. */
  31351. /**
  31352. * Sets the Color Grading 2D Lookup Texture.
  31353. */
  31354. cameraColorGradingTexture: Nullable<BaseTexture>;
  31355. /**
  31356. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31357. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31358. * 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;
  31359. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31360. */
  31361. /**
  31362. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31363. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31364. * 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;
  31365. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31366. */
  31367. cameraColorCurves: Nullable<ColorCurves>;
  31368. /**
  31369. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  31370. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  31371. */
  31372. switchToBGR: boolean;
  31373. private _renderTargets;
  31374. private _reflectionControls;
  31375. private _white;
  31376. private _primaryShadowColor;
  31377. private _primaryHighlightColor;
  31378. /**
  31379. * Instantiates a Background Material in the given scene
  31380. * @param name The friendly name of the material
  31381. * @param scene The scene to add the material to
  31382. */
  31383. constructor(name: string, scene: Scene);
  31384. /**
  31385. * The entire material has been created in order to prevent overdraw.
  31386. * @returns false
  31387. */
  31388. needAlphaTesting(): boolean;
  31389. /**
  31390. * The entire material has been created in order to prevent overdraw.
  31391. * @returns true if blending is enable
  31392. */
  31393. needAlphaBlending(): boolean;
  31394. /**
  31395. * Checks wether the material is ready to be rendered for a given mesh.
  31396. * @param mesh The mesh to render
  31397. * @param subMesh The submesh to check against
  31398. * @param useInstances Specify wether or not the material is used with instances
  31399. * @returns true if all the dependencies are ready (Textures, Effects...)
  31400. */
  31401. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31402. /**
  31403. * Compute the primary color according to the chosen perceptual color.
  31404. */
  31405. private _computePrimaryColorFromPerceptualColor();
  31406. /**
  31407. * Compute the highlights and shadow colors according to their chosen levels.
  31408. */
  31409. private _computePrimaryColors();
  31410. /**
  31411. * Build the uniform buffer used in the material.
  31412. */
  31413. buildUniformLayout(): void;
  31414. /**
  31415. * Unbind the material.
  31416. */
  31417. unbind(): void;
  31418. /**
  31419. * Bind only the world matrix to the material.
  31420. * @param world The world matrix to bind.
  31421. */
  31422. bindOnlyWorldMatrix(world: Matrix): void;
  31423. /**
  31424. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  31425. * @param world The world matrix to bind.
  31426. * @param subMesh The submesh to bind for.
  31427. */
  31428. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31429. /**
  31430. * Dispose the material.
  31431. * @param forceDisposeEffect Force disposal of the associated effect.
  31432. * @param forceDisposeTextures Force disposal of the associated textures.
  31433. */
  31434. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31435. /**
  31436. * Clones the material.
  31437. * @param name The cloned name.
  31438. * @returns The cloned material.
  31439. */
  31440. clone(name: string): BackgroundMaterial;
  31441. /**
  31442. * Serializes the current material to its JSON representation.
  31443. * @returns The JSON representation.
  31444. */
  31445. serialize(): any;
  31446. /**
  31447. * Gets the class name of the material
  31448. * @returns "BackgroundMaterial"
  31449. */
  31450. getClassName(): string;
  31451. /**
  31452. * Parse a JSON input to create back a background material.
  31453. * @param source The JSON data to parse
  31454. * @param scene The scene to create the parsed material in
  31455. * @param rootUrl The root url of the assets the material depends upon
  31456. * @returns the instantiated BackgroundMaterial.
  31457. */
  31458. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  31459. }
  31460. }
  31461. declare module BABYLON {
  31462. /**
  31463. * The Physically based material base class of BJS.
  31464. *
  31465. * This offers the main features of a standard PBR material.
  31466. * For more information, please refer to the documentation :
  31467. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  31468. */
  31469. abstract class PBRBaseMaterial extends PushMaterial {
  31470. /**
  31471. * Intensity of the direct lights e.g. the four lights available in your scene.
  31472. * This impacts both the direct diffuse and specular highlights.
  31473. */
  31474. protected _directIntensity: number;
  31475. /**
  31476. * Intensity of the emissive part of the material.
  31477. * This helps controlling the emissive effect without modifying the emissive color.
  31478. */
  31479. protected _emissiveIntensity: number;
  31480. /**
  31481. * Intensity of the environment e.g. how much the environment will light the object
  31482. * either through harmonics for rough material or through the refelction for shiny ones.
  31483. */
  31484. protected _environmentIntensity: number;
  31485. /**
  31486. * This is a special control allowing the reduction of the specular highlights coming from the
  31487. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  31488. */
  31489. protected _specularIntensity: number;
  31490. /**
  31491. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  31492. */
  31493. private _lightingInfos;
  31494. /**
  31495. * Debug Control allowing disabling the bump map on this material.
  31496. */
  31497. protected _disableBumpMap: boolean;
  31498. /**
  31499. * AKA Diffuse Texture in standard nomenclature.
  31500. */
  31501. protected _albedoTexture: BaseTexture;
  31502. /**
  31503. * AKA Occlusion Texture in other nomenclature.
  31504. */
  31505. protected _ambientTexture: BaseTexture;
  31506. /**
  31507. * AKA Occlusion Texture Intensity in other nomenclature.
  31508. */
  31509. protected _ambientTextureStrength: number;
  31510. /**
  31511. * Stores the alpha values in a texture.
  31512. */
  31513. protected _opacityTexture: BaseTexture;
  31514. /**
  31515. * Stores the reflection values in a texture.
  31516. */
  31517. protected _reflectionTexture: BaseTexture;
  31518. /**
  31519. * Stores the refraction values in a texture.
  31520. */
  31521. protected _refractionTexture: BaseTexture;
  31522. /**
  31523. * Stores the emissive values in a texture.
  31524. */
  31525. protected _emissiveTexture: BaseTexture;
  31526. /**
  31527. * AKA Specular texture in other nomenclature.
  31528. */
  31529. protected _reflectivityTexture: BaseTexture;
  31530. /**
  31531. * Used to switch from specular/glossiness to metallic/roughness workflow.
  31532. */
  31533. protected _metallicTexture: BaseTexture;
  31534. /**
  31535. * Specifies the metallic scalar of the metallic/roughness workflow.
  31536. * Can also be used to scale the metalness values of the metallic texture.
  31537. */
  31538. protected _metallic: number;
  31539. /**
  31540. * Specifies the roughness scalar of the metallic/roughness workflow.
  31541. * Can also be used to scale the roughness values of the metallic texture.
  31542. */
  31543. protected _roughness: number;
  31544. /**
  31545. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  31546. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  31547. */
  31548. protected _microSurfaceTexture: BaseTexture;
  31549. /**
  31550. * Stores surface normal data used to displace a mesh in a texture.
  31551. */
  31552. protected _bumpTexture: BaseTexture;
  31553. /**
  31554. * Stores the pre-calculated light information of a mesh in a texture.
  31555. */
  31556. protected _lightmapTexture: BaseTexture;
  31557. /**
  31558. * The color of a material in ambient lighting.
  31559. */
  31560. protected _ambientColor: Color3;
  31561. /**
  31562. * AKA Diffuse Color in other nomenclature.
  31563. */
  31564. protected _albedoColor: Color3;
  31565. /**
  31566. * AKA Specular Color in other nomenclature.
  31567. */
  31568. protected _reflectivityColor: Color3;
  31569. /**
  31570. * The color applied when light is reflected from a material.
  31571. */
  31572. protected _reflectionColor: Color3;
  31573. /**
  31574. * The color applied when light is emitted from a material.
  31575. */
  31576. protected _emissiveColor: Color3;
  31577. /**
  31578. * AKA Glossiness in other nomenclature.
  31579. */
  31580. protected _microSurface: number;
  31581. /**
  31582. * source material index of refraction (IOR)' / 'destination material IOR.
  31583. */
  31584. protected _indexOfRefraction: number;
  31585. /**
  31586. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  31587. */
  31588. protected _invertRefractionY: boolean;
  31589. /**
  31590. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  31591. * Materials half opaque for instance using refraction could benefit from this control.
  31592. */
  31593. protected _linkRefractionWithTransparency: boolean;
  31594. /**
  31595. * Specifies that the material will use the light map as a show map.
  31596. */
  31597. protected _useLightmapAsShadowmap: boolean;
  31598. /**
  31599. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  31600. * makes the reflect vector face the model (under horizon).
  31601. */
  31602. protected _useHorizonOcclusion: boolean;
  31603. /**
  31604. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  31605. * too much the area relying on ambient texture to define their ambient occlusion.
  31606. */
  31607. protected _useRadianceOcclusion: boolean;
  31608. /**
  31609. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  31610. */
  31611. protected _useAlphaFromAlbedoTexture: boolean;
  31612. /**
  31613. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  31614. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31615. */
  31616. protected _useSpecularOverAlpha: boolean;
  31617. /**
  31618. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  31619. */
  31620. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  31621. /**
  31622. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  31623. */
  31624. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  31625. /**
  31626. * Specifies if the metallic texture contains the roughness information in its green channel.
  31627. */
  31628. protected _useRoughnessFromMetallicTextureGreen: boolean;
  31629. /**
  31630. * Specifies if the metallic texture contains the metallness information in its blue channel.
  31631. */
  31632. protected _useMetallnessFromMetallicTextureBlue: boolean;
  31633. /**
  31634. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  31635. */
  31636. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  31637. /**
  31638. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  31639. */
  31640. protected _useAmbientInGrayScale: boolean;
  31641. /**
  31642. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  31643. * The material will try to infer what glossiness each pixel should be.
  31644. */
  31645. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  31646. /**
  31647. * BJS is using an harcoded light falloff based on a manually sets up range.
  31648. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  31649. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  31650. */
  31651. protected _usePhysicalLightFalloff: boolean;
  31652. /**
  31653. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31654. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31655. */
  31656. protected _useRadianceOverAlpha: boolean;
  31657. /**
  31658. * Allows using an object space normal map (instead of tangent space).
  31659. */
  31660. protected _useObjectSpaceNormalMap: boolean;
  31661. /**
  31662. * Allows using the bump map in parallax mode.
  31663. */
  31664. protected _useParallax: boolean;
  31665. /**
  31666. * Allows using the bump map in parallax occlusion mode.
  31667. */
  31668. protected _useParallaxOcclusion: boolean;
  31669. /**
  31670. * Controls the scale bias of the parallax mode.
  31671. */
  31672. protected _parallaxScaleBias: number;
  31673. /**
  31674. * If sets to true, disables all the lights affecting the material.
  31675. */
  31676. protected _disableLighting: boolean;
  31677. /**
  31678. * Number of Simultaneous lights allowed on the material.
  31679. */
  31680. protected _maxSimultaneousLights: number;
  31681. /**
  31682. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  31683. */
  31684. protected _invertNormalMapX: boolean;
  31685. /**
  31686. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  31687. */
  31688. protected _invertNormalMapY: boolean;
  31689. /**
  31690. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31691. */
  31692. protected _twoSidedLighting: boolean;
  31693. /**
  31694. * Defines the alpha limits in alpha test mode.
  31695. */
  31696. protected _alphaCutOff: number;
  31697. /**
  31698. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  31699. */
  31700. protected _forceAlphaTest: boolean;
  31701. /**
  31702. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  31703. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  31704. */
  31705. protected _useAlphaFresnel: boolean;
  31706. /**
  31707. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  31708. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  31709. */
  31710. protected _useLinearAlphaFresnel: boolean;
  31711. /**
  31712. * The transparency mode of the material.
  31713. */
  31714. protected _transparencyMode: Nullable<number>;
  31715. /**
  31716. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  31717. * from cos thetav and roughness:
  31718. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  31719. */
  31720. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  31721. /**
  31722. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  31723. */
  31724. protected _forceIrradianceInFragment: boolean;
  31725. /**
  31726. * Force normal to face away from face.
  31727. */
  31728. protected _forceNormalForward: boolean;
  31729. /**
  31730. * Enables specular anti aliasing in the PBR shader.
  31731. * It will both interacts on the Geometry for analytical and IBL lighting.
  31732. * It also prefilter the roughness map based on the bump values.
  31733. */
  31734. protected _enableSpecularAntiAliasing: boolean;
  31735. /**
  31736. * Default configuration related to image processing available in the PBR Material.
  31737. */
  31738. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31739. /**
  31740. * Keep track of the image processing observer to allow dispose and replace.
  31741. */
  31742. private _imageProcessingObserver;
  31743. /**
  31744. * Attaches a new image processing configuration to the PBR Material.
  31745. * @param configuration
  31746. */
  31747. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31748. /**
  31749. * Stores the available render targets.
  31750. */
  31751. private _renderTargets;
  31752. /**
  31753. * Sets the global ambient color for the material used in lighting calculations.
  31754. */
  31755. private _globalAmbientColor;
  31756. /**
  31757. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  31758. */
  31759. private _useLogarithmicDepth;
  31760. /**
  31761. * If set to true, no lighting calculations will be applied.
  31762. */
  31763. private _unlit;
  31764. /**
  31765. * Instantiates a new PBRMaterial instance.
  31766. *
  31767. * @param name The material name
  31768. * @param scene The scene the material will be use in.
  31769. */
  31770. constructor(name: string, scene: Scene);
  31771. /**
  31772. * Gets the name of the material class.
  31773. */
  31774. getClassName(): string;
  31775. /**
  31776. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  31777. */
  31778. /**
  31779. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  31780. */
  31781. useLogarithmicDepth: boolean;
  31782. /**
  31783. * Gets the current transparency mode.
  31784. */
  31785. /**
  31786. * Sets the transparency mode of the material.
  31787. */
  31788. transparencyMode: Nullable<number>;
  31789. /**
  31790. * Returns true if alpha blending should be disabled.
  31791. */
  31792. private readonly _disableAlphaBlending;
  31793. /**
  31794. * Specifies whether or not this material should be rendered in alpha blend mode.
  31795. */
  31796. needAlphaBlending(): boolean;
  31797. /**
  31798. * Specifies if the mesh will require alpha blending.
  31799. * @param mesh - BJS mesh.
  31800. */
  31801. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  31802. /**
  31803. * Specifies whether or not this material should be rendered in alpha test mode.
  31804. */
  31805. needAlphaTesting(): boolean;
  31806. /**
  31807. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  31808. */
  31809. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  31810. /**
  31811. * Gets the texture used for the alpha test.
  31812. */
  31813. getAlphaTestTexture(): BaseTexture;
  31814. /**
  31815. * Stores the reflectivity values based on metallic roughness workflow.
  31816. */
  31817. private static _scaledReflectivity;
  31818. /**
  31819. * Specifies that the submesh is ready to be used.
  31820. * @param mesh - BJS mesh.
  31821. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  31822. * @param useInstances - Specifies that instances should be used.
  31823. * @returns - boolean indicating that the submesh is ready or not.
  31824. */
  31825. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31826. /**
  31827. * Specifies if the material uses metallic roughness workflow.
  31828. * @returns boolean specifiying if the material uses metallic roughness workflow.
  31829. */
  31830. isMetallicWorkflow(): boolean;
  31831. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  31832. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  31833. /**
  31834. * Force shader compilation
  31835. */
  31836. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  31837. clipPlane: boolean;
  31838. }>): void;
  31839. /**
  31840. * Initializes the uniform buffer layout for the shader.
  31841. */
  31842. buildUniformLayout(): void;
  31843. /**
  31844. * Unbinds the textures.
  31845. */
  31846. unbind(): void;
  31847. /**
  31848. * Binds the submesh data.
  31849. * @param world - The world matrix.
  31850. * @param mesh - The BJS mesh.
  31851. * @param subMesh - A submesh of the BJS mesh.
  31852. */
  31853. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31854. /**
  31855. * Returns the animatable textures.
  31856. * @returns - Array of animatable textures.
  31857. */
  31858. getAnimatables(): IAnimatable[];
  31859. /**
  31860. * Returns the texture used for reflections.
  31861. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  31862. */
  31863. private _getReflectionTexture();
  31864. /**
  31865. * Returns the texture used for refraction or null if none is used.
  31866. * @returns - Refection texture if present. If no refraction texture and refraction
  31867. * is linked with transparency, returns environment texture. Otherwise, returns null.
  31868. */
  31869. private _getRefractionTexture();
  31870. /**
  31871. * Disposes the resources of the material.
  31872. * @param forceDisposeEffect - Forces the disposal of effects.
  31873. * @param forceDisposeTextures - Forces the disposal of all textures.
  31874. */
  31875. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31876. }
  31877. }
  31878. declare module BABYLON {
  31879. /**
  31880. * The Physically based simple base material of BJS.
  31881. *
  31882. * This enables better naming and convention enforcements on top of the pbrMaterial.
  31883. * It is used as the base class for both the specGloss and metalRough conventions.
  31884. */
  31885. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  31886. /**
  31887. * Number of Simultaneous lights allowed on the material.
  31888. */
  31889. maxSimultaneousLights: number;
  31890. /**
  31891. * If sets to true, disables all the lights affecting the material.
  31892. */
  31893. disableLighting: boolean;
  31894. /**
  31895. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  31896. */
  31897. environmentTexture: BaseTexture;
  31898. /**
  31899. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31900. */
  31901. invertNormalMapX: boolean;
  31902. /**
  31903. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31904. */
  31905. invertNormalMapY: boolean;
  31906. /**
  31907. * Normal map used in the model.
  31908. */
  31909. normalTexture: BaseTexture;
  31910. /**
  31911. * Emissivie color used to self-illuminate the model.
  31912. */
  31913. emissiveColor: Color3;
  31914. /**
  31915. * Emissivie texture used to self-illuminate the model.
  31916. */
  31917. emissiveTexture: BaseTexture;
  31918. /**
  31919. * Occlusion Channel Strenght.
  31920. */
  31921. occlusionStrength: number;
  31922. /**
  31923. * Occlusion Texture of the material (adding extra occlusion effects).
  31924. */
  31925. occlusionTexture: BaseTexture;
  31926. /**
  31927. * Defines the alpha limits in alpha test mode.
  31928. */
  31929. alphaCutOff: number;
  31930. /**
  31931. * Gets the current double sided mode.
  31932. */
  31933. /**
  31934. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31935. */
  31936. doubleSided: boolean;
  31937. lightmapTexture: BaseTexture;
  31938. useLightmapAsShadowmap: boolean;
  31939. /**
  31940. * Return the active textures of the material.
  31941. */
  31942. getActiveTextures(): BaseTexture[];
  31943. hasTexture(texture: BaseTexture): boolean;
  31944. /**
  31945. * Instantiates a new PBRMaterial instance.
  31946. *
  31947. * @param name The material name
  31948. * @param scene The scene the material will be use in.
  31949. */
  31950. constructor(name: string, scene: Scene);
  31951. getClassName(): string;
  31952. }
  31953. }
  31954. declare module BABYLON {
  31955. /**
  31956. * The Physically based material of BJS.
  31957. *
  31958. * This offers the main features of a standard PBR material.
  31959. * For more information, please refer to the documentation :
  31960. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  31961. */
  31962. class PBRMaterial extends PBRBaseMaterial {
  31963. private static _PBRMATERIAL_OPAQUE;
  31964. /**
  31965. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  31966. */
  31967. static readonly PBRMATERIAL_OPAQUE: number;
  31968. /**
  31969. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  31970. */
  31971. private static _PBRMATERIAL_ALPHATEST;
  31972. /**
  31973. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  31974. */
  31975. static readonly PBRMATERIAL_ALPHATEST: number;
  31976. /**
  31977. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31978. */
  31979. private static _PBRMATERIAL_ALPHABLEND;
  31980. /**
  31981. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31982. */
  31983. static readonly PBRMATERIAL_ALPHABLEND: number;
  31984. /**
  31985. * Represents the value for Alpha Test and Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31986. * They are also discarded below the alpha cutoff threshold to improve performances.
  31987. */
  31988. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  31989. /**
  31990. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31991. * They are also discarded below the alpha cutoff threshold to improve performances.
  31992. */
  31993. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  31994. /**
  31995. * Intensity of the direct lights e.g. the four lights available in your scene.
  31996. * This impacts both the direct diffuse and specular highlights.
  31997. */
  31998. directIntensity: number;
  31999. /**
  32000. * Intensity of the emissive part of the material.
  32001. * This helps controlling the emissive effect without modifying the emissive color.
  32002. */
  32003. emissiveIntensity: number;
  32004. /**
  32005. * Intensity of the environment e.g. how much the environment will light the object
  32006. * either through harmonics for rough material or through the refelction for shiny ones.
  32007. */
  32008. environmentIntensity: number;
  32009. /**
  32010. * This is a special control allowing the reduction of the specular highlights coming from the
  32011. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  32012. */
  32013. specularIntensity: number;
  32014. /**
  32015. * Debug Control allowing disabling the bump map on this material.
  32016. */
  32017. disableBumpMap: boolean;
  32018. /**
  32019. * AKA Diffuse Texture in standard nomenclature.
  32020. */
  32021. albedoTexture: BaseTexture;
  32022. /**
  32023. * AKA Occlusion Texture in other nomenclature.
  32024. */
  32025. ambientTexture: BaseTexture;
  32026. /**
  32027. * AKA Occlusion Texture Intensity in other nomenclature.
  32028. */
  32029. ambientTextureStrength: number;
  32030. /**
  32031. * Stores the alpha values in a texture.
  32032. */
  32033. opacityTexture: BaseTexture;
  32034. /**
  32035. * Stores the reflection values in a texture.
  32036. */
  32037. reflectionTexture: Nullable<BaseTexture>;
  32038. /**
  32039. * Stores the emissive values in a texture.
  32040. */
  32041. emissiveTexture: BaseTexture;
  32042. /**
  32043. * AKA Specular texture in other nomenclature.
  32044. */
  32045. reflectivityTexture: BaseTexture;
  32046. /**
  32047. * Used to switch from specular/glossiness to metallic/roughness workflow.
  32048. */
  32049. metallicTexture: BaseTexture;
  32050. /**
  32051. * Specifies the metallic scalar of the metallic/roughness workflow.
  32052. * Can also be used to scale the metalness values of the metallic texture.
  32053. */
  32054. metallic: number;
  32055. /**
  32056. * Specifies the roughness scalar of the metallic/roughness workflow.
  32057. * Can also be used to scale the roughness values of the metallic texture.
  32058. */
  32059. roughness: number;
  32060. /**
  32061. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  32062. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  32063. */
  32064. microSurfaceTexture: BaseTexture;
  32065. /**
  32066. * Stores surface normal data used to displace a mesh in a texture.
  32067. */
  32068. bumpTexture: BaseTexture;
  32069. /**
  32070. * Stores the pre-calculated light information of a mesh in a texture.
  32071. */
  32072. lightmapTexture: BaseTexture;
  32073. /**
  32074. * Stores the refracted light information in a texture.
  32075. */
  32076. refractionTexture: BaseTexture;
  32077. /**
  32078. * The color of a material in ambient lighting.
  32079. */
  32080. ambientColor: Color3;
  32081. /**
  32082. * AKA Diffuse Color in other nomenclature.
  32083. */
  32084. albedoColor: Color3;
  32085. /**
  32086. * AKA Specular Color in other nomenclature.
  32087. */
  32088. reflectivityColor: Color3;
  32089. /**
  32090. * The color reflected from the material.
  32091. */
  32092. reflectionColor: Color3;
  32093. /**
  32094. * The color emitted from the material.
  32095. */
  32096. emissiveColor: Color3;
  32097. /**
  32098. * AKA Glossiness in other nomenclature.
  32099. */
  32100. microSurface: number;
  32101. /**
  32102. * source material index of refraction (IOR)' / 'destination material IOR.
  32103. */
  32104. indexOfRefraction: number;
  32105. /**
  32106. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  32107. */
  32108. invertRefractionY: boolean;
  32109. /**
  32110. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  32111. * Materials half opaque for instance using refraction could benefit from this control.
  32112. */
  32113. linkRefractionWithTransparency: boolean;
  32114. useLightmapAsShadowmap: boolean;
  32115. /**
  32116. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  32117. */
  32118. useAlphaFromAlbedoTexture: boolean;
  32119. /**
  32120. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  32121. */
  32122. forceAlphaTest: boolean;
  32123. /**
  32124. * Defines the alpha limits in alpha test mode.
  32125. */
  32126. alphaCutOff: number;
  32127. /**
  32128. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  32129. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  32130. */
  32131. useSpecularOverAlpha: boolean;
  32132. /**
  32133. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  32134. */
  32135. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  32136. /**
  32137. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  32138. */
  32139. useRoughnessFromMetallicTextureAlpha: boolean;
  32140. /**
  32141. * Specifies if the metallic texture contains the roughness information in its green channel.
  32142. */
  32143. useRoughnessFromMetallicTextureGreen: boolean;
  32144. /**
  32145. * Specifies if the metallic texture contains the metallness information in its blue channel.
  32146. */
  32147. useMetallnessFromMetallicTextureBlue: boolean;
  32148. /**
  32149. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  32150. */
  32151. useAmbientOcclusionFromMetallicTextureRed: boolean;
  32152. /**
  32153. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  32154. */
  32155. useAmbientInGrayScale: boolean;
  32156. /**
  32157. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  32158. * The material will try to infer what glossiness each pixel should be.
  32159. */
  32160. useAutoMicroSurfaceFromReflectivityMap: boolean;
  32161. /**
  32162. * BJS is using an harcoded light falloff based on a manually sets up range.
  32163. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  32164. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  32165. */
  32166. usePhysicalLightFalloff: boolean;
  32167. /**
  32168. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  32169. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  32170. */
  32171. useRadianceOverAlpha: boolean;
  32172. /**
  32173. * Allows using an object space normal map (instead of tangent space).
  32174. */
  32175. useObjectSpaceNormalMap: boolean;
  32176. /**
  32177. * Allows using the bump map in parallax mode.
  32178. */
  32179. useParallax: boolean;
  32180. /**
  32181. * Allows using the bump map in parallax occlusion mode.
  32182. */
  32183. useParallaxOcclusion: boolean;
  32184. /**
  32185. * Controls the scale bias of the parallax mode.
  32186. */
  32187. parallaxScaleBias: number;
  32188. /**
  32189. * If sets to true, disables all the lights affecting the material.
  32190. */
  32191. disableLighting: boolean;
  32192. /**
  32193. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  32194. */
  32195. forceIrradianceInFragment: boolean;
  32196. /**
  32197. * Number of Simultaneous lights allowed on the material.
  32198. */
  32199. maxSimultaneousLights: number;
  32200. /**
  32201. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32202. */
  32203. invertNormalMapX: boolean;
  32204. /**
  32205. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32206. */
  32207. invertNormalMapY: boolean;
  32208. /**
  32209. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32210. */
  32211. twoSidedLighting: boolean;
  32212. /**
  32213. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32214. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  32215. */
  32216. useAlphaFresnel: boolean;
  32217. /**
  32218. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32219. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  32220. */
  32221. useLinearAlphaFresnel: boolean;
  32222. /**
  32223. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32224. * And/Or occlude the blended part.
  32225. */
  32226. environmentBRDFTexture: Nullable<BaseTexture>;
  32227. /**
  32228. * Force normal to face away from face.
  32229. */
  32230. forceNormalForward: boolean;
  32231. /**
  32232. * Enables specular anti aliasing in the PBR shader.
  32233. * It will both interacts on the Geometry for analytical and IBL lighting.
  32234. * It also prefilter the roughness map based on the bump values.
  32235. */
  32236. enableSpecularAntiAliasing: boolean;
  32237. /**
  32238. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  32239. * makes the reflect vector face the model (under horizon).
  32240. */
  32241. useHorizonOcclusion: boolean;
  32242. /**
  32243. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  32244. * too much the area relying on ambient texture to define their ambient occlusion.
  32245. */
  32246. useRadianceOcclusion: boolean;
  32247. /**
  32248. * If set to true, no lighting calculations will be applied.
  32249. */
  32250. unlit: boolean;
  32251. /**
  32252. * Gets the image processing configuration used either in this material.
  32253. */
  32254. /**
  32255. * Sets the Default image processing configuration used either in the this material.
  32256. *
  32257. * If sets to null, the scene one is in use.
  32258. */
  32259. imageProcessingConfiguration: ImageProcessingConfiguration;
  32260. /**
  32261. * Gets wether the color curves effect is enabled.
  32262. */
  32263. /**
  32264. * Sets wether the color curves effect is enabled.
  32265. */
  32266. cameraColorCurvesEnabled: boolean;
  32267. /**
  32268. * Gets wether the color grading effect is enabled.
  32269. */
  32270. /**
  32271. * Gets wether the color grading effect is enabled.
  32272. */
  32273. cameraColorGradingEnabled: boolean;
  32274. /**
  32275. * Gets wether tonemapping is enabled or not.
  32276. */
  32277. /**
  32278. * Sets wether tonemapping is enabled or not
  32279. */
  32280. cameraToneMappingEnabled: boolean;
  32281. /**
  32282. * The camera exposure used on this material.
  32283. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32284. * This corresponds to a photographic exposure.
  32285. */
  32286. /**
  32287. * The camera exposure used on this material.
  32288. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32289. * This corresponds to a photographic exposure.
  32290. */
  32291. cameraExposure: number;
  32292. /**
  32293. * Gets The camera contrast used on this material.
  32294. */
  32295. /**
  32296. * Sets The camera contrast used on this material.
  32297. */
  32298. cameraContrast: number;
  32299. /**
  32300. * Gets the Color Grading 2D Lookup Texture.
  32301. */
  32302. /**
  32303. * Sets the Color Grading 2D Lookup Texture.
  32304. */
  32305. cameraColorGradingTexture: Nullable<BaseTexture>;
  32306. /**
  32307. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32308. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32309. * 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;
  32310. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32311. */
  32312. /**
  32313. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32314. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32315. * 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;
  32316. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32317. */
  32318. cameraColorCurves: Nullable<ColorCurves>;
  32319. /**
  32320. * Instantiates a new PBRMaterial instance.
  32321. *
  32322. * @param name The material name
  32323. * @param scene The scene the material will be use in.
  32324. */
  32325. constructor(name: string, scene: Scene);
  32326. /**
  32327. * Returns the name of this material class.
  32328. */
  32329. getClassName(): string;
  32330. /**
  32331. * Returns an array of the actively used textures.
  32332. * @returns - Array of BaseTextures
  32333. */
  32334. getActiveTextures(): BaseTexture[];
  32335. /**
  32336. * Checks to see if a texture is used in the material.
  32337. * @param texture - Base texture to use.
  32338. * @returns - Boolean specifying if a texture is used in the material.
  32339. */
  32340. hasTexture(texture: BaseTexture): boolean;
  32341. /**
  32342. * Makes a duplicate of the current material.
  32343. * @param name - name to use for the new material.
  32344. */
  32345. clone(name: string): PBRMaterial;
  32346. /**
  32347. * Serializes this PBR Material.
  32348. * @returns - An object with the serialized material.
  32349. */
  32350. serialize(): any;
  32351. /**
  32352. * Parses a PBR Material from a serialized object.
  32353. * @param source - Serialized object.
  32354. * @param scene - BJS scene instance.
  32355. * @param rootUrl - url for the scene object
  32356. * @returns - PBRMaterial
  32357. */
  32358. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  32359. }
  32360. }
  32361. declare module BABYLON {
  32362. /**
  32363. * The PBR material of BJS following the metal roughness convention.
  32364. *
  32365. * This fits to the PBR convention in the GLTF definition:
  32366. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  32367. */
  32368. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  32369. /**
  32370. * The base color has two different interpretations depending on the value of metalness.
  32371. * When the material is a metal, the base color is the specific measured reflectance value
  32372. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  32373. * of the material.
  32374. */
  32375. baseColor: Color3;
  32376. /**
  32377. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  32378. * well as opacity information in the alpha channel.
  32379. */
  32380. baseTexture: BaseTexture;
  32381. /**
  32382. * Specifies the metallic scalar value of the material.
  32383. * Can also be used to scale the metalness values of the metallic texture.
  32384. */
  32385. metallic: number;
  32386. /**
  32387. * Specifies the roughness scalar value of the material.
  32388. * Can also be used to scale the roughness values of the metallic texture.
  32389. */
  32390. roughness: number;
  32391. /**
  32392. * Texture containing both the metallic value in the B channel and the
  32393. * roughness value in the G channel to keep better precision.
  32394. */
  32395. metallicRoughnessTexture: BaseTexture;
  32396. /**
  32397. * Instantiates a new PBRMetalRoughnessMaterial instance.
  32398. *
  32399. * @param name The material name
  32400. * @param scene The scene the material will be use in.
  32401. */
  32402. constructor(name: string, scene: Scene);
  32403. /**
  32404. * Return the currrent class name of the material.
  32405. */
  32406. getClassName(): string;
  32407. /**
  32408. * Return the active textures of the material.
  32409. */
  32410. getActiveTextures(): BaseTexture[];
  32411. /**
  32412. * Checks to see if a texture is used in the material.
  32413. * @param texture - Base texture to use.
  32414. * @returns - Boolean specifying if a texture is used in the material.
  32415. */
  32416. hasTexture(texture: BaseTexture): boolean;
  32417. /**
  32418. * Makes a duplicate of the current material.
  32419. * @param name - name to use for the new material.
  32420. */
  32421. clone(name: string): PBRMetallicRoughnessMaterial;
  32422. /**
  32423. * Serialize the material to a parsable JSON object.
  32424. */
  32425. serialize(): any;
  32426. /**
  32427. * Parses a JSON object correponding to the serialize function.
  32428. */
  32429. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  32430. }
  32431. }
  32432. declare module BABYLON {
  32433. /**
  32434. * The PBR material of BJS following the specular glossiness convention.
  32435. *
  32436. * This fits to the PBR convention in the GLTF definition:
  32437. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  32438. */
  32439. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  32440. /**
  32441. * Specifies the diffuse color of the material.
  32442. */
  32443. diffuseColor: Color3;
  32444. /**
  32445. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  32446. * channel.
  32447. */
  32448. diffuseTexture: BaseTexture;
  32449. /**
  32450. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  32451. */
  32452. specularColor: Color3;
  32453. /**
  32454. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  32455. */
  32456. glossiness: number;
  32457. /**
  32458. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  32459. */
  32460. specularGlossinessTexture: BaseTexture;
  32461. /**
  32462. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  32463. *
  32464. * @param name The material name
  32465. * @param scene The scene the material will be use in.
  32466. */
  32467. constructor(name: string, scene: Scene);
  32468. /**
  32469. * Return the currrent class name of the material.
  32470. */
  32471. getClassName(): string;
  32472. /**
  32473. * Return the active textures of the material.
  32474. */
  32475. getActiveTextures(): BaseTexture[];
  32476. /**
  32477. * Checks to see if a texture is used in the material.
  32478. * @param texture - Base texture to use.
  32479. * @returns - Boolean specifying if a texture is used in the material.
  32480. */
  32481. hasTexture(texture: BaseTexture): boolean;
  32482. /**
  32483. * Makes a duplicate of the current material.
  32484. * @param name - name to use for the new material.
  32485. */
  32486. clone(name: string): PBRSpecularGlossinessMaterial;
  32487. /**
  32488. * Serialize the material to a parsable JSON object.
  32489. */
  32490. serialize(): any;
  32491. /**
  32492. * Parses a JSON object correponding to the serialize function.
  32493. */
  32494. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  32495. }
  32496. }
  32497. declare module BABYLON {
  32498. class BaseTexture {
  32499. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32500. name: string;
  32501. private _hasAlpha;
  32502. hasAlpha: boolean;
  32503. getAlphaFromRGB: boolean;
  32504. level: number;
  32505. coordinatesIndex: number;
  32506. private _coordinatesMode;
  32507. /**
  32508. * How a texture is mapped.
  32509. *
  32510. * | Value | Type | Description |
  32511. * | ----- | ----------------------------------- | ----------- |
  32512. * | 0 | EXPLICIT_MODE | |
  32513. * | 1 | SPHERICAL_MODE | |
  32514. * | 2 | PLANAR_MODE | |
  32515. * | 3 | CUBIC_MODE | |
  32516. * | 4 | PROJECTION_MODE | |
  32517. * | 5 | SKYBOX_MODE | |
  32518. * | 6 | INVCUBIC_MODE | |
  32519. * | 7 | EQUIRECTANGULAR_MODE | |
  32520. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32521. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32522. */
  32523. coordinatesMode: number;
  32524. /**
  32525. * | Value | Type | Description |
  32526. * | ----- | ------------------ | ----------- |
  32527. * | 0 | CLAMP_ADDRESSMODE | |
  32528. * | 1 | WRAP_ADDRESSMODE | |
  32529. * | 2 | MIRROR_ADDRESSMODE | |
  32530. */
  32531. wrapU: number;
  32532. /**
  32533. * | Value | Type | Description |
  32534. * | ----- | ------------------ | ----------- |
  32535. * | 0 | CLAMP_ADDRESSMODE | |
  32536. * | 1 | WRAP_ADDRESSMODE | |
  32537. * | 2 | MIRROR_ADDRESSMODE | |
  32538. */
  32539. wrapV: number;
  32540. /**
  32541. * | Value | Type | Description |
  32542. * | ----- | ------------------ | ----------- |
  32543. * | 0 | CLAMP_ADDRESSMODE | |
  32544. * | 1 | WRAP_ADDRESSMODE | |
  32545. * | 2 | MIRROR_ADDRESSMODE | |
  32546. */
  32547. wrapR: number;
  32548. anisotropicFilteringLevel: number;
  32549. isCube: boolean;
  32550. is3D: boolean;
  32551. gammaSpace: boolean;
  32552. invertZ: boolean;
  32553. lodLevelInAlpha: boolean;
  32554. lodGenerationOffset: number;
  32555. lodGenerationScale: number;
  32556. isRenderTarget: boolean;
  32557. readonly uid: string;
  32558. toString(): string;
  32559. getClassName(): string;
  32560. animations: Animation[];
  32561. /**
  32562. * An event triggered when the texture is disposed.
  32563. */
  32564. onDisposeObservable: Observable<BaseTexture>;
  32565. private _onDisposeObserver;
  32566. onDispose: () => void;
  32567. delayLoadState: number;
  32568. private _scene;
  32569. _texture: Nullable<InternalTexture>;
  32570. private _uid;
  32571. readonly isBlocking: boolean;
  32572. constructor(scene: Nullable<Scene>);
  32573. getScene(): Nullable<Scene>;
  32574. getTextureMatrix(): Matrix;
  32575. getReflectionTextureMatrix(): Matrix;
  32576. getInternalTexture(): Nullable<InternalTexture>;
  32577. isReadyOrNotBlocking(): boolean;
  32578. isReady(): boolean;
  32579. getSize(): ISize;
  32580. getBaseSize(): ISize;
  32581. scale(ratio: number): void;
  32582. readonly canRescale: boolean;
  32583. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  32584. _rebuild(): void;
  32585. delayLoad(): void;
  32586. clone(): Nullable<BaseTexture>;
  32587. readonly textureType: number;
  32588. readonly textureFormat: number;
  32589. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  32590. releaseInternalTexture(): void;
  32591. sphericalPolynomial: Nullable<SphericalPolynomial>;
  32592. readonly _lodTextureHigh: Nullable<BaseTexture>;
  32593. readonly _lodTextureMid: Nullable<BaseTexture>;
  32594. readonly _lodTextureLow: Nullable<BaseTexture>;
  32595. dispose(): void;
  32596. serialize(): any;
  32597. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  32598. }
  32599. }
  32600. declare module BABYLON {
  32601. /**
  32602. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  32603. * It can help converting any input color in a desired output one. This can then be used to create effects
  32604. * from sepia, black and white to sixties or futuristic rendering...
  32605. *
  32606. * The only supported format is currently 3dl.
  32607. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  32608. */
  32609. class ColorGradingTexture extends BaseTexture {
  32610. /**
  32611. * The current texture matrix. (will always be identity in color grading texture)
  32612. */
  32613. private _textureMatrix;
  32614. /**
  32615. * The texture URL.
  32616. */
  32617. url: string;
  32618. /**
  32619. * Empty line regex stored for GC.
  32620. */
  32621. private static _noneEmptyLineRegex;
  32622. private _engine;
  32623. /**
  32624. * Instantiates a ColorGradingTexture from the following parameters.
  32625. *
  32626. * @param url The location of the color gradind data (currently only supporting 3dl)
  32627. * @param scene The scene the texture will be used in
  32628. */
  32629. constructor(url: string, scene: Scene);
  32630. /**
  32631. * Returns the texture matrix used in most of the material.
  32632. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  32633. */
  32634. getTextureMatrix(): Matrix;
  32635. /**
  32636. * Occurs when the file being loaded is a .3dl LUT file.
  32637. */
  32638. private load3dlTexture();
  32639. /**
  32640. * Starts the loading process of the texture.
  32641. */
  32642. private loadTexture();
  32643. /**
  32644. * Clones the color gradind texture.
  32645. */
  32646. clone(): ColorGradingTexture;
  32647. /**
  32648. * Called during delayed load for textures.
  32649. */
  32650. delayLoad(): void;
  32651. /**
  32652. * Parses a color grading texture serialized by Babylon.
  32653. * @param parsedTexture The texture information being parsedTexture
  32654. * @param scene The scene to load the texture in
  32655. * @param rootUrl The root url of the data assets to load
  32656. * @return A color gradind texture
  32657. */
  32658. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  32659. /**
  32660. * Serializes the LUT texture to json format.
  32661. */
  32662. serialize(): any;
  32663. }
  32664. }
  32665. declare module BABYLON {
  32666. class CubeTexture extends BaseTexture {
  32667. url: string;
  32668. coordinatesMode: number;
  32669. /**
  32670. * Gets or sets the center of the bounding box associated with the cube texture
  32671. * It must define where the camera used to render the texture was set
  32672. */
  32673. boundingBoxPosition: Vector3;
  32674. private _boundingBoxSize;
  32675. /**
  32676. * Gets or sets the size of the bounding box associated with the cube texture
  32677. * When defined, the cubemap will switch to local mode
  32678. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  32679. * @example https://www.babylonjs-playground.com/#RNASML
  32680. */
  32681. boundingBoxSize: Vector3;
  32682. protected _rotationY: number;
  32683. /**
  32684. * Gets texture matrix rotation angle around Y axis radians.
  32685. */
  32686. /**
  32687. * Sets texture matrix rotation angle around Y axis in radians.
  32688. */
  32689. rotationY: number;
  32690. private _noMipmap;
  32691. private _files;
  32692. private _extensions;
  32693. private _textureMatrix;
  32694. private _format;
  32695. private _prefiltered;
  32696. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  32697. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any): CubeTexture;
  32698. 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);
  32699. delayLoad(): void;
  32700. getReflectionTextureMatrix(): Matrix;
  32701. setReflectionTextureMatrix(value: Matrix): void;
  32702. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  32703. clone(): CubeTexture;
  32704. }
  32705. }
  32706. declare module BABYLON {
  32707. /**
  32708. * A class extending {BABYLON.Texture} allowing drawing on a texture
  32709. * @see http://doc.babylonjs.com/how_to/dynamictexture
  32710. */
  32711. class DynamicTexture extends Texture {
  32712. private _generateMipMaps;
  32713. private _canvas;
  32714. private _context;
  32715. private _engine;
  32716. /**
  32717. * Creates a {BABYLON.DynamicTexture}
  32718. * @param name defines the name of the texture
  32719. * @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
  32720. * @param scene defines the scene where you want the texture
  32721. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  32722. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  32723. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  32724. */
  32725. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  32726. /**
  32727. * Gets the current state of canRescale
  32728. */
  32729. readonly canRescale: boolean;
  32730. private _recreate(textureSize);
  32731. /**
  32732. * Scales the texture
  32733. * @param ratio the scale factor to apply to both width and height
  32734. */
  32735. scale(ratio: number): void;
  32736. /**
  32737. * Resizes the texture
  32738. * @param width the new width
  32739. * @param height the new height
  32740. */
  32741. scaleTo(width: number, height: number): void;
  32742. /**
  32743. * Gets the context of the canvas used by the texture
  32744. * @returns the canvas context of the dynamic texture
  32745. */
  32746. getContext(): CanvasRenderingContext2D;
  32747. /**
  32748. * Clears the texture
  32749. */
  32750. clear(): void;
  32751. /**
  32752. * Updates the texture
  32753. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  32754. */
  32755. update(invertY?: boolean): void;
  32756. /**
  32757. * Draws text onto the texture
  32758. * @param text defines the text to be drawn
  32759. * @param x defines the placement of the text from the left
  32760. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  32761. * @param font defines the font to be used with font-style, font-size, font-name
  32762. * @param color defines the color used for the text
  32763. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  32764. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  32765. * @param update defines whether texture is immediately update (default is true)
  32766. */
  32767. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  32768. /**
  32769. * Clones the texture
  32770. * @returns the clone of the texture.
  32771. */
  32772. clone(): DynamicTexture;
  32773. /** @hidden */
  32774. _rebuild(): void;
  32775. }
  32776. }
  32777. declare module BABYLON {
  32778. /**
  32779. * This represents a texture coming from an HDR input.
  32780. *
  32781. * The only supported format is currently panorama picture stored in RGBE format.
  32782. * Example of such files can be found on HDRLib: http://hdrlib.com/
  32783. */
  32784. class HDRCubeTexture extends BaseTexture {
  32785. private static _facesMapping;
  32786. private _generateHarmonics;
  32787. private _noMipmap;
  32788. private _textureMatrix;
  32789. private _size;
  32790. private _onLoad;
  32791. private _onError;
  32792. /**
  32793. * The texture URL.
  32794. */
  32795. url: string;
  32796. /**
  32797. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  32798. */
  32799. coordinatesMode: number;
  32800. protected _isBlocking: boolean;
  32801. /**
  32802. * Gets wether or not the texture is blocking during loading.
  32803. */
  32804. /**
  32805. * Sets wether or not the texture is blocking during loading.
  32806. */
  32807. isBlocking: boolean;
  32808. protected _rotationY: number;
  32809. /**
  32810. * Gets texture matrix rotation angle around Y axis radians.
  32811. */
  32812. /**
  32813. * Sets texture matrix rotation angle around Y axis in radians.
  32814. */
  32815. rotationY: number;
  32816. /**
  32817. * Gets or sets the center of the bounding box associated with the cube texture
  32818. * It must define where the camera used to render the texture was set
  32819. */
  32820. boundingBoxPosition: Vector3;
  32821. private _boundingBoxSize;
  32822. /**
  32823. * Gets or sets the size of the bounding box associated with the cube texture
  32824. * When defined, the cubemap will switch to local mode
  32825. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  32826. * @example https://www.babylonjs-playground.com/#RNASML
  32827. */
  32828. boundingBoxSize: Vector3;
  32829. /**
  32830. * Instantiates an HDRTexture from the following parameters.
  32831. *
  32832. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  32833. * @param scene The scene the texture will be used in
  32834. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  32835. * @param noMipmap Forces to not generate the mipmap if true
  32836. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  32837. * @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)
  32838. * @param reserved Reserved flag for internal use.
  32839. */
  32840. 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>);
  32841. /**
  32842. * Occurs when the file is raw .hdr file.
  32843. */
  32844. private loadTexture();
  32845. clone(): HDRCubeTexture;
  32846. delayLoad(): void;
  32847. getReflectionTextureMatrix(): Matrix;
  32848. setReflectionTextureMatrix(value: Matrix): void;
  32849. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  32850. serialize(): any;
  32851. }
  32852. }
  32853. declare module BABYLON {
  32854. /**
  32855. * Class used to store data associated with WebGL texture data for the engine
  32856. * This class should not be used directly
  32857. */
  32858. class InternalTexture implements IInternalTextureTracker {
  32859. /**
  32860. * The source of the texture data is unknown
  32861. */
  32862. static DATASOURCE_UNKNOWN: number;
  32863. /**
  32864. * Texture data comes from an URL
  32865. */
  32866. static DATASOURCE_URL: number;
  32867. /**
  32868. * Texture data is only used for temporary storage
  32869. */
  32870. static DATASOURCE_TEMP: number;
  32871. /**
  32872. * Texture data comes from raw data (ArrayBuffer)
  32873. */
  32874. static DATASOURCE_RAW: number;
  32875. /**
  32876. * Texture content is dynamic (video or dynamic texture)
  32877. */
  32878. static DATASOURCE_DYNAMIC: number;
  32879. /**
  32880. * Texture content is generated by rendering to it
  32881. */
  32882. static DATASOURCE_RENDERTARGET: number;
  32883. /**
  32884. * Texture content is part of a multi render target process
  32885. */
  32886. static DATASOURCE_MULTIRENDERTARGET: number;
  32887. /**
  32888. * Texture data comes from a cube data file
  32889. */
  32890. static DATASOURCE_CUBE: number;
  32891. /**
  32892. * Texture data comes from a raw cube data
  32893. */
  32894. static DATASOURCE_CUBERAW: number;
  32895. /**
  32896. * Texture data come from a prefiltered cube data file
  32897. */
  32898. static DATASOURCE_CUBEPREFILTERED: number;
  32899. /**
  32900. * Texture content is raw 3D data
  32901. */
  32902. static DATASOURCE_RAW3D: number;
  32903. /**
  32904. * Texture content is a depth texture
  32905. */
  32906. static DATASOURCE_DEPTHTEXTURE: number;
  32907. /**
  32908. * Defines if the texture is ready
  32909. */
  32910. isReady: boolean;
  32911. /**
  32912. * Defines if the texture is a cube texture
  32913. */
  32914. isCube: boolean;
  32915. /**
  32916. * Defines if the texture contains 3D data
  32917. */
  32918. is3D: boolean;
  32919. /**
  32920. * Gets the URL used to load this texture
  32921. */
  32922. url: string;
  32923. /**
  32924. * Gets the sampling mode of the texture
  32925. */
  32926. samplingMode: number;
  32927. /**
  32928. * Gets a boolean indicating if the texture needs mipmaps generation
  32929. */
  32930. generateMipMaps: boolean;
  32931. /**
  32932. * Gets the number of samples used by the texture (WebGL2+ only)
  32933. */
  32934. samples: number;
  32935. /**
  32936. * Gets the type of the texture
  32937. */
  32938. type: number;
  32939. /**
  32940. * Gets the format of the texture
  32941. */
  32942. format: number;
  32943. /**
  32944. * Observable called when the texture is loaded
  32945. */
  32946. onLoadedObservable: Observable<InternalTexture>;
  32947. /**
  32948. * Gets the width of the texture
  32949. */
  32950. width: number;
  32951. /**
  32952. * Gets the height of the texture
  32953. */
  32954. height: number;
  32955. /**
  32956. * Gets the depth of the texture
  32957. */
  32958. depth: number;
  32959. /**
  32960. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32961. */
  32962. baseWidth: number;
  32963. /**
  32964. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32965. */
  32966. baseHeight: number;
  32967. /**
  32968. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32969. */
  32970. baseDepth: number;
  32971. /**
  32972. * Gets a boolean indicating if the texture is inverted on Y axis
  32973. */
  32974. invertY: boolean;
  32975. /**
  32976. * Gets or set the previous tracker in the list
  32977. */
  32978. previous: Nullable<IInternalTextureTracker>;
  32979. /**
  32980. * Gets or set the next tracker in the list
  32981. */
  32982. next: Nullable<IInternalTextureTracker>;
  32983. /** @hidden */
  32984. _initialSlot: number;
  32985. /** @hidden */
  32986. _designatedSlot: number;
  32987. /** @hidden */
  32988. _dataSource: number;
  32989. /** @hidden */
  32990. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  32991. /** @hidden */
  32992. _bufferView: Nullable<ArrayBufferView>;
  32993. /** @hidden */
  32994. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32995. /** @hidden */
  32996. _size: number;
  32997. /** @hidden */
  32998. _extension: string;
  32999. /** @hidden */
  33000. _files: Nullable<string[]>;
  33001. /** @hidden */
  33002. _workingCanvas: HTMLCanvasElement;
  33003. /** @hidden */
  33004. _workingContext: CanvasRenderingContext2D;
  33005. /** @hidden */
  33006. _framebuffer: Nullable<WebGLFramebuffer>;
  33007. /** @hidden */
  33008. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33009. /** @hidden */
  33010. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33011. /** @hidden */
  33012. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33013. /** @hidden */
  33014. _attachments: Nullable<number[]>;
  33015. /** @hidden */
  33016. _cachedCoordinatesMode: Nullable<number>;
  33017. /** @hidden */
  33018. _cachedWrapU: Nullable<number>;
  33019. /** @hidden */
  33020. _cachedWrapV: Nullable<number>;
  33021. /** @hidden */
  33022. _cachedWrapR: Nullable<number>;
  33023. /** @hidden */
  33024. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33025. /** @hidden */
  33026. _isDisabled: boolean;
  33027. /** @hidden */
  33028. _compression: Nullable<string>;
  33029. /** @hidden */
  33030. _generateStencilBuffer: boolean;
  33031. /** @hidden */
  33032. _generateDepthBuffer: boolean;
  33033. /** @hidden */
  33034. _comparisonFunction: number;
  33035. /** @hidden */
  33036. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33037. /** @hidden */
  33038. _lodGenerationScale: number;
  33039. /** @hidden */
  33040. _lodGenerationOffset: number;
  33041. /** @hidden */
  33042. _lodTextureHigh: BaseTexture;
  33043. /** @hidden */
  33044. _lodTextureMid: BaseTexture;
  33045. /** @hidden */
  33046. _lodTextureLow: BaseTexture;
  33047. /** @hidden */
  33048. _webGLTexture: Nullable<WebGLTexture>;
  33049. /** @hidden */
  33050. _references: number;
  33051. private _engine;
  33052. /**
  33053. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  33054. */
  33055. readonly dataSource: number;
  33056. /**
  33057. * Creates a new InternalTexture
  33058. * @param engine defines the engine to use
  33059. * @param dataSource defines the type of data that will be used
  33060. */
  33061. constructor(engine: Engine, dataSource: number);
  33062. /**
  33063. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  33064. */
  33065. incrementReferences(): void;
  33066. /**
  33067. * Change the size of the texture (not the size of the content)
  33068. * @param width defines the new width
  33069. * @param height defines the new height
  33070. * @param depth defines the new depth (1 by default)
  33071. */
  33072. updateSize(width: int, height: int, depth?: int): void;
  33073. /** @hidden */
  33074. _rebuild(): void;
  33075. private _swapAndDie(target);
  33076. /**
  33077. * Dispose the current allocated resources
  33078. */
  33079. dispose(): void;
  33080. }
  33081. }
  33082. declare module BABYLON {
  33083. /**
  33084. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  33085. */
  33086. interface IInternalTextureTracker {
  33087. /**
  33088. * Gets or set the previous tracker in the list
  33089. */
  33090. previous: Nullable<IInternalTextureTracker>;
  33091. /**
  33092. * Gets or set the next tracker in the list
  33093. */
  33094. next: Nullable<IInternalTextureTracker>;
  33095. }
  33096. /**
  33097. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  33098. */
  33099. class DummyInternalTextureTracker {
  33100. /**
  33101. * Gets or set the previous tracker in the list
  33102. */
  33103. previous: Nullable<IInternalTextureTracker>;
  33104. /**
  33105. * Gets or set the next tracker in the list
  33106. */
  33107. next: Nullable<IInternalTextureTracker>;
  33108. }
  33109. }
  33110. declare module BABYLON {
  33111. class MirrorTexture extends RenderTargetTexture {
  33112. private scene;
  33113. mirrorPlane: Plane;
  33114. private _transformMatrix;
  33115. private _mirrorMatrix;
  33116. private _savedViewMatrix;
  33117. private _blurX;
  33118. private _blurY;
  33119. private _adaptiveBlurKernel;
  33120. private _blurKernelX;
  33121. private _blurKernelY;
  33122. private _blurRatio;
  33123. blurRatio: number;
  33124. adaptiveBlurKernel: number;
  33125. blurKernel: number;
  33126. blurKernelX: number;
  33127. blurKernelY: number;
  33128. private _autoComputeBlurKernel();
  33129. protected _onRatioRescale(): void;
  33130. private _updateGammaSpace();
  33131. private _imageProcessingConfigChangeObserver;
  33132. constructor(name: string, size: number | {
  33133. width: number;
  33134. height: number;
  33135. } | {
  33136. ratio: number;
  33137. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  33138. private _preparePostProcesses();
  33139. clone(): MirrorTexture;
  33140. serialize(): any;
  33141. dispose(): void;
  33142. }
  33143. }
  33144. declare module BABYLON {
  33145. interface IMultiRenderTargetOptions {
  33146. generateMipMaps?: boolean;
  33147. types?: number[];
  33148. samplingModes?: number[];
  33149. generateDepthBuffer?: boolean;
  33150. generateStencilBuffer?: boolean;
  33151. generateDepthTexture?: boolean;
  33152. textureCount?: number;
  33153. doNotChangeAspectRatio?: boolean;
  33154. defaultType?: number;
  33155. }
  33156. class MultiRenderTarget extends RenderTargetTexture {
  33157. private _internalTextures;
  33158. private _textures;
  33159. readonly isSupported: boolean;
  33160. private _multiRenderTargetOptions;
  33161. readonly textures: Texture[];
  33162. readonly depthTexture: Texture;
  33163. wrapU: number;
  33164. wrapV: number;
  33165. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  33166. _rebuild(): void;
  33167. private _createInternalTextures();
  33168. private _createTextures();
  33169. samples: number;
  33170. resize(size: any): void;
  33171. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  33172. dispose(): void;
  33173. releaseInternalTextures(): void;
  33174. }
  33175. }
  33176. declare module BABYLON {
  33177. class RawTexture extends Texture {
  33178. format: number;
  33179. private _engine;
  33180. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  33181. update(data: ArrayBufferView): void;
  33182. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33183. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33184. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33185. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33186. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33187. }
  33188. }
  33189. declare module BABYLON {
  33190. /**
  33191. * Class used to store 3D textures containing user data
  33192. */
  33193. class RawTexture3D extends Texture {
  33194. /** Gets or sets the texture format to use*/
  33195. format: number;
  33196. private _engine;
  33197. /**
  33198. * Create a new RawTexture3D
  33199. * @param data defines the data of the texture
  33200. * @param width defines the width of the texture
  33201. * @param height defines the height of the texture
  33202. * @param depth defines the depth of the texture
  33203. * @param format defines the texture format to use
  33204. * @param scene defines the hosting scene
  33205. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  33206. * @param invertY defines if texture must be stored with Y axis inverted
  33207. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  33208. */
  33209. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  33210. /** Gets or sets the texture format to use*/
  33211. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number);
  33212. /**
  33213. * Update the texture with new data
  33214. * @param data defines the data to store in the texture
  33215. */
  33216. update(data: ArrayBufferView): void;
  33217. }
  33218. }
  33219. declare module BABYLON {
  33220. /**
  33221. * Creates a refraction texture used by refraction channel of the standard material.
  33222. * @param name the texture name
  33223. * @param size size of the underlying texture
  33224. * @param scene root scene
  33225. */
  33226. class RefractionTexture extends RenderTargetTexture {
  33227. refractionPlane: Plane;
  33228. depth: number;
  33229. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  33230. clone(): RefractionTexture;
  33231. serialize(): any;
  33232. }
  33233. }
  33234. declare module BABYLON {
  33235. class RenderTargetTexture extends Texture {
  33236. isCube: boolean;
  33237. static _REFRESHRATE_RENDER_ONCE: number;
  33238. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  33239. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  33240. static readonly REFRESHRATE_RENDER_ONCE: number;
  33241. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  33242. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  33243. /**
  33244. * Use this predicate to dynamically define the list of mesh you want to render.
  33245. * If set, the renderList property will be overwritten.
  33246. */
  33247. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  33248. /**
  33249. * Use this list to define the list of mesh you want to render.
  33250. */
  33251. renderList: Nullable<Array<AbstractMesh>>;
  33252. renderParticles: boolean;
  33253. renderSprites: boolean;
  33254. coordinatesMode: number;
  33255. activeCamera: Nullable<Camera>;
  33256. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  33257. useCameraPostProcesses: boolean;
  33258. ignoreCameraViewport: boolean;
  33259. private _postProcessManager;
  33260. private _postProcesses;
  33261. private _resizeObserver;
  33262. /**
  33263. * An event triggered when the texture is unbind.
  33264. */
  33265. onBeforeBindObservable: Observable<RenderTargetTexture>;
  33266. /**
  33267. * An event triggered when the texture is unbind.
  33268. */
  33269. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  33270. private _onAfterUnbindObserver;
  33271. onAfterUnbind: () => void;
  33272. /**
  33273. * An event triggered before rendering the texture
  33274. */
  33275. onBeforeRenderObservable: Observable<number>;
  33276. private _onBeforeRenderObserver;
  33277. onBeforeRender: (faceIndex: number) => void;
  33278. /**
  33279. * An event triggered after rendering the texture
  33280. */
  33281. onAfterRenderObservable: Observable<number>;
  33282. private _onAfterRenderObserver;
  33283. onAfterRender: (faceIndex: number) => void;
  33284. /**
  33285. * An event triggered after the texture clear
  33286. */
  33287. onClearObservable: Observable<Engine>;
  33288. private _onClearObserver;
  33289. onClear: (Engine: Engine) => void;
  33290. clearColor: Color4;
  33291. protected _size: number | {
  33292. width: number;
  33293. height: number;
  33294. };
  33295. protected _initialSizeParameter: number | {
  33296. width: number;
  33297. height: number;
  33298. } | {
  33299. ratio: number;
  33300. };
  33301. protected _sizeRatio: Nullable<number>;
  33302. _generateMipMaps: boolean;
  33303. protected _renderingManager: RenderingManager;
  33304. _waitingRenderList: string[];
  33305. protected _doNotChangeAspectRatio: boolean;
  33306. protected _currentRefreshId: number;
  33307. protected _refreshRate: number;
  33308. protected _textureMatrix: Matrix;
  33309. protected _samples: number;
  33310. protected _renderTargetOptions: RenderTargetCreationOptions;
  33311. readonly renderTargetOptions: RenderTargetCreationOptions;
  33312. protected _engine: Engine;
  33313. protected _onRatioRescale(): void;
  33314. /**
  33315. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  33316. * It must define where the camera used to render the texture is set
  33317. */
  33318. boundingBoxPosition: Vector3;
  33319. private _boundingBoxSize;
  33320. /**
  33321. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  33322. * When defined, the cubemap will switch to local mode
  33323. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33324. * @example https://www.babylonjs-playground.com/#RNASML
  33325. */
  33326. boundingBoxSize: Vector3;
  33327. /**
  33328. * In case the RTT has been created with a depth texture, get the associated
  33329. * depth texture.
  33330. * Otherwise, return null.
  33331. */
  33332. depthStencilTexture: Nullable<InternalTexture>;
  33333. /**
  33334. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  33335. * or used a shadow, depth texture...
  33336. * @param name The friendly name of the texture
  33337. * @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)
  33338. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  33339. * @param generateMipMaps True if mip maps need to be generated after render.
  33340. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  33341. * @param type The type of the buffer in the RTT (int, half float, float...)
  33342. * @param isCube True if a cube texture needs to be created
  33343. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  33344. * @param generateDepthBuffer True to generate a depth buffer
  33345. * @param generateStencilBuffer True to generate a stencil buffer
  33346. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  33347. */
  33348. constructor(name: string, size: number | {
  33349. width: number;
  33350. height: number;
  33351. } | {
  33352. ratio: number;
  33353. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  33354. /**
  33355. * Creates a depth stencil texture.
  33356. * This is only available in WebGL 2 or with the depth texture extension available.
  33357. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  33358. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  33359. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  33360. */
  33361. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  33362. private _processSizeParameter(size);
  33363. samples: number;
  33364. resetRefreshCounter(): void;
  33365. refreshRate: number;
  33366. addPostProcess(postProcess: PostProcess): void;
  33367. clearPostProcesses(dispose?: boolean): void;
  33368. removePostProcess(postProcess: PostProcess): void;
  33369. _shouldRender(): boolean;
  33370. getRenderSize(): number;
  33371. getRenderWidth(): number;
  33372. getRenderHeight(): number;
  33373. readonly canRescale: boolean;
  33374. scale(ratio: number): void;
  33375. getReflectionTextureMatrix(): Matrix;
  33376. resize(size: number | {
  33377. width: number;
  33378. height: number;
  33379. } | {
  33380. ratio: number;
  33381. }): void;
  33382. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  33383. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  33384. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  33385. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  33386. /**
  33387. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33388. * This allowed control for front to back rendering or reversly depending of the special needs.
  33389. *
  33390. * @param renderingGroupId The rendering group id corresponding to its index
  33391. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33392. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33393. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33394. */
  33395. 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;
  33396. /**
  33397. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33398. *
  33399. * @param renderingGroupId The rendering group id corresponding to its index
  33400. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33401. */
  33402. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  33403. clone(): RenderTargetTexture;
  33404. serialize(): any;
  33405. disposeFramebufferObjects(): void;
  33406. dispose(): void;
  33407. _rebuild(): void;
  33408. /**
  33409. * Clear the info related to rendering groups preventing retention point in material dispose.
  33410. */
  33411. freeRenderingGroups(): void;
  33412. }
  33413. }
  33414. declare module BABYLON {
  33415. class Texture extends BaseTexture {
  33416. static NEAREST_SAMPLINGMODE: number;
  33417. static NEAREST_NEAREST_MIPLINEAR: number;
  33418. static BILINEAR_SAMPLINGMODE: number;
  33419. static LINEAR_LINEAR_MIPNEAREST: number;
  33420. static TRILINEAR_SAMPLINGMODE: number;
  33421. static LINEAR_LINEAR_MIPLINEAR: number;
  33422. static NEAREST_NEAREST_MIPNEAREST: number;
  33423. static NEAREST_LINEAR_MIPNEAREST: number;
  33424. static NEAREST_LINEAR_MIPLINEAR: number;
  33425. static NEAREST_LINEAR: number;
  33426. static NEAREST_NEAREST: number;
  33427. static LINEAR_NEAREST_MIPNEAREST: number;
  33428. static LINEAR_NEAREST_MIPLINEAR: number;
  33429. static LINEAR_LINEAR: number;
  33430. static LINEAR_NEAREST: number;
  33431. static EXPLICIT_MODE: number;
  33432. static SPHERICAL_MODE: number;
  33433. static PLANAR_MODE: number;
  33434. static CUBIC_MODE: number;
  33435. static PROJECTION_MODE: number;
  33436. static SKYBOX_MODE: number;
  33437. static INVCUBIC_MODE: number;
  33438. static EQUIRECTANGULAR_MODE: number;
  33439. static FIXED_EQUIRECTANGULAR_MODE: number;
  33440. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33441. static CLAMP_ADDRESSMODE: number;
  33442. static WRAP_ADDRESSMODE: number;
  33443. static MIRROR_ADDRESSMODE: number;
  33444. /**
  33445. * 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
  33446. */
  33447. static UseSerializedUrlIfAny: boolean;
  33448. url: Nullable<string>;
  33449. uOffset: number;
  33450. vOffset: number;
  33451. uScale: number;
  33452. vScale: number;
  33453. uAng: number;
  33454. vAng: number;
  33455. wAng: number;
  33456. /**
  33457. * Defines the center of rotation (U)
  33458. */
  33459. uRotationCenter: number;
  33460. /**
  33461. * Defines the center of rotation (V)
  33462. */
  33463. vRotationCenter: number;
  33464. /**
  33465. * Defines the center of rotation (W)
  33466. */
  33467. wRotationCenter: number;
  33468. readonly noMipmap: boolean;
  33469. private _noMipmap;
  33470. _invertY: boolean;
  33471. private _rowGenerationMatrix;
  33472. private _cachedTextureMatrix;
  33473. private _projectionModeMatrix;
  33474. private _t0;
  33475. private _t1;
  33476. private _t2;
  33477. private _cachedUOffset;
  33478. private _cachedVOffset;
  33479. private _cachedUScale;
  33480. private _cachedVScale;
  33481. private _cachedUAng;
  33482. private _cachedVAng;
  33483. private _cachedWAng;
  33484. private _cachedProjectionMatrixId;
  33485. private _cachedCoordinatesMode;
  33486. _samplingMode: number;
  33487. private _buffer;
  33488. private _deleteBuffer;
  33489. protected _format: Nullable<number>;
  33490. private _delayedOnLoad;
  33491. private _delayedOnError;
  33492. protected _onLoadObservable: Nullable<Observable<Texture>>;
  33493. protected _isBlocking: boolean;
  33494. isBlocking: boolean;
  33495. readonly samplingMode: number;
  33496. 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);
  33497. /**
  33498. * Update the url (and optional buffer) of this texture if url was null during construction.
  33499. * @param url the url of the texture
  33500. * @param buffer the buffer of the texture (defaults to null)
  33501. */
  33502. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  33503. delayLoad(): void;
  33504. updateSamplingMode(samplingMode: number): void;
  33505. private _prepareRowForTextureGeneration(x, y, z, t);
  33506. getTextureMatrix(): Matrix;
  33507. getReflectionTextureMatrix(): Matrix;
  33508. clone(): Texture;
  33509. readonly onLoadObservable: Observable<Texture>;
  33510. serialize(): any;
  33511. getClassName(): string;
  33512. dispose(): void;
  33513. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  33514. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  33515. 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;
  33516. }
  33517. }
  33518. declare module BABYLON {
  33519. /**
  33520. * Settings for finer control over video usage
  33521. */
  33522. interface VideoTextureSettings {
  33523. /**
  33524. * Applies `autoplay` to video, if specified
  33525. */
  33526. autoPlay?: boolean;
  33527. /**
  33528. * Applies `loop` to video, if specified
  33529. */
  33530. loop?: boolean;
  33531. /**
  33532. * Automatically updates internal texture from video at every frame in the render loop
  33533. */
  33534. autoUpdateTexture: boolean;
  33535. }
  33536. class VideoTexture extends Texture {
  33537. /**
  33538. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  33539. */
  33540. readonly autoUpdateTexture: boolean;
  33541. /**
  33542. * The video instance used by the texture internally
  33543. */
  33544. readonly video: HTMLVideoElement;
  33545. private _generateMipMaps;
  33546. private _engine;
  33547. private _stillImageCaptured;
  33548. /**
  33549. * Creates a video texture.
  33550. * Sample : https://doc.babylonjs.com/how_to/video_texture
  33551. * @param {string | null} name optional name, will detect from video source, if not defined
  33552. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  33553. * @param {BABYLON.Scene} scene is obviously the current scene.
  33554. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  33555. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  33556. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  33557. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  33558. */
  33559. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  33560. private _getName(src);
  33561. private _getVideo(src);
  33562. private _createInternalTexture;
  33563. private reset;
  33564. /**
  33565. * Internal method to initiate `update`.
  33566. */
  33567. _rebuild(): void;
  33568. /**
  33569. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  33570. */
  33571. update(): void;
  33572. /**
  33573. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  33574. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  33575. */
  33576. updateTexture(isVisible: boolean): void;
  33577. protected _updateInternalTexture: (e?: Event | undefined) => void;
  33578. /**
  33579. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  33580. * @param url New url.
  33581. */
  33582. updateURL(url: string): void;
  33583. dispose(): void;
  33584. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  33585. minWidth: number;
  33586. maxWidth: number;
  33587. minHeight: number;
  33588. maxHeight: number;
  33589. deviceId: string;
  33590. }): void;
  33591. }
  33592. }
  33593. declare var DracoDecoderModule: any;
  33594. declare var WebAssembly: any;
  33595. declare module BABYLON {
  33596. /**
  33597. * Configuration for Draco compression
  33598. */
  33599. interface IDracoCompressionConfiguration {
  33600. /**
  33601. * Configuration for the decoder.
  33602. */
  33603. decoder?: {
  33604. /**
  33605. * The url to the WebAssembly module.
  33606. */
  33607. wasmUrl?: string;
  33608. /**
  33609. * The url to the WebAssembly binary.
  33610. */
  33611. wasmBinaryUrl?: string;
  33612. /**
  33613. * The url to the fallback JavaScript module.
  33614. */
  33615. fallbackUrl?: string;
  33616. };
  33617. }
  33618. /**
  33619. * Draco compression (https://google.github.io/draco/)
  33620. */
  33621. class DracoCompression implements IDisposable {
  33622. private static _DecoderModulePromise;
  33623. /**
  33624. * The configuration.
  33625. */
  33626. static Configuration: IDracoCompressionConfiguration;
  33627. /**
  33628. * Returns true if the decoder is available.
  33629. */
  33630. static readonly DecoderAvailable: boolean;
  33631. /**
  33632. * Constructor
  33633. */
  33634. constructor();
  33635. /**
  33636. * Stop all async operations and release resources.
  33637. */
  33638. dispose(): void;
  33639. /**
  33640. * Decode Draco compressed mesh data to vertex data.
  33641. * @param data The array buffer view for the Draco compression data
  33642. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  33643. * @returns A promise that resolves with the decoded vertex data
  33644. */
  33645. decodeMeshAsync(data: ArrayBufferView, attributes: {
  33646. [kind: string]: number;
  33647. }): Promise<VertexData>;
  33648. private static _GetDecoderModule();
  33649. private static _LoadScriptAsync(url);
  33650. private static _LoadFileAsync(url);
  33651. }
  33652. }
  33653. declare module BABYLON {
  33654. /**
  33655. * Particle emitter emitting particles from the inside of a box.
  33656. * It emits the particles randomly between 2 given directions.
  33657. */
  33658. class BoxParticleEmitter implements IParticleEmitterType {
  33659. /**
  33660. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  33661. */
  33662. direction1: Vector3;
  33663. /**
  33664. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  33665. */
  33666. direction2: Vector3;
  33667. /**
  33668. * 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.
  33669. */
  33670. minEmitBox: Vector3;
  33671. /**
  33672. * 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.
  33673. */
  33674. maxEmitBox: Vector3;
  33675. /**
  33676. * Creates a new instance BoxParticleEmitter
  33677. */
  33678. constructor();
  33679. /**
  33680. * Called by the particle System when the direction is computed for the created particle.
  33681. * @param emitPower is the power of the particle (speed)
  33682. * @param worldMatrix is the world matrix of the particle system
  33683. * @param directionToUpdate is the direction vector to update with the result
  33684. * @param particle is the particle we are computed the direction for
  33685. */
  33686. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33687. /**
  33688. * Called by the particle System when the position is computed for the created particle.
  33689. * @param worldMatrix is the world matrix of the particle system
  33690. * @param positionToUpdate is the position vector to update with the result
  33691. * @param particle is the particle we are computed the position for
  33692. */
  33693. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33694. /**
  33695. * Clones the current emitter and returns a copy of it
  33696. * @returns the new emitter
  33697. */
  33698. clone(): BoxParticleEmitter;
  33699. /**
  33700. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33701. * @param effect defines the update shader
  33702. */
  33703. applyToShader(effect: Effect): void;
  33704. /**
  33705. * Returns a string to use to update the GPU particles update shader
  33706. * @returns a string containng the defines string
  33707. */
  33708. getEffectDefines(): string;
  33709. /**
  33710. * Returns the string "BoxEmitter"
  33711. * @returns a string containing the class name
  33712. */
  33713. getClassName(): string;
  33714. /**
  33715. * Serializes the particle system to a JSON object.
  33716. * @returns the JSON object
  33717. */
  33718. serialize(): any;
  33719. /**
  33720. * Parse properties from a JSON object
  33721. * @param serializationObject defines the JSON object
  33722. */
  33723. parse(serializationObject: any): void;
  33724. }
  33725. }
  33726. declare module BABYLON {
  33727. /**
  33728. * Particle emitter emitting particles from the inside of a cone.
  33729. * It emits the particles alongside the cone volume from the base to the particle.
  33730. * The emission direction might be randomized.
  33731. */
  33732. class ConeParticleEmitter implements IParticleEmitterType {
  33733. /**
  33734. * The radius of the emission cone.
  33735. */
  33736. angle: number;
  33737. /**
  33738. * The cone base angle.
  33739. */
  33740. directionRandomizer: number;
  33741. private _radius;
  33742. private _height;
  33743. /**
  33744. * Gets the radius of the emission cone.
  33745. */
  33746. /**
  33747. * Sets the radius of the emission cone.
  33748. */
  33749. radius: number;
  33750. /**
  33751. * Creates a new instance ConeParticleEmitter
  33752. * @param radius the radius of the emission cone (1 by default)
  33753. * @param angles the cone base angle (PI by default)
  33754. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  33755. */
  33756. constructor(radius?: number,
  33757. /**
  33758. * The radius of the emission cone.
  33759. */
  33760. angle?: number,
  33761. /**
  33762. * The cone base angle.
  33763. */
  33764. directionRandomizer?: number);
  33765. /**
  33766. * Called by the particle System when the direction is computed for the created particle.
  33767. * @param emitPower is the power of the particle (speed)
  33768. * @param worldMatrix is the world matrix of the particle system
  33769. * @param directionToUpdate is the direction vector to update with the result
  33770. * @param particle is the particle we are computed the direction for
  33771. */
  33772. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33773. /**
  33774. * Called by the particle System when the position is computed for the created particle.
  33775. * @param worldMatrix is the world matrix of the particle system
  33776. * @param positionToUpdate is the position vector to update with the result
  33777. * @param particle is the particle we are computed the position for
  33778. */
  33779. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33780. /**
  33781. * Clones the current emitter and returns a copy of it
  33782. * @returns the new emitter
  33783. */
  33784. clone(): ConeParticleEmitter;
  33785. /**
  33786. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33787. * @param effect defines the update shader
  33788. */
  33789. applyToShader(effect: Effect): void;
  33790. /**
  33791. * Returns a string to use to update the GPU particles update shader
  33792. * @returns a string containng the defines string
  33793. */
  33794. getEffectDefines(): string;
  33795. /**
  33796. * Returns the string "BoxEmitter"
  33797. * @returns a string containing the class name
  33798. */
  33799. getClassName(): string;
  33800. /**
  33801. * Serializes the particle system to a JSON object.
  33802. * @returns the JSON object
  33803. */
  33804. serialize(): any;
  33805. /**
  33806. * Parse properties from a JSON object
  33807. * @param serializationObject defines the JSON object
  33808. */
  33809. parse(serializationObject: any): void;
  33810. }
  33811. }
  33812. declare module BABYLON {
  33813. /**
  33814. * Particle emitter represents a volume emitting particles.
  33815. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  33816. */
  33817. interface IParticleEmitterType {
  33818. /**
  33819. * Called by the particle System when the direction is computed for the created particle.
  33820. * @param emitPower is the power of the particle (speed)
  33821. * @param worldMatrix is the world matrix of the particle system
  33822. * @param directionToUpdate is the direction vector to update with the result
  33823. * @param particle is the particle we are computed the direction for
  33824. */
  33825. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33826. /**
  33827. * Called by the particle System when the position is computed for the created particle.
  33828. * @param worldMatrix is the world matrix of the particle system
  33829. * @param positionToUpdate is the position vector to update with the result
  33830. * @param particle is the particle we are computed the position for
  33831. */
  33832. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33833. /**
  33834. * Clones the current emitter and returns a copy of it
  33835. * @returns the new emitter
  33836. */
  33837. clone(): IParticleEmitterType;
  33838. /**
  33839. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33840. * @param effect defines the update shader
  33841. */
  33842. applyToShader(effect: Effect): void;
  33843. /**
  33844. * Returns a string to use to update the GPU particles update shader
  33845. * @returns the effect defines string
  33846. */
  33847. getEffectDefines(): string;
  33848. /**
  33849. * Returns a string representing the class name
  33850. * @returns a string containing the class name
  33851. */
  33852. getClassName(): string;
  33853. /**
  33854. * Serializes the particle system to a JSON object.
  33855. * @returns the JSON object
  33856. */
  33857. serialize(): any;
  33858. /**
  33859. * Parse properties from a JSON object
  33860. * @param serializationObject defines the JSON object
  33861. */
  33862. parse(serializationObject: any): void;
  33863. }
  33864. }
  33865. declare module BABYLON {
  33866. /**
  33867. * Particle emitter emitting particles from the inside of a sphere.
  33868. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  33869. */
  33870. class SphereParticleEmitter implements IParticleEmitterType {
  33871. /**
  33872. * The radius of the emission sphere.
  33873. */
  33874. radius: number;
  33875. /**
  33876. * How much to randomize the particle direction [0-1].
  33877. */
  33878. directionRandomizer: number;
  33879. /**
  33880. * Creates a new instance SphereParticleEmitter
  33881. * @param radius the radius of the emission sphere (1 by default)
  33882. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  33883. */
  33884. constructor(
  33885. /**
  33886. * The radius of the emission sphere.
  33887. */
  33888. radius?: number,
  33889. /**
  33890. * How much to randomize the particle direction [0-1].
  33891. */
  33892. directionRandomizer?: number);
  33893. /**
  33894. * Called by the particle System when the direction is computed for the created particle.
  33895. * @param emitPower is the power of the particle (speed)
  33896. * @param worldMatrix is the world matrix of the particle system
  33897. * @param directionToUpdate is the direction vector to update with the result
  33898. * @param particle is the particle we are computed the direction for
  33899. */
  33900. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33901. /**
  33902. * Called by the particle System when the position is computed for the created particle.
  33903. * @param worldMatrix is the world matrix of the particle system
  33904. * @param positionToUpdate is the position vector to update with the result
  33905. * @param particle is the particle we are computed the position for
  33906. */
  33907. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33908. /**
  33909. * Clones the current emitter and returns a copy of it
  33910. * @returns the new emitter
  33911. */
  33912. clone(): SphereParticleEmitter;
  33913. /**
  33914. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33915. * @param effect defines the update shader
  33916. */
  33917. applyToShader(effect: Effect): void;
  33918. /**
  33919. * Returns a string to use to update the GPU particles update shader
  33920. * @returns a string containng the defines string
  33921. */
  33922. getEffectDefines(): string;
  33923. /**
  33924. * Returns the string "SphereParticleEmitter"
  33925. * @returns a string containing the class name
  33926. */
  33927. getClassName(): string;
  33928. /**
  33929. * Serializes the particle system to a JSON object.
  33930. * @returns the JSON object
  33931. */
  33932. serialize(): any;
  33933. /**
  33934. * Parse properties from a JSON object
  33935. * @param serializationObject defines the JSON object
  33936. */
  33937. parse(serializationObject: any): void;
  33938. }
  33939. /**
  33940. * Particle emitter emitting particles from the inside of a sphere.
  33941. * It emits the particles randomly between two vectors.
  33942. */
  33943. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  33944. /**
  33945. * The min limit of the emission direction.
  33946. */
  33947. direction1: Vector3;
  33948. /**
  33949. * The max limit of the emission direction.
  33950. */
  33951. direction2: Vector3;
  33952. /**
  33953. * Creates a new instance SphereDirectedParticleEmitter
  33954. * @param radius the radius of the emission sphere (1 by default)
  33955. * @param direction1 the min limit of the emission direction (up vector by default)
  33956. * @param direction2 the max limit of the emission direction (up vector by default)
  33957. */
  33958. constructor(radius?: number,
  33959. /**
  33960. * The min limit of the emission direction.
  33961. */
  33962. direction1?: Vector3,
  33963. /**
  33964. * The max limit of the emission direction.
  33965. */
  33966. direction2?: Vector3);
  33967. /**
  33968. * Called by the particle System when the direction is computed for the created particle.
  33969. * @param emitPower is the power of the particle (speed)
  33970. * @param worldMatrix is the world matrix of the particle system
  33971. * @param directionToUpdate is the direction vector to update with the result
  33972. * @param particle is the particle we are computed the direction for
  33973. */
  33974. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33975. /**
  33976. * Clones the current emitter and returns a copy of it
  33977. * @returns the new emitter
  33978. */
  33979. clone(): SphereDirectedParticleEmitter;
  33980. /**
  33981. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33982. * @param effect defines the update shader
  33983. */
  33984. applyToShader(effect: Effect): void;
  33985. /**
  33986. * Returns a string to use to update the GPU particles update shader
  33987. * @returns a string containng the defines string
  33988. */
  33989. getEffectDefines(): string;
  33990. /**
  33991. * Returns the string "SphereDirectedParticleEmitter"
  33992. * @returns a string containing the class name
  33993. */
  33994. getClassName(): string;
  33995. /**
  33996. * Serializes the particle system to a JSON object.
  33997. * @returns the JSON object
  33998. */
  33999. serialize(): any;
  34000. /**
  34001. * Parse properties from a JSON object
  34002. * @param serializationObject defines the JSON object
  34003. */
  34004. parse(serializationObject: any): void;
  34005. }
  34006. }
  34007. declare module BABYLON {
  34008. class CannonJSPlugin implements IPhysicsEnginePlugin {
  34009. private _useDeltaForWorldStep;
  34010. world: any;
  34011. name: string;
  34012. private _physicsMaterials;
  34013. private _fixedTimeStep;
  34014. BJSCANNON: any;
  34015. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  34016. setGravity(gravity: Vector3): void;
  34017. setTimeStep(timeStep: number): void;
  34018. getTimeStep(): number;
  34019. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  34020. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34021. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34022. generatePhysicsBody(impostor: PhysicsImpostor): void;
  34023. private _processChildMeshes(mainImpostor);
  34024. removePhysicsBody(impostor: PhysicsImpostor): void;
  34025. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  34026. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  34027. private _addMaterial(name, friction, restitution);
  34028. private _checkWithEpsilon(value);
  34029. private _createShape(impostor);
  34030. private _createHeightmap(object, pointDepth?);
  34031. private _minus90X;
  34032. private _plus90X;
  34033. private _tmpPosition;
  34034. private _tmpDeltaPosition;
  34035. private _tmpUnityRotation;
  34036. private _updatePhysicsBodyTransformation(impostor);
  34037. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  34038. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  34039. isSupported(): boolean;
  34040. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34041. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34042. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34043. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34044. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  34045. getBodyMass(impostor: PhysicsImpostor): number;
  34046. getBodyFriction(impostor: PhysicsImpostor): number;
  34047. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  34048. getBodyRestitution(impostor: PhysicsImpostor): number;
  34049. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  34050. sleepBody(impostor: PhysicsImpostor): void;
  34051. wakeUpBody(impostor: PhysicsImpostor): void;
  34052. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  34053. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  34054. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  34055. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  34056. getRadius(impostor: PhysicsImpostor): number;
  34057. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  34058. dispose(): void;
  34059. private _extendNamespace();
  34060. }
  34061. }
  34062. declare module BABYLON {
  34063. class OimoJSPlugin implements IPhysicsEnginePlugin {
  34064. world: any;
  34065. name: string;
  34066. BJSOIMO: any;
  34067. constructor(iterations?: number);
  34068. setGravity(gravity: Vector3): void;
  34069. setTimeStep(timeStep: number): void;
  34070. getTimeStep(): number;
  34071. private _tmpImpostorsArray;
  34072. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  34073. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34074. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34075. generatePhysicsBody(impostor: PhysicsImpostor): void;
  34076. private _tmpPositionVector;
  34077. removePhysicsBody(impostor: PhysicsImpostor): void;
  34078. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  34079. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  34080. isSupported(): boolean;
  34081. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  34082. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  34083. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34084. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34085. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34086. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34087. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  34088. getBodyMass(impostor: PhysicsImpostor): number;
  34089. getBodyFriction(impostor: PhysicsImpostor): number;
  34090. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  34091. getBodyRestitution(impostor: PhysicsImpostor): number;
  34092. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  34093. sleepBody(impostor: PhysicsImpostor): void;
  34094. wakeUpBody(impostor: PhysicsImpostor): void;
  34095. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  34096. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  34097. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34098. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  34099. getRadius(impostor: PhysicsImpostor): number;
  34100. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  34101. dispose(): void;
  34102. }
  34103. }
  34104. declare module BABYLON {
  34105. /**
  34106. * This represents a set of one or more post processes in Babylon.
  34107. * A post process can be used to apply a shader to a texture after it is rendered.
  34108. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  34109. */
  34110. class PostProcessRenderEffect {
  34111. private _postProcesses;
  34112. private _getPostProcesses;
  34113. private _singleInstance;
  34114. private _cameras;
  34115. private _indicesForCamera;
  34116. /**
  34117. * Name of the effect
  34118. */
  34119. _name: string;
  34120. /**
  34121. * Instantiates a post process render effect.
  34122. * A post process can be used to apply a shader to a texture after it is rendered.
  34123. * @param engine The engine the effect is tied to
  34124. * @param name The name of the effect
  34125. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  34126. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  34127. */
  34128. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  34129. /**
  34130. * Checks if all the post processes in the effect are supported.
  34131. */
  34132. readonly isSupported: boolean;
  34133. /**
  34134. * Updates the current state of the effect
  34135. */
  34136. _update(): void;
  34137. /**
  34138. * Attaches the effect on cameras
  34139. * @param cameras The camera to attach to.
  34140. */
  34141. _attachCameras(cameras: Camera): void;
  34142. /**
  34143. * Attaches the effect on cameras
  34144. * @param cameras The camera to attach to.
  34145. */
  34146. _attachCameras(cameras: Camera[]): void;
  34147. /**
  34148. * Detatches the effect on cameras
  34149. * @param cameras The camera to detatch from.
  34150. */
  34151. _detachCameras(cameras: Camera): void;
  34152. /**
  34153. * Detatches the effect on cameras
  34154. * @param cameras The camera to detatch from.
  34155. */
  34156. _detachCameras(cameras: Camera[]): void;
  34157. /**
  34158. * Enables the effect on given cameras
  34159. * @param cameras The camera to enable.
  34160. */
  34161. _enable(cameras: Camera): void;
  34162. /**
  34163. * Enables the effect on given cameras
  34164. * @param cameras The camera to enable.
  34165. */
  34166. _enable(cameras: Nullable<Camera[]>): void;
  34167. /**
  34168. * Disables the effect on the given cameras
  34169. * @param cameras The camera to disable.
  34170. */
  34171. _disable(cameras: Camera): void;
  34172. /**
  34173. * Disables the effect on the given cameras
  34174. * @param cameras The camera to disable.
  34175. */
  34176. _disable(cameras: Nullable<Camera[]>): void;
  34177. /**
  34178. * Gets a list of the post processes contained in the effect.
  34179. * @param camera The camera to get the post processes on.
  34180. * @returns The list of the post processes in the effect.
  34181. */
  34182. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  34183. }
  34184. }
  34185. declare module BABYLON {
  34186. class PostProcessRenderPipeline {
  34187. private engine;
  34188. private _renderEffects;
  34189. private _renderEffectsForIsolatedPass;
  34190. protected _cameras: Camera[];
  34191. _name: string;
  34192. constructor(engine: Engine, name: string);
  34193. getClassName(): string;
  34194. readonly isSupported: boolean;
  34195. addEffect(renderEffect: PostProcessRenderEffect): void;
  34196. _rebuild(): void;
  34197. _enableEffect(renderEffectName: string, cameras: Camera): void;
  34198. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  34199. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  34200. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  34201. _attachCameras(cameras: Camera, unique: boolean): void;
  34202. _attachCameras(cameras: Camera[], unique: boolean): void;
  34203. _detachCameras(cameras: Camera): void;
  34204. _detachCameras(cameras: Nullable<Camera[]>): void;
  34205. _update(): void;
  34206. _reset(): void;
  34207. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  34208. dispose(): void;
  34209. }
  34210. }
  34211. declare module BABYLON {
  34212. class PostProcessRenderPipelineManager {
  34213. private _renderPipelines;
  34214. constructor();
  34215. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  34216. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  34217. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  34218. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  34219. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  34220. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  34221. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  34222. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  34223. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  34224. update(): void;
  34225. _rebuild(): void;
  34226. dispose(): void;
  34227. }
  34228. }
  34229. declare module BABYLON {
  34230. /**
  34231. * Helper class dealing with the extraction of spherical polynomial dataArray
  34232. * from a cube map.
  34233. */
  34234. class CubeMapToSphericalPolynomialTools {
  34235. private static FileFaces;
  34236. /**
  34237. * Converts a texture to the according Spherical Polynomial data.
  34238. * This extracts the first 3 orders only as they are the only one used in the lighting.
  34239. *
  34240. * @param texture The texture to extract the information from.
  34241. * @return The Spherical Polynomial data.
  34242. */
  34243. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  34244. /**
  34245. * Converts a cubemap to the according Spherical Polynomial data.
  34246. * This extracts the first 3 orders only as they are the only one used in the lighting.
  34247. *
  34248. * @param cubeInfo The Cube map to extract the information from.
  34249. * @return The Spherical Polynomial data.
  34250. */
  34251. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  34252. }
  34253. }
  34254. declare module BABYLON {
  34255. /**
  34256. * Header information of HDR texture files.
  34257. */
  34258. interface HDRInfo {
  34259. /**
  34260. * The height of the texture in pixels.
  34261. */
  34262. height: number;
  34263. /**
  34264. * The width of the texture in pixels.
  34265. */
  34266. width: number;
  34267. /**
  34268. * The index of the beginning of the data in the binary file.
  34269. */
  34270. dataPosition: number;
  34271. }
  34272. /**
  34273. * This groups tools to convert HDR texture to native colors array.
  34274. */
  34275. class HDRTools {
  34276. private static Ldexp(mantissa, exponent);
  34277. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  34278. private static readStringLine(uint8array, startIndex);
  34279. /**
  34280. * Reads header information from an RGBE texture stored in a native array.
  34281. * More information on this format are available here:
  34282. * https://en.wikipedia.org/wiki/RGBE_image_format
  34283. *
  34284. * @param uint8array The binary file stored in native array.
  34285. * @return The header information.
  34286. */
  34287. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  34288. /**
  34289. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  34290. * This RGBE texture needs to store the information as a panorama.
  34291. *
  34292. * More information on this format are available here:
  34293. * https://en.wikipedia.org/wiki/RGBE_image_format
  34294. *
  34295. * @param buffer The binary file stored in an array buffer.
  34296. * @param size The expected size of the extracted cubemap.
  34297. * @return The Cube Map information.
  34298. */
  34299. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  34300. /**
  34301. * Returns the pixels data extracted from an RGBE texture.
  34302. * This pixels will be stored left to right up to down in the R G B order in one array.
  34303. *
  34304. * More information on this format are available here:
  34305. * https://en.wikipedia.org/wiki/RGBE_image_format
  34306. *
  34307. * @param uint8array The binary file stored in an array buffer.
  34308. * @param hdrInfo The header information of the file.
  34309. * @return The pixels data in RGB right to left up to down order.
  34310. */
  34311. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  34312. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  34313. }
  34314. }
  34315. declare module BABYLON {
  34316. /**
  34317. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  34318. */
  34319. interface CubeMapInfo {
  34320. /**
  34321. * The pixel array for the front face.
  34322. * This is stored in format, left to right, up to down format.
  34323. */
  34324. front: Nullable<ArrayBufferView>;
  34325. /**
  34326. * The pixel array for the back face.
  34327. * This is stored in format, left to right, up to down format.
  34328. */
  34329. back: Nullable<ArrayBufferView>;
  34330. /**
  34331. * The pixel array for the left face.
  34332. * This is stored in format, left to right, up to down format.
  34333. */
  34334. left: Nullable<ArrayBufferView>;
  34335. /**
  34336. * The pixel array for the right face.
  34337. * This is stored in format, left to right, up to down format.
  34338. */
  34339. right: Nullable<ArrayBufferView>;
  34340. /**
  34341. * The pixel array for the up face.
  34342. * This is stored in format, left to right, up to down format.
  34343. */
  34344. up: Nullable<ArrayBufferView>;
  34345. /**
  34346. * The pixel array for the down face.
  34347. * This is stored in format, left to right, up to down format.
  34348. */
  34349. down: Nullable<ArrayBufferView>;
  34350. /**
  34351. * The size of the cubemap stored.
  34352. *
  34353. * Each faces will be size * size pixels.
  34354. */
  34355. size: number;
  34356. /**
  34357. * The format of the texture.
  34358. *
  34359. * RGBA, RGB.
  34360. */
  34361. format: number;
  34362. /**
  34363. * The type of the texture data.
  34364. *
  34365. * UNSIGNED_INT, FLOAT.
  34366. */
  34367. type: number;
  34368. /**
  34369. * Specifies whether the texture is in gamma space.
  34370. */
  34371. gammaSpace: boolean;
  34372. }
  34373. /**
  34374. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  34375. */
  34376. class PanoramaToCubeMapTools {
  34377. private static FACE_FRONT;
  34378. private static FACE_BACK;
  34379. private static FACE_RIGHT;
  34380. private static FACE_LEFT;
  34381. private static FACE_DOWN;
  34382. private static FACE_UP;
  34383. /**
  34384. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  34385. *
  34386. * @param float32Array The source data.
  34387. * @param inputWidth The width of the input panorama.
  34388. * @param inputhHeight The height of the input panorama.
  34389. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  34390. * @return The cubemap data
  34391. */
  34392. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  34393. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  34394. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  34395. }
  34396. }
  34397. declare module BABYLON {
  34398. class CustomProceduralTexture extends ProceduralTexture {
  34399. private _animate;
  34400. private _time;
  34401. private _config;
  34402. private _texturePath;
  34403. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  34404. private loadJson(jsonUrl);
  34405. isReady(): boolean;
  34406. render(useCameraPostProcess?: boolean): void;
  34407. updateTextures(): void;
  34408. updateShaderUniforms(): void;
  34409. animate: boolean;
  34410. }
  34411. }
  34412. declare module BABYLON {
  34413. class ProceduralTexture extends Texture {
  34414. isCube: boolean;
  34415. private _size;
  34416. _generateMipMaps: boolean;
  34417. isEnabled: boolean;
  34418. private _currentRefreshId;
  34419. private _refreshRate;
  34420. onGenerated: () => void;
  34421. private _vertexBuffers;
  34422. private _indexBuffer;
  34423. private _effect;
  34424. private _uniforms;
  34425. private _samplers;
  34426. private _fragment;
  34427. _textures: {
  34428. [key: string]: Texture;
  34429. };
  34430. private _floats;
  34431. private _floatsArrays;
  34432. private _colors3;
  34433. private _colors4;
  34434. private _vectors2;
  34435. private _vectors3;
  34436. private _matrices;
  34437. private _fallbackTexture;
  34438. private _fallbackTextureUsed;
  34439. private _engine;
  34440. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  34441. private _createIndexBuffer();
  34442. _rebuild(): void;
  34443. reset(): void;
  34444. isReady(): boolean;
  34445. resetRefreshCounter(): void;
  34446. setFragment(fragment: any): void;
  34447. refreshRate: number;
  34448. _shouldRender(): boolean;
  34449. getRenderSize(): number;
  34450. resize(size: number, generateMipMaps: boolean): void;
  34451. private _checkUniform(uniformName);
  34452. setTexture(name: string, texture: Texture): ProceduralTexture;
  34453. setFloat(name: string, value: number): ProceduralTexture;
  34454. setFloats(name: string, value: number[]): ProceduralTexture;
  34455. setColor3(name: string, value: Color3): ProceduralTexture;
  34456. setColor4(name: string, value: Color4): ProceduralTexture;
  34457. setVector2(name: string, value: Vector2): ProceduralTexture;
  34458. setVector3(name: string, value: Vector3): ProceduralTexture;
  34459. setMatrix(name: string, value: Matrix): ProceduralTexture;
  34460. render(useCameraPostProcess?: boolean): void;
  34461. clone(): ProceduralTexture;
  34462. dispose(): void;
  34463. }
  34464. }
  34465. declare module BABYLON {
  34466. /**
  34467. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  34468. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  34469. */
  34470. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  34471. private _scene;
  34472. private _originalCameras;
  34473. /**
  34474. * ID of the sharpen post process,
  34475. */
  34476. private readonly SharpenPostProcessId;
  34477. /**
  34478. * ID of the image processing post process;
  34479. */
  34480. readonly ImageProcessingPostProcessId: string;
  34481. /**
  34482. * ID of the Fast Approximate Anti-Aliasing post process;
  34483. */
  34484. readonly FxaaPostProcessId: string;
  34485. /**
  34486. * ID of the chromatic aberration post process,
  34487. */
  34488. private readonly ChromaticAberrationPostProcessId;
  34489. /**
  34490. * ID of the grain post process
  34491. */
  34492. private readonly GrainPostProcessId;
  34493. /**
  34494. * Sharpen post process which will apply a sharpen convolution to enhance edges
  34495. */
  34496. sharpen: SharpenPostProcess;
  34497. private _sharpenEffect;
  34498. private bloom;
  34499. /**
  34500. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  34501. */
  34502. depthOfField: DepthOfFieldEffect;
  34503. /**
  34504. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  34505. */
  34506. fxaa: FxaaPostProcess;
  34507. /**
  34508. * Image post processing pass used to perform operations such as tone mapping or color grading.
  34509. */
  34510. imageProcessing: ImageProcessingPostProcess;
  34511. /**
  34512. * Chromatic aberration post process which will shift rgb colors in the image
  34513. */
  34514. chromaticAberration: ChromaticAberrationPostProcess;
  34515. private _chromaticAberrationEffect;
  34516. /**
  34517. * Grain post process which add noise to the image
  34518. */
  34519. grain: GrainPostProcess;
  34520. private _grainEffect;
  34521. /**
  34522. * Glow post process which adds a glow to emmisive areas of the image
  34523. */
  34524. private _glowLayer;
  34525. /**
  34526. * Animations which can be used to tweak settings over a period of time
  34527. */
  34528. animations: Animation[];
  34529. private _imageProcessingConfigurationObserver;
  34530. private _sharpenEnabled;
  34531. private _bloomEnabled;
  34532. private _depthOfFieldEnabled;
  34533. private _depthOfFieldBlurLevel;
  34534. private _fxaaEnabled;
  34535. private _imageProcessingEnabled;
  34536. private _defaultPipelineTextureType;
  34537. private _bloomScale;
  34538. private _chromaticAberrationEnabled;
  34539. private _grainEnabled;
  34540. private _buildAllowed;
  34541. /**
  34542. * Enable or disable the sharpen process from the pipeline
  34543. */
  34544. sharpenEnabled: boolean;
  34545. private _resizeObserver;
  34546. private _hardwareScaleLevel;
  34547. private _bloomKernel;
  34548. /**
  34549. * Specifies the size of the bloom blur kernel, relative to the final output size
  34550. */
  34551. bloomKernel: number;
  34552. /**
  34553. * Specifies the weight of the bloom in the final rendering
  34554. */
  34555. private _bloomWeight;
  34556. /**
  34557. * Specifies the luma threshold for the area that will be blurred by the bloom
  34558. */
  34559. private _bloomThreshold;
  34560. private _hdr;
  34561. /**
  34562. * The strength of the bloom.
  34563. */
  34564. bloomWeight: number;
  34565. /**
  34566. * The strength of the bloom.
  34567. */
  34568. bloomThreshold: number;
  34569. /**
  34570. * The scale of the bloom, lower value will provide better performance.
  34571. */
  34572. bloomScale: number;
  34573. /**
  34574. * Enable or disable the bloom from the pipeline
  34575. */
  34576. bloomEnabled: boolean;
  34577. private _rebuildBloom();
  34578. /**
  34579. * If the depth of field is enabled.
  34580. */
  34581. depthOfFieldEnabled: boolean;
  34582. /**
  34583. * Blur level of the depth of field effect. (Higher blur will effect performance)
  34584. */
  34585. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  34586. /**
  34587. * If the anti aliasing is enabled.
  34588. */
  34589. fxaaEnabled: boolean;
  34590. private _samples;
  34591. /**
  34592. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  34593. */
  34594. samples: number;
  34595. /**
  34596. * If image processing is enabled.
  34597. */
  34598. imageProcessingEnabled: boolean;
  34599. /**
  34600. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  34601. */
  34602. glowLayerEnabled: boolean;
  34603. /**
  34604. * Enable or disable the chromaticAberration process from the pipeline
  34605. */
  34606. chromaticAberrationEnabled: boolean;
  34607. /**
  34608. * Enable or disable the grain process from the pipeline
  34609. */
  34610. grainEnabled: boolean;
  34611. /**
  34612. * @constructor
  34613. * @param {string} name - The rendering pipeline name (default: "")
  34614. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  34615. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  34616. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  34617. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  34618. */
  34619. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  34620. /**
  34621. * Force the compilation of the entire pipeline.
  34622. */
  34623. prepare(): void;
  34624. private _hasCleared;
  34625. private _prevPostProcess;
  34626. private _prevPrevPostProcess;
  34627. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  34628. private _buildPipeline();
  34629. private _disposePostProcesses(disposeNonRecreated?);
  34630. /**
  34631. * Dispose of the pipeline and stop all post processes
  34632. */
  34633. dispose(): void;
  34634. /**
  34635. * Serialize the rendering pipeline (Used when exporting)
  34636. * @returns the serialized object
  34637. */
  34638. serialize(): any;
  34639. /**
  34640. * Parse the serialized pipeline
  34641. * @param source Source pipeline.
  34642. * @param scene The scene to load the pipeline to.
  34643. * @param rootUrl The URL of the serialized pipeline.
  34644. * @returns An instantiated pipeline from the serialized object.
  34645. */
  34646. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  34647. }
  34648. }
  34649. declare module BABYLON {
  34650. class LensRenderingPipeline extends PostProcessRenderPipeline {
  34651. /**
  34652. * The chromatic aberration PostProcess id in the pipeline
  34653. */
  34654. LensChromaticAberrationEffect: string;
  34655. /**
  34656. * The highlights enhancing PostProcess id in the pipeline
  34657. */
  34658. HighlightsEnhancingEffect: string;
  34659. /**
  34660. * The depth-of-field PostProcess id in the pipeline
  34661. */
  34662. LensDepthOfFieldEffect: string;
  34663. private _scene;
  34664. private _depthTexture;
  34665. private _grainTexture;
  34666. private _chromaticAberrationPostProcess;
  34667. private _highlightsPostProcess;
  34668. private _depthOfFieldPostProcess;
  34669. private _edgeBlur;
  34670. private _grainAmount;
  34671. private _chromaticAberration;
  34672. private _distortion;
  34673. private _highlightsGain;
  34674. private _highlightsThreshold;
  34675. private _dofDistance;
  34676. private _dofAperture;
  34677. private _dofDarken;
  34678. private _dofPentagon;
  34679. private _blurNoise;
  34680. /**
  34681. * @constructor
  34682. *
  34683. * Effect parameters are as follow:
  34684. * {
  34685. * chromatic_aberration: number; // from 0 to x (1 for realism)
  34686. * edge_blur: number; // from 0 to x (1 for realism)
  34687. * distortion: number; // from 0 to x (1 for realism)
  34688. * grain_amount: number; // from 0 to 1
  34689. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  34690. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  34691. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  34692. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  34693. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  34694. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  34695. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  34696. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  34697. * }
  34698. * Note: if an effect parameter is unset, effect is disabled
  34699. *
  34700. * @param {string} name - The rendering pipeline name
  34701. * @param {object} parameters - An object containing all parameters (see above)
  34702. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34703. * @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)
  34704. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34705. */
  34706. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  34707. setEdgeBlur(amount: number): void;
  34708. disableEdgeBlur(): void;
  34709. setGrainAmount(amount: number): void;
  34710. disableGrain(): void;
  34711. setChromaticAberration(amount: number): void;
  34712. disableChromaticAberration(): void;
  34713. setEdgeDistortion(amount: number): void;
  34714. disableEdgeDistortion(): void;
  34715. setFocusDistance(amount: number): void;
  34716. disableDepthOfField(): void;
  34717. setAperture(amount: number): void;
  34718. setDarkenOutOfFocus(amount: number): void;
  34719. enablePentagonBokeh(): void;
  34720. disablePentagonBokeh(): void;
  34721. enableNoiseBlur(): void;
  34722. disableNoiseBlur(): void;
  34723. setHighlightsGain(amount: number): void;
  34724. setHighlightsThreshold(amount: number): void;
  34725. disableHighlights(): void;
  34726. /**
  34727. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  34728. */
  34729. dispose(disableDepthRender?: boolean): void;
  34730. private _createChromaticAberrationPostProcess(ratio);
  34731. private _createHighlightsPostProcess(ratio);
  34732. private _createDepthOfFieldPostProcess(ratio);
  34733. private _createGrainTexture();
  34734. }
  34735. }
  34736. declare module BABYLON {
  34737. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  34738. /**
  34739. * The PassPostProcess id in the pipeline that contains the original scene color
  34740. */
  34741. SSAOOriginalSceneColorEffect: string;
  34742. /**
  34743. * The SSAO PostProcess id in the pipeline
  34744. */
  34745. SSAORenderEffect: string;
  34746. /**
  34747. * The horizontal blur PostProcess id in the pipeline
  34748. */
  34749. SSAOBlurHRenderEffect: string;
  34750. /**
  34751. * The vertical blur PostProcess id in the pipeline
  34752. */
  34753. SSAOBlurVRenderEffect: string;
  34754. /**
  34755. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  34756. */
  34757. SSAOCombineRenderEffect: string;
  34758. /**
  34759. * The output strength of the SSAO post-process. Default value is 1.0.
  34760. */
  34761. totalStrength: number;
  34762. /**
  34763. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  34764. */
  34765. maxZ: number;
  34766. /**
  34767. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  34768. */
  34769. minZAspect: number;
  34770. /**
  34771. * Number of samples used for the SSAO calculations. Default value is 8
  34772. */
  34773. private _samples;
  34774. /**
  34775. * Ratio object used for SSAO ratio and blur ratio
  34776. */
  34777. private _ratio;
  34778. /**
  34779. * Dynamically generated sphere sampler.
  34780. */
  34781. private _sampleSphere;
  34782. /**
  34783. * Blur filter offsets
  34784. */
  34785. private _samplerOffsets;
  34786. samples: number;
  34787. /**
  34788. * Are we using bilateral blur ?
  34789. */
  34790. private _expensiveBlur;
  34791. expensiveBlur: boolean;
  34792. /**
  34793. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  34794. */
  34795. radius: number;
  34796. /**
  34797. * The base color of the SSAO post-process
  34798. * The final result is "base + ssao" between [0, 1]
  34799. */
  34800. base: number;
  34801. /**
  34802. * Support test.
  34803. */
  34804. static readonly IsSupported: boolean;
  34805. private _scene;
  34806. private _depthTexture;
  34807. private _normalTexture;
  34808. private _randomTexture;
  34809. private _originalColorPostProcess;
  34810. private _ssaoPostProcess;
  34811. private _blurHPostProcess;
  34812. private _blurVPostProcess;
  34813. private _ssaoCombinePostProcess;
  34814. private _firstUpdate;
  34815. /**
  34816. * @constructor
  34817. * @param {string} name - The rendering pipeline name
  34818. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34819. * @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 }
  34820. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34821. */
  34822. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  34823. /**
  34824. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  34825. */
  34826. dispose(disableGeometryBufferRenderer?: boolean): void;
  34827. private _createBlurPostProcess(ssaoRatio, blurRatio);
  34828. _rebuild(): void;
  34829. private _generateHemisphere();
  34830. private _createSSAOPostProcess(ratio);
  34831. private _createSSAOCombinePostProcess(ratio);
  34832. private _createRandomTexture();
  34833. /**
  34834. * Serialize the rendering pipeline (Used when exporting)
  34835. * @returns the serialized object
  34836. */
  34837. serialize(): any;
  34838. /**
  34839. * Parse the serialized pipeline
  34840. * @param source Source pipeline.
  34841. * @param scene The scene to load the pipeline to.
  34842. * @param rootUrl The URL of the serialized pipeline.
  34843. * @returns An instantiated pipeline from the serialized object.
  34844. */
  34845. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  34846. }
  34847. }
  34848. declare module BABYLON {
  34849. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  34850. /**
  34851. * The PassPostProcess id in the pipeline that contains the original scene color
  34852. */
  34853. SSAOOriginalSceneColorEffect: string;
  34854. /**
  34855. * The SSAO PostProcess id in the pipeline
  34856. */
  34857. SSAORenderEffect: string;
  34858. /**
  34859. * The horizontal blur PostProcess id in the pipeline
  34860. */
  34861. SSAOBlurHRenderEffect: string;
  34862. /**
  34863. * The vertical blur PostProcess id in the pipeline
  34864. */
  34865. SSAOBlurVRenderEffect: string;
  34866. /**
  34867. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  34868. */
  34869. SSAOCombineRenderEffect: string;
  34870. /**
  34871. * The output strength of the SSAO post-process. Default value is 1.0.
  34872. */
  34873. totalStrength: number;
  34874. /**
  34875. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  34876. */
  34877. radius: number;
  34878. /**
  34879. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  34880. * Must not be equal to fallOff and superior to fallOff.
  34881. * Default value is 0.975
  34882. */
  34883. area: number;
  34884. /**
  34885. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  34886. * Must not be equal to area and inferior to area.
  34887. * Default value is 0.0
  34888. */
  34889. fallOff: number;
  34890. /**
  34891. * The base color of the SSAO post-process
  34892. * The final result is "base + ssao" between [0, 1]
  34893. */
  34894. base: number;
  34895. private _scene;
  34896. private _depthTexture;
  34897. private _randomTexture;
  34898. private _originalColorPostProcess;
  34899. private _ssaoPostProcess;
  34900. private _blurHPostProcess;
  34901. private _blurVPostProcess;
  34902. private _ssaoCombinePostProcess;
  34903. private _firstUpdate;
  34904. /**
  34905. * @constructor
  34906. * @param {string} name - The rendering pipeline name
  34907. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34908. * @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 }
  34909. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34910. */
  34911. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  34912. /**
  34913. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  34914. */
  34915. dispose(disableDepthRender?: boolean): void;
  34916. private _createBlurPostProcess(ratio);
  34917. _rebuild(): void;
  34918. private _createSSAOPostProcess(ratio);
  34919. private _createSSAOCombinePostProcess(ratio);
  34920. private _createRandomTexture();
  34921. }
  34922. }
  34923. declare module BABYLON {
  34924. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  34925. /**
  34926. * Public members
  34927. */
  34928. originalPostProcess: Nullable<PostProcess>;
  34929. downSampleX4PostProcess: Nullable<PostProcess>;
  34930. brightPassPostProcess: Nullable<PostProcess>;
  34931. blurHPostProcesses: PostProcess[];
  34932. blurVPostProcesses: PostProcess[];
  34933. textureAdderPostProcess: Nullable<PostProcess>;
  34934. volumetricLightPostProcess: Nullable<PostProcess>;
  34935. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  34936. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  34937. volumetricLightMergePostProces: Nullable<PostProcess>;
  34938. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  34939. luminancePostProcess: Nullable<PostProcess>;
  34940. luminanceDownSamplePostProcesses: PostProcess[];
  34941. hdrPostProcess: Nullable<PostProcess>;
  34942. textureAdderFinalPostProcess: Nullable<PostProcess>;
  34943. lensFlareFinalPostProcess: Nullable<PostProcess>;
  34944. hdrFinalPostProcess: Nullable<PostProcess>;
  34945. lensFlarePostProcess: Nullable<PostProcess>;
  34946. lensFlareComposePostProcess: Nullable<PostProcess>;
  34947. motionBlurPostProcess: Nullable<PostProcess>;
  34948. depthOfFieldPostProcess: Nullable<PostProcess>;
  34949. brightThreshold: number;
  34950. blurWidth: number;
  34951. horizontalBlur: boolean;
  34952. exposure: number;
  34953. lensTexture: Nullable<Texture>;
  34954. volumetricLightCoefficient: number;
  34955. volumetricLightPower: number;
  34956. volumetricLightBlurScale: number;
  34957. sourceLight: Nullable<SpotLight | DirectionalLight>;
  34958. hdrMinimumLuminance: number;
  34959. hdrDecreaseRate: number;
  34960. hdrIncreaseRate: number;
  34961. lensColorTexture: Nullable<Texture>;
  34962. lensFlareStrength: number;
  34963. lensFlareGhostDispersal: number;
  34964. lensFlareHaloWidth: number;
  34965. lensFlareDistortionStrength: number;
  34966. lensStarTexture: Nullable<Texture>;
  34967. lensFlareDirtTexture: Nullable<Texture>;
  34968. depthOfFieldDistance: number;
  34969. depthOfFieldBlurWidth: number;
  34970. motionStrength: number;
  34971. animations: Animation[];
  34972. /**
  34973. * Private members
  34974. */
  34975. private _scene;
  34976. private _currentDepthOfFieldSource;
  34977. private _basePostProcess;
  34978. private _hdrCurrentLuminance;
  34979. private _floatTextureType;
  34980. private _ratio;
  34981. private _bloomEnabled;
  34982. private _depthOfFieldEnabled;
  34983. private _vlsEnabled;
  34984. private _lensFlareEnabled;
  34985. private _hdrEnabled;
  34986. private _motionBlurEnabled;
  34987. private _motionBlurSamples;
  34988. private _volumetricLightStepsCount;
  34989. BloomEnabled: boolean;
  34990. DepthOfFieldEnabled: boolean;
  34991. LensFlareEnabled: boolean;
  34992. HDREnabled: boolean;
  34993. VLSEnabled: boolean;
  34994. MotionBlurEnabled: boolean;
  34995. volumetricLightStepsCount: number;
  34996. motionBlurSamples: number;
  34997. /**
  34998. * @constructor
  34999. * @param {string} name - The rendering pipeline name
  35000. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35001. * @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)
  35002. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  35003. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35004. */
  35005. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  35006. private _buildPipeline();
  35007. private _createDownSampleX4PostProcess(scene, ratio);
  35008. private _createBrightPassPostProcess(scene, ratio);
  35009. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  35010. private _createTextureAdderPostProcess(scene, ratio);
  35011. private _createVolumetricLightPostProcess(scene, ratio);
  35012. private _createLuminancePostProcesses(scene, textureType);
  35013. private _createHdrPostProcess(scene, ratio);
  35014. private _createLensFlarePostProcess(scene, ratio);
  35015. private _createDepthOfFieldPostProcess(scene, ratio);
  35016. private _createMotionBlurPostProcess(scene, ratio);
  35017. private _getDepthTexture();
  35018. private _disposePostProcesses();
  35019. /**
  35020. * Dispose of the pipeline and stop all post processes
  35021. */
  35022. dispose(): void;
  35023. /**
  35024. * Serialize the rendering pipeline (Used when exporting)
  35025. * @returns the serialized object
  35026. */
  35027. serialize(): any;
  35028. /**
  35029. * Parse the serialized pipeline
  35030. * @param source Source pipeline.
  35031. * @param scene The scene to load the pipeline to.
  35032. * @param rootUrl The URL of the serialized pipeline.
  35033. * @returns An instantiated pipeline from the serialized object.
  35034. */
  35035. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  35036. static LuminanceSteps: number;
  35037. }
  35038. }