babylon.d.ts 1.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359
  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. * Observer raised when the animation ends
  3335. */
  3336. onAnimationEndObservable: Observable<Animatable>;
  3337. /**
  3338. * Gets the root Animatable used to synchronize and normalize animations
  3339. */
  3340. readonly syncRoot: Animatable;
  3341. /**
  3342. * Gets the current frame of the first RuntimeAnimation
  3343. * Used to synchronize Animatables
  3344. */
  3345. readonly masterFrame: number;
  3346. /**
  3347. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3348. */
  3349. weight: number;
  3350. /**
  3351. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3352. */
  3353. speedRatio: number;
  3354. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  3355. /**
  3356. * Synchronize and normalize current Animatable with a source Animatable
  3357. * This is useful when using animation weights and when animations are not of the same length
  3358. * @param root defines the root Animatable to synchronize with
  3359. * @returns the current Animatable
  3360. */
  3361. syncWith(root: Animatable): Animatable;
  3362. getAnimations(): RuntimeAnimation[];
  3363. appendAnimations(target: any, animations: Animation[]): void;
  3364. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3365. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3366. reset(): void;
  3367. enableBlending(blendingSpeed: number): void;
  3368. disableBlending(): void;
  3369. goToFrame(frame: number): void;
  3370. pause(): void;
  3371. restart(): void;
  3372. private _raiseOnAnimationEnd();
  3373. stop(animationName?: string): void;
  3374. /**
  3375. * Wait asynchronously for the animation to end
  3376. * @returns a promise which will be fullfilled when the animation ends
  3377. */
  3378. waitAsync(): Promise<Animatable>;
  3379. /** @hidden */
  3380. _animate(delay: number): boolean;
  3381. }
  3382. }
  3383. declare module BABYLON {
  3384. /**
  3385. * Represents the range of an animation
  3386. */
  3387. class AnimationRange {
  3388. /**The name of the animation range**/
  3389. name: string;
  3390. /**The starting frame of the animation */
  3391. from: number;
  3392. /**The ending frame of the animation*/
  3393. to: number;
  3394. /**
  3395. * Initializes the range of an animation
  3396. * @param name The name of the animation range
  3397. * @param from The starting frame of the animation
  3398. * @param to The ending frame of the animation
  3399. */
  3400. constructor(
  3401. /**The name of the animation range**/
  3402. name: string,
  3403. /**The starting frame of the animation */
  3404. from: number,
  3405. /**The ending frame of the animation*/
  3406. to: number);
  3407. /**
  3408. * Makes a copy of the animation range
  3409. * @returns A copy of the animation range
  3410. */
  3411. clone(): AnimationRange;
  3412. }
  3413. /**
  3414. * Composed of a frame, and an action function
  3415. */
  3416. class AnimationEvent {
  3417. /** The frame for which the event is triggered **/
  3418. frame: number;
  3419. /** The event to perform when triggered **/
  3420. action: () => void;
  3421. /** Specifies if the event should be triggered only once**/
  3422. onlyOnce: boolean | undefined;
  3423. /**
  3424. * Specifies if the animation event is done
  3425. */
  3426. isDone: boolean;
  3427. /**
  3428. * Initializes the animation event
  3429. * @param frame The frame for which the event is triggered
  3430. * @param action The event to perform when triggered
  3431. * @param onlyOnce Specifies if the event should be triggered only once
  3432. */
  3433. constructor(
  3434. /** The frame for which the event is triggered **/
  3435. frame: number,
  3436. /** The event to perform when triggered **/
  3437. action: () => void,
  3438. /** Specifies if the event should be triggered only once**/
  3439. onlyOnce?: boolean | undefined);
  3440. /** @hidden */
  3441. _clone(): AnimationEvent;
  3442. }
  3443. /**
  3444. * A cursor which tracks a point on a path
  3445. */
  3446. class PathCursor {
  3447. private path;
  3448. /**
  3449. * Stores path cursor callbacks for when an onchange event is triggered
  3450. */
  3451. private _onchange;
  3452. /**
  3453. * The value of the path cursor
  3454. */
  3455. value: number;
  3456. /**
  3457. * The animation array of the path cursor
  3458. */
  3459. animations: Animation[];
  3460. /**
  3461. * Initializes the path cursor
  3462. * @param path The path to track
  3463. */
  3464. constructor(path: Path2);
  3465. /**
  3466. * Gets the cursor point on the path
  3467. * @returns A point on the path cursor at the cursor location
  3468. */
  3469. getPoint(): Vector3;
  3470. /**
  3471. * Moves the cursor ahead by the step amount
  3472. * @param step The amount to move the cursor forward
  3473. * @returns This path cursor
  3474. */
  3475. moveAhead(step?: number): PathCursor;
  3476. /**
  3477. * Moves the cursor behind by the step amount
  3478. * @param step The amount to move the cursor back
  3479. * @returns This path cursor
  3480. */
  3481. moveBack(step?: number): PathCursor;
  3482. /**
  3483. * Moves the cursor by the step amount
  3484. * If the step amount is greater than one, an exception is thrown
  3485. * @param step The amount to move the cursor
  3486. * @returns This path cursor
  3487. */
  3488. move(step: number): PathCursor;
  3489. /**
  3490. * Ensures that the value is limited between zero and one
  3491. * @returns This path cursor
  3492. */
  3493. private ensureLimits();
  3494. /**
  3495. * Runs onchange callbacks on change (used by the animation engine)
  3496. * @returns This path cursor
  3497. */
  3498. private raiseOnChange();
  3499. /**
  3500. * Executes a function on change
  3501. * @param f A path cursor onchange callback
  3502. * @returns This path cursor
  3503. */
  3504. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3505. }
  3506. /**
  3507. * Defines an interface which represents an animation key frame
  3508. */
  3509. interface IAnimationKey {
  3510. /**
  3511. * Frame of the key frame
  3512. */
  3513. frame: number;
  3514. /**
  3515. * Value at the specifies key frame
  3516. */
  3517. value: any;
  3518. /**
  3519. * The input tangent for the cubic hermite spline
  3520. */
  3521. inTangent?: any;
  3522. /**
  3523. * The output tangent for the cubic hermite spline
  3524. */
  3525. outTangent?: any;
  3526. /**
  3527. * The animation interpolation type
  3528. */
  3529. interpolation?: AnimationKeyInterpolation;
  3530. }
  3531. /**
  3532. * Enum for the animation key frame interpolation type
  3533. */
  3534. enum AnimationKeyInterpolation {
  3535. /**
  3536. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3537. */
  3538. STEP = 1,
  3539. }
  3540. /**
  3541. * Class used to store any kind of animation
  3542. */
  3543. class Animation {
  3544. /**Name of the animation */
  3545. name: string;
  3546. /**Property to animate */
  3547. targetProperty: string;
  3548. /**The frames per second of the animation */
  3549. framePerSecond: number;
  3550. /**The data type of the animation */
  3551. dataType: number;
  3552. /**The loop mode of the animation */
  3553. loopMode: number | undefined;
  3554. /**Specifies if blending should be enabled */
  3555. enableBlending: boolean | undefined;
  3556. /**
  3557. * Use matrix interpolation instead of using direct key value when animating matrices
  3558. */
  3559. static AllowMatricesInterpolation: boolean;
  3560. /**
  3561. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3562. */
  3563. static AllowMatrixDecomposeForInterpolation: boolean;
  3564. /**
  3565. * Stores the key frames of the animation
  3566. */
  3567. private _keys;
  3568. /**
  3569. * Stores the easing function of the animation
  3570. */
  3571. private _easingFunction;
  3572. /**
  3573. * @hidden Internal use only
  3574. */
  3575. _runtimeAnimations: RuntimeAnimation[];
  3576. /**
  3577. * The set of event that will be linked to this animation
  3578. */
  3579. private _events;
  3580. /**
  3581. * Stores an array of target property paths
  3582. */
  3583. targetPropertyPath: string[];
  3584. /**
  3585. * Stores the blending speed of the animation
  3586. */
  3587. blendingSpeed: number;
  3588. /**
  3589. * Stores the animation ranges for the animation
  3590. */
  3591. private _ranges;
  3592. /**
  3593. * @hidden Internal use
  3594. */
  3595. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3596. /**
  3597. * Sets up an animation
  3598. * @param property The property to animate
  3599. * @param animationType The animation type to apply
  3600. * @param framePerSecond The frames per second of the animation
  3601. * @param easingFunction The easing function used in the animation
  3602. * @returns The created animation
  3603. */
  3604. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3605. /**
  3606. * Create and start an animation on a node
  3607. * @param name defines the name of the global animation that will be run on all nodes
  3608. * @param node defines the root node where the animation will take place
  3609. * @param targetProperty defines property to animate
  3610. * @param framePerSecond defines the number of frame per second yo use
  3611. * @param totalFrame defines the number of frames in total
  3612. * @param from defines the initial value
  3613. * @param to defines the final value
  3614. * @param loopMode defines which loop mode you want to use (off by default)
  3615. * @param easingFunction defines the easing function to use (linear by default)
  3616. * @param onAnimationEnd defines the callback to call when animation end
  3617. * @returns the animatable created for this animation
  3618. */
  3619. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3620. /**
  3621. * Create and start an animation on a node and its descendants
  3622. * @param name defines the name of the global animation that will be run on all nodes
  3623. * @param node defines the root node where the animation will take place
  3624. * @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
  3625. * @param targetProperty defines property to animate
  3626. * @param framePerSecond defines the number of frame per second to use
  3627. * @param totalFrame defines the number of frames in total
  3628. * @param from defines the initial value
  3629. * @param to defines the final value
  3630. * @param loopMode defines which loop mode you want to use (off by default)
  3631. * @param easingFunction defines the easing function to use (linear by default)
  3632. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3633. * @returns the list of animatables created for all nodes
  3634. * @example https://www.babylonjs-playground.com/#MH0VLI
  3635. */
  3636. 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[]>;
  3637. /**
  3638. * Creates a new animation, merges it with the existing animations and starts it
  3639. * @param name Name of the animation
  3640. * @param node Node which contains the scene that begins the animations
  3641. * @param targetProperty Specifies which property to animate
  3642. * @param framePerSecond The frames per second of the animation
  3643. * @param totalFrame The total number of frames
  3644. * @param from The frame at the beginning of the animation
  3645. * @param to The frame at the end of the animation
  3646. * @param loopMode Specifies the loop mode of the animation
  3647. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3648. * @param onAnimationEnd Callback to run once the animation is complete
  3649. * @returns Nullable animation
  3650. */
  3651. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3652. /**
  3653. * Transition property of the Camera to the target Value
  3654. * @param property The property to transition
  3655. * @param targetValue The target Value of the property
  3656. * @param host The object where the property to animate belongs
  3657. * @param scene Scene used to run the animation
  3658. * @param frameRate Framerate (in frame/s) to use
  3659. * @param transition The transition type we want to use
  3660. * @param duration The duration of the animation, in milliseconds
  3661. * @param onAnimationEnd Callback trigger at the end of the animation
  3662. * @returns Nullable animation
  3663. */
  3664. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3665. /**
  3666. * Return the array of runtime animations currently using this animation
  3667. */
  3668. readonly runtimeAnimations: RuntimeAnimation[];
  3669. /**
  3670. * Specifies if any of the runtime animations are currently running
  3671. */
  3672. readonly hasRunningRuntimeAnimations: boolean;
  3673. /**
  3674. * Initializes the animation
  3675. * @param name Name of the animation
  3676. * @param targetProperty Property to animate
  3677. * @param framePerSecond The frames per second of the animation
  3678. * @param dataType The data type of the animation
  3679. * @param loopMode The loop mode of the animation
  3680. * @param enableBlendings Specifies if blending should be enabled
  3681. */
  3682. constructor(
  3683. /**Name of the animation */
  3684. name: string,
  3685. /**Property to animate */
  3686. targetProperty: string,
  3687. /**The frames per second of the animation */
  3688. framePerSecond: number,
  3689. /**The data type of the animation */
  3690. dataType: number,
  3691. /**The loop mode of the animation */
  3692. loopMode?: number | undefined,
  3693. /**Specifies if blending should be enabled */
  3694. enableBlending?: boolean | undefined);
  3695. /**
  3696. * Converts the animation to a string
  3697. * @param fullDetails support for multiple levels of logging within scene loading
  3698. * @returns String form of the animation
  3699. */
  3700. toString(fullDetails?: boolean): string;
  3701. /**
  3702. * Add an event to this animation
  3703. * @param event Event to add
  3704. */
  3705. addEvent(event: AnimationEvent): void;
  3706. /**
  3707. * Remove all events found at the given frame
  3708. * @param frame The frame to remove events from
  3709. */
  3710. removeEvents(frame: number): void;
  3711. /**
  3712. * Retrieves all the events from the animation
  3713. * @returns Events from the animation
  3714. */
  3715. getEvents(): AnimationEvent[];
  3716. /**
  3717. * Creates an animation range
  3718. * @param name Name of the animation range
  3719. * @param from Starting frame of the animation range
  3720. * @param to Ending frame of the animation
  3721. */
  3722. createRange(name: string, from: number, to: number): void;
  3723. /**
  3724. * Deletes an animation range by name
  3725. * @param name Name of the animation range to delete
  3726. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3727. */
  3728. deleteRange(name: string, deleteFrames?: boolean): void;
  3729. /**
  3730. * Gets the animation range by name, or null if not defined
  3731. * @param name Name of the animation range
  3732. * @returns Nullable animation range
  3733. */
  3734. getRange(name: string): Nullable<AnimationRange>;
  3735. /**
  3736. * Gets the key frames from the animation
  3737. * @returns The key frames of the animation
  3738. */
  3739. getKeys(): Array<IAnimationKey>;
  3740. /**
  3741. * Gets the highest frame rate of the animation
  3742. * @returns Highest frame rate of the animation
  3743. */
  3744. getHighestFrame(): number;
  3745. /**
  3746. * Gets the easing function of the animation
  3747. * @returns Easing function of the animation
  3748. */
  3749. getEasingFunction(): IEasingFunction;
  3750. /**
  3751. * Sets the easing function of the animation
  3752. * @param easingFunction A custom mathematical formula for animation
  3753. */
  3754. setEasingFunction(easingFunction: EasingFunction): void;
  3755. /**
  3756. * Interpolates a scalar linearly
  3757. * @param startValue Start value of the animation curve
  3758. * @param endValue End value of the animation curve
  3759. * @param gradient Scalar amount to interpolate
  3760. * @returns Interpolated scalar value
  3761. */
  3762. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3763. /**
  3764. * Interpolates a scalar cubically
  3765. * @param startValue Start value of the animation curve
  3766. * @param outTangent End tangent of the animation
  3767. * @param endValue End value of the animation curve
  3768. * @param inTangent Start tangent of the animation curve
  3769. * @param gradient Scalar amount to interpolate
  3770. * @returns Interpolated scalar value
  3771. */
  3772. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3773. /**
  3774. * Interpolates a quaternion using a spherical linear interpolation
  3775. * @param startValue Start value of the animation curve
  3776. * @param endValue End value of the animation curve
  3777. * @param gradient Scalar amount to interpolate
  3778. * @returns Interpolated quaternion value
  3779. */
  3780. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3781. /**
  3782. * Interpolates a quaternion cubically
  3783. * @param startValue Start value of the animation curve
  3784. * @param outTangent End tangent of the animation curve
  3785. * @param endValue End value of the animation curve
  3786. * @param inTangent Start tangent of the animation curve
  3787. * @param gradient Scalar amount to interpolate
  3788. * @returns Interpolated quaternion value
  3789. */
  3790. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3791. /**
  3792. * Interpolates a Vector3 linearl
  3793. * @param startValue Start value of the animation curve
  3794. * @param endValue End value of the animation curve
  3795. * @param gradient Scalar amount to interpolate
  3796. * @returns Interpolated scalar value
  3797. */
  3798. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3799. /**
  3800. * Interpolates a Vector3 cubically
  3801. * @param startValue Start value of the animation curve
  3802. * @param outTangent End tangent of the animation
  3803. * @param endValue End value of the animation curve
  3804. * @param inTangent Start tangent of the animation curve
  3805. * @param gradient Scalar amount to interpolate
  3806. * @returns InterpolatedVector3 value
  3807. */
  3808. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3809. /**
  3810. * Interpolates a Vector2 linearly
  3811. * @param startValue Start value of the animation curve
  3812. * @param endValue End value of the animation curve
  3813. * @param gradient Scalar amount to interpolate
  3814. * @returns Interpolated Vector2 value
  3815. */
  3816. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3817. /**
  3818. * Interpolates a Vector2 cubically
  3819. * @param startValue Start value of the animation curve
  3820. * @param outTangent End tangent of the animation
  3821. * @param endValue End value of the animation curve
  3822. * @param inTangent Start tangent of the animation curve
  3823. * @param gradient Scalar amount to interpolate
  3824. * @returns Interpolated Vector2 value
  3825. */
  3826. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  3827. /**
  3828. * Interpolates a size linearly
  3829. * @param startValue Start value of the animation curve
  3830. * @param endValue End value of the animation curve
  3831. * @param gradient Scalar amount to interpolate
  3832. * @returns Interpolated Size value
  3833. */
  3834. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  3835. /**
  3836. * Interpolates a Color3 linearly
  3837. * @param startValue Start value of the animation curve
  3838. * @param endValue End value of the animation curve
  3839. * @param gradient Scalar amount to interpolate
  3840. * @returns Interpolated Color3 value
  3841. */
  3842. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  3843. /**
  3844. * @hidden Internal use only
  3845. */
  3846. _getKeyValue(value: any): any;
  3847. /**
  3848. * @hidden Internal use only
  3849. */
  3850. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  3851. /**
  3852. * Defines the function to use to interpolate matrices
  3853. * @param startValue defines the start matrix
  3854. * @param endValue defines the end matrix
  3855. * @param gradient defines the gradient between both matrices
  3856. * @param result defines an optional target matrix where to store the interpolation
  3857. * @returns the interpolated matrix
  3858. */
  3859. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  3860. /**
  3861. * Makes a copy of the animation
  3862. * @returns Cloned animation
  3863. */
  3864. clone(): Animation;
  3865. /**
  3866. * Sets the key frames of the animation
  3867. * @param values The animation key frames to set
  3868. */
  3869. setKeys(values: Array<IAnimationKey>): void;
  3870. /**
  3871. * Serializes the animation to an object
  3872. * @returns Serialized object
  3873. */
  3874. serialize(): any;
  3875. /**
  3876. * Float animation type
  3877. */
  3878. private static _ANIMATIONTYPE_FLOAT;
  3879. /**
  3880. * Vector3 animation type
  3881. */
  3882. private static _ANIMATIONTYPE_VECTOR3;
  3883. /**
  3884. * Quaternion animation type
  3885. */
  3886. private static _ANIMATIONTYPE_QUATERNION;
  3887. /**
  3888. * Matrix animation type
  3889. */
  3890. private static _ANIMATIONTYPE_MATRIX;
  3891. /**
  3892. * Color3 animation type
  3893. */
  3894. private static _ANIMATIONTYPE_COLOR3;
  3895. /**
  3896. * Vector2 animation type
  3897. */
  3898. private static _ANIMATIONTYPE_VECTOR2;
  3899. /**
  3900. * Size animation type
  3901. */
  3902. private static _ANIMATIONTYPE_SIZE;
  3903. /**
  3904. * Relative Loop Mode
  3905. */
  3906. private static _ANIMATIONLOOPMODE_RELATIVE;
  3907. /**
  3908. * Cycle Loop Mode
  3909. */
  3910. private static _ANIMATIONLOOPMODE_CYCLE;
  3911. /**
  3912. * Constant Loop Mode
  3913. */
  3914. private static _ANIMATIONLOOPMODE_CONSTANT;
  3915. /**
  3916. * Get the float animation type
  3917. */
  3918. static readonly ANIMATIONTYPE_FLOAT: number;
  3919. /**
  3920. * Get the Vector3 animation type
  3921. */
  3922. static readonly ANIMATIONTYPE_VECTOR3: number;
  3923. /**
  3924. * Get the Vectpr2 animation type
  3925. */
  3926. static readonly ANIMATIONTYPE_VECTOR2: number;
  3927. /**
  3928. * Get the Size animation type
  3929. */
  3930. static readonly ANIMATIONTYPE_SIZE: number;
  3931. /**
  3932. * Get the Quaternion animation type
  3933. */
  3934. static readonly ANIMATIONTYPE_QUATERNION: number;
  3935. /**
  3936. * Get the Matrix animation type
  3937. */
  3938. static readonly ANIMATIONTYPE_MATRIX: number;
  3939. /**
  3940. * Get the Color3 animation type
  3941. */
  3942. static readonly ANIMATIONTYPE_COLOR3: number;
  3943. /**
  3944. * Get the Relative Loop Mode
  3945. */
  3946. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  3947. /**
  3948. * Get the Cycle Loop Mode
  3949. */
  3950. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  3951. /**
  3952. * Get the Constant Loop Mode
  3953. */
  3954. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  3955. /** @hidden */
  3956. static _UniversalLerp(left: any, right: any, amount: number): any;
  3957. /**
  3958. * Parses an animation object and creates an animation
  3959. * @param parsedAnimation Parsed animation object
  3960. * @returns Animation object
  3961. */
  3962. static Parse(parsedAnimation: any): Animation;
  3963. /**
  3964. * Appends the serialized animations from the source animations
  3965. * @param source Source containing the animations
  3966. * @param destination Target to store the animations
  3967. */
  3968. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  3969. }
  3970. }
  3971. declare module BABYLON {
  3972. /**
  3973. * This class defines the direct association between an animation and a target
  3974. */
  3975. class TargetedAnimation {
  3976. animation: Animation;
  3977. target: any;
  3978. }
  3979. /**
  3980. * Use this class to create coordinated animations on multiple targets
  3981. */
  3982. class AnimationGroup implements IDisposable {
  3983. name: string;
  3984. private _scene;
  3985. private _targetedAnimations;
  3986. private _animatables;
  3987. private _from;
  3988. private _to;
  3989. private _isStarted;
  3990. private _speedRatio;
  3991. onAnimationEndObservable: Observable<TargetedAnimation>;
  3992. /**
  3993. * Gets the first frame
  3994. */
  3995. readonly from: number;
  3996. /**
  3997. * Gets the last frame
  3998. */
  3999. readonly to: number;
  4000. /**
  4001. * Define if the animations are started
  4002. */
  4003. readonly isStarted: boolean;
  4004. /**
  4005. * Gets or sets the speed ratio to use for all animations
  4006. */
  4007. /**
  4008. * Gets or sets the speed ratio to use for all animations
  4009. */
  4010. speedRatio: number;
  4011. /**
  4012. * Gets the targeted animations for this animation group
  4013. */
  4014. readonly targetedAnimations: Array<TargetedAnimation>;
  4015. /**
  4016. * returning the list of animatables controlled by this animation group.
  4017. */
  4018. readonly animatables: Array<Animatable>;
  4019. constructor(name: string, scene?: Nullable<Scene>);
  4020. /**
  4021. * Add an animation (with its target) in the group
  4022. * @param animation defines the animation we want to add
  4023. * @param target defines the target of the animation
  4024. * @returns the {BABYLON.TargetedAnimation} object
  4025. */
  4026. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4027. /**
  4028. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4029. * It can add constant keys at begin or end
  4030. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4031. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4032. */
  4033. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4034. /**
  4035. * Start all animations on given targets
  4036. * @param loop defines if animations must loop
  4037. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4038. * @param from defines the from key (optional)
  4039. * @param to defines the to key (optional)
  4040. * @returns the current animation group
  4041. */
  4042. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4043. /**
  4044. * Pause all animations
  4045. */
  4046. pause(): AnimationGroup;
  4047. /**
  4048. * Play all animations to initial state
  4049. * This function will start() the animations if they were not started or will restart() them if they were paused
  4050. * @param loop defines if animations must loop
  4051. */
  4052. play(loop?: boolean): AnimationGroup;
  4053. /**
  4054. * Reset all animations to initial state
  4055. */
  4056. reset(): AnimationGroup;
  4057. /**
  4058. * Restart animations from key 0
  4059. */
  4060. restart(): AnimationGroup;
  4061. /**
  4062. * Stop all animations
  4063. */
  4064. stop(): AnimationGroup;
  4065. /**
  4066. * Set animation weight for all animatables
  4067. * @param weight defines the weight to use
  4068. * @return the animationGroup
  4069. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4070. */
  4071. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4072. /**
  4073. * Synchronize and normalize all animatables with a source animatable
  4074. * @param root defines the root animatable to synchronize with
  4075. * @return the animationGroup
  4076. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4077. */
  4078. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4079. /**
  4080. * Goes to a specific frame in this animation group
  4081. * @param frame the frame number to go to
  4082. * @return the animationGroup
  4083. */
  4084. goToFrame(frame: number): AnimationGroup;
  4085. /**
  4086. * Dispose all associated resources
  4087. */
  4088. dispose(): void;
  4089. }
  4090. }
  4091. declare module BABYLON {
  4092. /**
  4093. * Class used to override all child animations of a given target
  4094. */
  4095. class AnimationPropertiesOverride {
  4096. /**
  4097. * Gets or sets a value indicating if animation blending must be used
  4098. */
  4099. enableBlending: boolean;
  4100. /**
  4101. * Gets or sets the blending speed to use when enableBlending is true
  4102. */
  4103. blendingSpeed: number;
  4104. /**
  4105. * Gets or sets the default loop mode to use
  4106. */
  4107. loopMode: number;
  4108. }
  4109. }
  4110. declare module BABYLON {
  4111. interface IEasingFunction {
  4112. ease(gradient: number): number;
  4113. }
  4114. class EasingFunction implements IEasingFunction {
  4115. private static _EASINGMODE_EASEIN;
  4116. private static _EASINGMODE_EASEOUT;
  4117. private static _EASINGMODE_EASEINOUT;
  4118. static readonly EASINGMODE_EASEIN: number;
  4119. static readonly EASINGMODE_EASEOUT: number;
  4120. static readonly EASINGMODE_EASEINOUT: number;
  4121. private _easingMode;
  4122. setEasingMode(easingMode: number): void;
  4123. getEasingMode(): number;
  4124. easeInCore(gradient: number): number;
  4125. ease(gradient: number): number;
  4126. }
  4127. class CircleEase extends EasingFunction implements IEasingFunction {
  4128. easeInCore(gradient: number): number;
  4129. }
  4130. class BackEase extends EasingFunction implements IEasingFunction {
  4131. amplitude: number;
  4132. constructor(amplitude?: number);
  4133. easeInCore(gradient: number): number;
  4134. }
  4135. class BounceEase extends EasingFunction implements IEasingFunction {
  4136. bounces: number;
  4137. bounciness: number;
  4138. constructor(bounces?: number, bounciness?: number);
  4139. easeInCore(gradient: number): number;
  4140. }
  4141. class CubicEase extends EasingFunction implements IEasingFunction {
  4142. easeInCore(gradient: number): number;
  4143. }
  4144. class ElasticEase extends EasingFunction implements IEasingFunction {
  4145. oscillations: number;
  4146. springiness: number;
  4147. constructor(oscillations?: number, springiness?: number);
  4148. easeInCore(gradient: number): number;
  4149. }
  4150. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4151. exponent: number;
  4152. constructor(exponent?: number);
  4153. easeInCore(gradient: number): number;
  4154. }
  4155. class PowerEase extends EasingFunction implements IEasingFunction {
  4156. power: number;
  4157. constructor(power?: number);
  4158. easeInCore(gradient: number): number;
  4159. }
  4160. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4161. easeInCore(gradient: number): number;
  4162. }
  4163. class QuarticEase extends EasingFunction implements IEasingFunction {
  4164. easeInCore(gradient: number): number;
  4165. }
  4166. class QuinticEase extends EasingFunction implements IEasingFunction {
  4167. easeInCore(gradient: number): number;
  4168. }
  4169. class SineEase extends EasingFunction implements IEasingFunction {
  4170. easeInCore(gradient: number): number;
  4171. }
  4172. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4173. x1: number;
  4174. y1: number;
  4175. x2: number;
  4176. y2: number;
  4177. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4178. easeInCore(gradient: number): number;
  4179. }
  4180. }
  4181. declare module BABYLON {
  4182. /**
  4183. * Defines a runtime animation
  4184. */
  4185. class RuntimeAnimation {
  4186. private _events;
  4187. /**
  4188. * The current frame of the runtime animation
  4189. */
  4190. private _currentFrame;
  4191. /**
  4192. * The animation used by the runtime animation
  4193. */
  4194. private _animation;
  4195. /**
  4196. * The target of the runtime animation
  4197. */
  4198. private _target;
  4199. /**
  4200. * The initiating animatable
  4201. */
  4202. private _host;
  4203. /**
  4204. * The original value of the runtime animation
  4205. */
  4206. private _originalValue;
  4207. /**
  4208. * The original blend value of the runtime animation
  4209. */
  4210. private _originalBlendValue;
  4211. /**
  4212. * The offsets cache of the runtime animation
  4213. */
  4214. private _offsetsCache;
  4215. /**
  4216. * The high limits cache of the runtime animation
  4217. */
  4218. private _highLimitsCache;
  4219. /**
  4220. * Specifies if the runtime animation has been stopped
  4221. */
  4222. private _stopped;
  4223. /**
  4224. * The blending factor of the runtime animation
  4225. */
  4226. private _blendingFactor;
  4227. /**
  4228. * The BabylonJS scene
  4229. */
  4230. private _scene;
  4231. /**
  4232. * The current value of the runtime animation
  4233. */
  4234. private _currentValue;
  4235. /** @hidden */
  4236. _workValue: any;
  4237. /**
  4238. * The active target of the runtime animation
  4239. */
  4240. private _activeTarget;
  4241. /**
  4242. * The target path of the runtime animation
  4243. */
  4244. private _targetPath;
  4245. /**
  4246. * The weight of the runtime animation
  4247. */
  4248. private _weight;
  4249. /**
  4250. * The ratio offset of the runtime animation
  4251. */
  4252. private _ratioOffset;
  4253. /**
  4254. * The previous delay of the runtime animation
  4255. */
  4256. private _previousDelay;
  4257. /**
  4258. * The previous ratio of the runtime animation
  4259. */
  4260. private _previousRatio;
  4261. /**
  4262. * Gets the current frame of the runtime animation
  4263. */
  4264. readonly currentFrame: number;
  4265. /**
  4266. * Gets the weight of the runtime animation
  4267. */
  4268. readonly weight: number;
  4269. /**
  4270. * Gets the current value of the runtime animation
  4271. */
  4272. readonly currentValue: any;
  4273. /**
  4274. * Gets the target path of the runtime animation
  4275. */
  4276. readonly targetPath: string;
  4277. /**
  4278. * Gets the actual target of the runtime animation
  4279. */
  4280. readonly target: any;
  4281. /**
  4282. * Create a new RuntimeAnimation object
  4283. * @param target defines the target of the animation
  4284. * @param animation defines the source animation object
  4285. * @param scene defines the hosting scene
  4286. * @param host defines the initiating Animatable
  4287. */
  4288. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4289. /**
  4290. * Gets the animation from the runtime animation
  4291. */
  4292. readonly animation: Animation;
  4293. /**
  4294. * Resets the runtime animation to the beginning
  4295. * @param restoreOriginal defines whether to restore the target property to the original value
  4296. */
  4297. reset(restoreOriginal?: boolean): void;
  4298. /**
  4299. * Specifies if the runtime animation is stopped
  4300. * @returns Boolean specifying if the runtime animation is stopped
  4301. */
  4302. isStopped(): boolean;
  4303. /**
  4304. * Disposes of the runtime animation
  4305. */
  4306. dispose(): void;
  4307. /**
  4308. * Interpolates the animation from the current frame
  4309. * @param currentFrame The frame to interpolate the animation to
  4310. * @param repeatCount The number of times that the animation should loop
  4311. * @param loopMode The type of looping mode to use
  4312. * @param offsetValue Animation offset value
  4313. * @param highLimitValue The high limit value
  4314. * @returns The interpolated value
  4315. */
  4316. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  4317. /**
  4318. * Apply the interpolated value to the target
  4319. * @param currentValue defines the value computed by the animation
  4320. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4321. */
  4322. setValue(currentValue: any, weight?: number): void;
  4323. private _setValue(target, currentValue, weight, targetIndex?);
  4324. /**
  4325. * Gets the loop pmode of the runtime animation
  4326. * @returns Loop Mode
  4327. */
  4328. private _getCorrectLoopMode();
  4329. /**
  4330. * Move the current animation to a given frame
  4331. * @param frame defines the frame to move to
  4332. */
  4333. goToFrame(frame: number): void;
  4334. /**
  4335. * @hidden Internal use only
  4336. */
  4337. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4338. /**
  4339. * Execute the current animation
  4340. * @param delay defines the delay to add to the current frame
  4341. * @param from defines the lower bound of the animation range
  4342. * @param to defines the upper bound of the animation range
  4343. * @param loop defines if the current animation must loop
  4344. * @param speedRatio defines the current speed ratio
  4345. * @param weight defines the weight of the animation (default is -1 so no weight)
  4346. * @returns a boolean indicating if the animation has ended
  4347. */
  4348. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4349. }
  4350. }
  4351. declare module BABYLON {
  4352. /**
  4353. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4354. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4355. */
  4356. class Analyser {
  4357. /**
  4358. * Gets or sets the smoothing
  4359. * @ignorenaming
  4360. */
  4361. SMOOTHING: number;
  4362. /**
  4363. * Gets or sets the FFT table size
  4364. * @ignorenaming
  4365. */
  4366. FFT_SIZE: number;
  4367. /**
  4368. * Gets or sets the bar graph amplitude
  4369. * @ignorenaming
  4370. */
  4371. BARGRAPHAMPLITUDE: number;
  4372. /**
  4373. * Gets or sets the position of the debug canvas
  4374. * @ignorenaming
  4375. */
  4376. DEBUGCANVASPOS: {
  4377. x: number;
  4378. y: number;
  4379. };
  4380. /**
  4381. * Gets or sets the debug canvas size
  4382. * @ignorenaming
  4383. */
  4384. DEBUGCANVASSIZE: {
  4385. width: number;
  4386. height: number;
  4387. };
  4388. private _byteFreqs;
  4389. private _byteTime;
  4390. private _floatFreqs;
  4391. private _webAudioAnalyser;
  4392. private _debugCanvas;
  4393. private _debugCanvasContext;
  4394. private _scene;
  4395. private _registerFunc;
  4396. private _audioEngine;
  4397. /**
  4398. * Creates a new analyser
  4399. * @param scene defines hosting scene
  4400. */
  4401. constructor(scene: Scene);
  4402. /**
  4403. * Get the number of data values you will have to play with for the visualization
  4404. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4405. * @returns a number
  4406. */
  4407. getFrequencyBinCount(): number;
  4408. /**
  4409. * Gets the current frequency data as a byte array
  4410. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4411. * @returns a Uint8Array
  4412. */
  4413. getByteFrequencyData(): Uint8Array;
  4414. /**
  4415. * Gets the current waveform as a byte array
  4416. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4417. * @returns a Uint8Array
  4418. */
  4419. getByteTimeDomainData(): Uint8Array;
  4420. /**
  4421. * Gets the current frequency data as a float array
  4422. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4423. * @returns a Float32Array
  4424. */
  4425. getFloatFrequencyData(): Float32Array;
  4426. /**
  4427. * Renders the debug canvas
  4428. */
  4429. drawDebugCanvas(): void;
  4430. /**
  4431. * Stops rendering the debug canvas and removes it
  4432. */
  4433. stopDebugCanvas(): void;
  4434. /**
  4435. * Connects two audio nodes
  4436. * @param inputAudioNode defines first node to connect
  4437. * @param outputAudioNode defines second node to connect
  4438. */
  4439. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4440. /**
  4441. * Releases all associated resources
  4442. */
  4443. dispose(): void;
  4444. }
  4445. }
  4446. declare module BABYLON {
  4447. class AudioEngine {
  4448. private _audioContext;
  4449. private _audioContextInitialized;
  4450. canUseWebAudio: boolean;
  4451. masterGain: GainNode;
  4452. private _connectedAnalyser;
  4453. WarnedWebAudioUnsupported: boolean;
  4454. unlocked: boolean;
  4455. onAudioUnlocked: () => any;
  4456. isMP3supported: boolean;
  4457. isOGGsupported: boolean;
  4458. readonly audioContext: Nullable<AudioContext>;
  4459. constructor();
  4460. private _unlockiOSaudio();
  4461. private _initializeAudioContext();
  4462. dispose(): void;
  4463. getGlobalVolume(): number;
  4464. setGlobalVolume(newVolume: number): void;
  4465. connectToAnalyser(analyser: Analyser): void;
  4466. }
  4467. }
  4468. declare module BABYLON {
  4469. class Sound {
  4470. name: string;
  4471. autoplay: boolean;
  4472. loop: boolean;
  4473. useCustomAttenuation: boolean;
  4474. soundTrackId: number;
  4475. spatialSound: boolean;
  4476. refDistance: number;
  4477. rolloffFactor: number;
  4478. maxDistance: number;
  4479. distanceModel: string;
  4480. private _panningModel;
  4481. onended: () => any;
  4482. private _playbackRate;
  4483. private _streaming;
  4484. private _startTime;
  4485. private _startOffset;
  4486. private _position;
  4487. private _localDirection;
  4488. private _volume;
  4489. private _isReadyToPlay;
  4490. isPlaying: boolean;
  4491. isPaused: boolean;
  4492. private _isDirectional;
  4493. private _readyToPlayCallback;
  4494. private _audioBuffer;
  4495. private _soundSource;
  4496. private _streamingSource;
  4497. private _soundPanner;
  4498. private _soundGain;
  4499. private _inputAudioNode;
  4500. private _ouputAudioNode;
  4501. private _coneInnerAngle;
  4502. private _coneOuterAngle;
  4503. private _coneOuterGain;
  4504. private _scene;
  4505. private _connectedMesh;
  4506. private _customAttenuationFunction;
  4507. private _registerFunc;
  4508. private _isOutputConnected;
  4509. private _htmlAudioElement;
  4510. private _urlType;
  4511. /**
  4512. * Create a sound and attach it to a scene
  4513. * @param name Name of your sound
  4514. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  4515. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4516. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4517. */
  4518. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4519. dispose(): void;
  4520. isReady(): boolean;
  4521. private _soundLoaded(audioData);
  4522. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4523. updateOptions(options: any): void;
  4524. private _createSpatialParameters();
  4525. private _updateSpatialParameters();
  4526. switchPanningModelToHRTF(): void;
  4527. switchPanningModelToEqualPower(): void;
  4528. private _switchPanningModel();
  4529. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4530. /**
  4531. * Transform this sound into a directional source
  4532. * @param coneInnerAngle Size of the inner cone in degree
  4533. * @param coneOuterAngle Size of the outer cone in degree
  4534. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4535. */
  4536. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4537. setPosition(newPosition: Vector3): void;
  4538. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4539. private _updateDirection();
  4540. updateDistanceFromListener(): void;
  4541. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4542. /**
  4543. * Play the sound
  4544. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4545. * @param offset (optional) Start the sound setting it at a specific time
  4546. */
  4547. play(time?: number, offset?: number): void;
  4548. private _onended();
  4549. /**
  4550. * Stop the sound
  4551. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4552. */
  4553. stop(time?: number): void;
  4554. pause(): void;
  4555. setVolume(newVolume: number, time?: number): void;
  4556. setPlaybackRate(newPlaybackRate: number): void;
  4557. getVolume(): number;
  4558. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4559. detachFromMesh(): void;
  4560. private _onRegisterAfterWorldMatrixUpdate(node);
  4561. clone(): Nullable<Sound>;
  4562. getAudioBuffer(): AudioBuffer | null;
  4563. serialize(): any;
  4564. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4565. }
  4566. }
  4567. declare module BABYLON {
  4568. class SoundTrack {
  4569. private _outputAudioNode;
  4570. private _scene;
  4571. id: number;
  4572. soundCollection: Array<Sound>;
  4573. private _isMainTrack;
  4574. private _connectedAnalyser;
  4575. private _options;
  4576. private _isInitialized;
  4577. constructor(scene: Scene, options?: any);
  4578. private _initializeSoundTrackAudioGraph();
  4579. dispose(): void;
  4580. AddSound(sound: Sound): void;
  4581. RemoveSound(sound: Sound): void;
  4582. setVolume(newVolume: number): void;
  4583. switchPanningModelToHRTF(): void;
  4584. switchPanningModelToEqualPower(): void;
  4585. connectToAnalyser(analyser: Analyser): void;
  4586. }
  4587. }
  4588. declare module BABYLON {
  4589. interface Behavior<T extends Node> {
  4590. name: string;
  4591. init(): void;
  4592. attach(node: T): void;
  4593. detach(): void;
  4594. }
  4595. }
  4596. declare module BABYLON {
  4597. /**
  4598. * Class used to store bone information
  4599. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4600. */
  4601. class Bone extends Node {
  4602. /**
  4603. * defines the bone name
  4604. */
  4605. name: string;
  4606. private static _tmpVecs;
  4607. private static _tmpQuat;
  4608. private static _tmpMats;
  4609. /**
  4610. * Gets the list of child bones
  4611. */
  4612. children: Bone[];
  4613. /** Gets the animations associated with this bone */
  4614. animations: Animation[];
  4615. /**
  4616. * Gets or sets bone length
  4617. */
  4618. length: number;
  4619. /**
  4620. * @hidden Internal only
  4621. * Set this value to map this bone to a different index in the transform matrices
  4622. * Set this value to -1 to exclude the bone from the transform matrices
  4623. */
  4624. _index: Nullable<number>;
  4625. private _skeleton;
  4626. private _localMatrix;
  4627. private _restPose;
  4628. private _baseMatrix;
  4629. private _absoluteTransform;
  4630. private _invertedAbsoluteTransform;
  4631. private _parent;
  4632. private _scalingDeterminant;
  4633. private _worldTransform;
  4634. private _localScaling;
  4635. private _localRotation;
  4636. private _localPosition;
  4637. private _needToDecompose;
  4638. private _needToCompose;
  4639. /** @hidden */
  4640. /** @hidden */
  4641. _matrix: Matrix;
  4642. /**
  4643. * Create a new bone
  4644. * @param name defines the bone name
  4645. * @param skeleton defines the parent skeleton
  4646. * @param parentBone defines the parent (can be null if the bone is the root)
  4647. * @param localMatrix defines the local matrix
  4648. * @param restPose defines the rest pose matrix
  4649. * @param baseMatrix defines the base matrix
  4650. * @param index defines index of the bone in the hiearchy
  4651. */
  4652. constructor(
  4653. /**
  4654. * defines the bone name
  4655. */
  4656. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4657. /**
  4658. * Gets the parent skeleton
  4659. * @returns a skeleton
  4660. */
  4661. getSkeleton(): Skeleton;
  4662. /**
  4663. * Gets parent bone
  4664. * @returns a bone or null if the bone is the root of the bone hierarchy
  4665. */
  4666. getParent(): Nullable<Bone>;
  4667. /**
  4668. * Sets the parent bone
  4669. * @param parent defines the parent (can be null if the bone is the root)
  4670. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4671. */
  4672. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4673. /**
  4674. * Gets the local matrix
  4675. * @returns a matrix
  4676. */
  4677. getLocalMatrix(): Matrix;
  4678. /**
  4679. * Gets the base matrix (initial matrix which remains unchanged)
  4680. * @returns a matrix
  4681. */
  4682. getBaseMatrix(): Matrix;
  4683. /**
  4684. * Gets the rest pose matrix
  4685. * @returns a matrix
  4686. */
  4687. getRestPose(): Matrix;
  4688. /**
  4689. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  4690. */
  4691. getWorldMatrix(): Matrix;
  4692. /**
  4693. * Sets the local matrix to rest pose matrix
  4694. */
  4695. returnToRest(): void;
  4696. /**
  4697. * Gets the inverse of the absolute transform matrix.
  4698. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  4699. * @returns a matrix
  4700. */
  4701. getInvertedAbsoluteTransform(): Matrix;
  4702. /**
  4703. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  4704. * @returns a matrix
  4705. */
  4706. getAbsoluteTransform(): Matrix;
  4707. /** Gets or sets current position (in local space) */
  4708. position: Vector3;
  4709. /** Gets or sets current rotation (in local space) */
  4710. rotation: Vector3;
  4711. /** Gets or sets current rotation quaternion (in local space) */
  4712. rotationQuaternion: Quaternion;
  4713. /** Gets or sets current scaling (in local space) */
  4714. scaling: Vector3;
  4715. /**
  4716. * Gets the animation properties override
  4717. */
  4718. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4719. private _decompose();
  4720. private _compose();
  4721. /**
  4722. * Update the base and local matrices
  4723. * @param matrix defines the new base or local matrix
  4724. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4725. * @param updateLocalMatrix defines if the local matrix should be updated
  4726. */
  4727. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  4728. /** @hidden */
  4729. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  4730. /**
  4731. * Flag the bone as dirty (Forcing it to update everything)
  4732. */
  4733. markAsDirty(): void;
  4734. private _markAsDirtyAndCompose();
  4735. private _markAsDirtyAndDecompose();
  4736. /**
  4737. * Copy an animation range from another bone
  4738. * @param source defines the source bone
  4739. * @param rangeName defines the range name to copy
  4740. * @param frameOffset defines the frame offset
  4741. * @param rescaleAsRequired defines if rescaling must be applied if required
  4742. * @param skelDimensionsRatio defines the scaling ratio
  4743. * @returns true if operation was successful
  4744. */
  4745. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  4746. /**
  4747. * Translate the bone in local or world space
  4748. * @param vec The amount to translate the bone
  4749. * @param space The space that the translation is in
  4750. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4751. */
  4752. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4753. /**
  4754. * Set the postion of the bone in local or world space
  4755. * @param position The position to set the bone
  4756. * @param space The space that the position is in
  4757. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4758. */
  4759. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4760. /**
  4761. * Set the absolute position of the bone (world space)
  4762. * @param position The position to set the bone
  4763. * @param mesh The mesh that this bone is attached to
  4764. */
  4765. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  4766. /**
  4767. * Scale the bone on the x, y and z axes (in local space)
  4768. * @param x The amount to scale the bone on the x axis
  4769. * @param y The amount to scale the bone on the y axis
  4770. * @param z The amount to scale the bone on the z axis
  4771. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  4772. */
  4773. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  4774. /**
  4775. * Set the bone scaling in local space
  4776. * @param scale defines the scaling vector
  4777. */
  4778. setScale(scale: Vector3): void;
  4779. /**
  4780. * Gets the current scaling in local space
  4781. * @returns the current scaling vector
  4782. */
  4783. getScale(): Vector3;
  4784. /**
  4785. * Gets the current scaling in local space and stores it in a target vector
  4786. * @param result defines the target vector
  4787. */
  4788. getScaleToRef(result: Vector3): void;
  4789. /**
  4790. * Set the yaw, pitch, and roll of the bone in local or world space
  4791. * @param yaw The rotation of the bone on the y axis
  4792. * @param pitch The rotation of the bone on the x axis
  4793. * @param roll The rotation of the bone on the z axis
  4794. * @param space The space that the axes of rotation are in
  4795. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4796. */
  4797. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  4798. /**
  4799. * Add a rotation to the bone on an axis in local or world space
  4800. * @param axis The axis to rotate the bone on
  4801. * @param amount The amount to rotate the bone
  4802. * @param space The space that the axis is in
  4803. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4804. */
  4805. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  4806. /**
  4807. * Set the rotation of the bone to a particular axis angle in local or world space
  4808. * @param axis The axis to rotate the bone on
  4809. * @param angle The angle that the bone should be rotated to
  4810. * @param space The space that the axis is in
  4811. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4812. */
  4813. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  4814. /**
  4815. * Set the euler rotation of the bone in local of world space
  4816. * @param rotation The euler rotation that the bone should be set to
  4817. * @param space The space that the rotation is in
  4818. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4819. */
  4820. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4821. /**
  4822. * Set the quaternion rotation of the bone in local of world space
  4823. * @param quat The quaternion rotation that the bone should be set to
  4824. * @param space The space that the rotation is in
  4825. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4826. */
  4827. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  4828. /**
  4829. * Set the rotation matrix of the bone in local of world space
  4830. * @param rotMat The rotation matrix that the bone should be set to
  4831. * @param space The space that the rotation is in
  4832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4833. */
  4834. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  4835. private _rotateWithMatrix(rmat, space?, mesh?);
  4836. private _getNegativeRotationToRef(rotMatInv, mesh?);
  4837. /**
  4838. * Get the position of the bone in local or world space
  4839. * @param space The space that the returned position is in
  4840. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4841. * @returns The position of the bone
  4842. */
  4843. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4844. /**
  4845. * Copy the position of the bone to a vector3 in local or world space
  4846. * @param space The space that the returned position is in
  4847. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4848. * @param result The vector3 to copy the position to
  4849. */
  4850. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  4851. /**
  4852. * Get the absolute position of the bone (world space)
  4853. * @param mesh The mesh that this bone is attached to
  4854. * @returns The absolute position of the bone
  4855. */
  4856. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  4857. /**
  4858. * Copy the absolute position of the bone (world space) to the result param
  4859. * @param mesh The mesh that this bone is attached to
  4860. * @param result The vector3 to copy the absolute position to
  4861. */
  4862. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  4863. /**
  4864. * Compute the absolute transforms of this bone and its children
  4865. */
  4866. computeAbsoluteTransforms(): void;
  4867. /**
  4868. * Get the world direction from an axis that is in the local space of the bone
  4869. * @param localAxis The local direction that is used to compute the world direction
  4870. * @param mesh The mesh that this bone is attached to
  4871. * @returns The world direction
  4872. */
  4873. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4874. /**
  4875. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  4876. * @param localAxis The local direction that is used to compute the world direction
  4877. * @param mesh The mesh that this bone is attached to
  4878. * @param result The vector3 that the world direction will be copied to
  4879. */
  4880. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4881. /**
  4882. * Get the euler rotation of the bone in local or world space
  4883. * @param space The space that the rotation should be in
  4884. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4885. * @returns The euler rotation
  4886. */
  4887. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4888. /**
  4889. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  4890. * @param space The space that the rotation should be in
  4891. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4892. * @param result The vector3 that the rotation should be copied to
  4893. */
  4894. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4895. /**
  4896. * Get the quaternion rotation of the bone in either local or world space
  4897. * @param space The space that the rotation should be in
  4898. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4899. * @returns The quaternion rotation
  4900. */
  4901. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  4902. /**
  4903. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  4904. * @param space The space that the rotation should be in
  4905. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4906. * @param result The quaternion that the rotation should be copied to
  4907. */
  4908. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  4909. /**
  4910. * Get the rotation matrix of the bone in local or world space
  4911. * @param space The space that the rotation should be in
  4912. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4913. * @returns The rotation matrix
  4914. */
  4915. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  4916. /**
  4917. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  4918. * @param space The space that the rotation should be in
  4919. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4920. * @param result The quaternion that the rotation should be copied to
  4921. */
  4922. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  4923. /**
  4924. * Get the world position of a point that is in the local space of the bone
  4925. * @param position The local position
  4926. * @param mesh The mesh that this bone is attached to
  4927. * @returns The world position
  4928. */
  4929. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4930. /**
  4931. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  4932. * @param position The local position
  4933. * @param mesh The mesh that this bone is attached to
  4934. * @param result The vector3 that the world position should be copied to
  4935. */
  4936. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4937. /**
  4938. * Get the local position of a point that is in world space
  4939. * @param position The world position
  4940. * @param mesh The mesh that this bone is attached to
  4941. * @returns The local position
  4942. */
  4943. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4944. /**
  4945. * Get the local position of a point that is in world space and copy it to the result param
  4946. * @param position The world position
  4947. * @param mesh The mesh that this bone is attached to
  4948. * @param result The vector3 that the local position should be copied to
  4949. */
  4950. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4951. }
  4952. }
  4953. declare module BABYLON {
  4954. /**
  4955. * Class used to apply inverse kinematics to bones
  4956. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  4957. */
  4958. class BoneIKController {
  4959. private static _tmpVecs;
  4960. private static _tmpQuat;
  4961. private static _tmpMats;
  4962. /**
  4963. * Gets or sets the target mesh
  4964. */
  4965. targetMesh: AbstractMesh;
  4966. /** Gets or sets the mesh used as pole */
  4967. poleTargetMesh: AbstractMesh;
  4968. /**
  4969. * Gets or sets the bone used as pole
  4970. */
  4971. poleTargetBone: Nullable<Bone>;
  4972. /**
  4973. * Gets or sets the target position
  4974. */
  4975. targetPosition: Vector3;
  4976. /**
  4977. * Gets or sets the pole target position
  4978. */
  4979. poleTargetPosition: Vector3;
  4980. /**
  4981. * Gets or sets the pole target local offset
  4982. */
  4983. poleTargetLocalOffset: Vector3;
  4984. /**
  4985. * Gets or sets the pole angle
  4986. */
  4987. poleAngle: number;
  4988. /**
  4989. * Gets or sets the mesh associated with the controller
  4990. */
  4991. mesh: AbstractMesh;
  4992. /**
  4993. * 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)
  4994. */
  4995. slerpAmount: number;
  4996. private _bone1Quat;
  4997. private _bone1Mat;
  4998. private _bone2Ang;
  4999. private _bone1;
  5000. private _bone2;
  5001. private _bone1Length;
  5002. private _bone2Length;
  5003. private _maxAngle;
  5004. private _maxReach;
  5005. private _rightHandedSystem;
  5006. private _bendAxis;
  5007. private _slerping;
  5008. private _adjustRoll;
  5009. /**
  5010. * Gets or sets maximum allowed angle
  5011. */
  5012. maxAngle: number;
  5013. /**
  5014. * Creates a new BoneIKController
  5015. * @param mesh defines the mesh to control
  5016. * @param bone defines the bone to control
  5017. * @param options defines options to set up the controller
  5018. */
  5019. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5020. targetMesh?: AbstractMesh;
  5021. poleTargetMesh?: AbstractMesh;
  5022. poleTargetBone?: Bone;
  5023. poleTargetLocalOffset?: Vector3;
  5024. poleAngle?: number;
  5025. bendAxis?: Vector3;
  5026. maxAngle?: number;
  5027. slerpAmount?: number;
  5028. });
  5029. private _setMaxAngle(ang);
  5030. /**
  5031. * Force the controller to update the bones
  5032. */
  5033. update(): void;
  5034. }
  5035. }
  5036. declare module BABYLON {
  5037. /**
  5038. * Class used to make a bone look toward a point in space
  5039. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5040. */
  5041. class BoneLookController {
  5042. private static _tmpVecs;
  5043. private static _tmpQuat;
  5044. private static _tmpMats;
  5045. /**
  5046. * The target Vector3 that the bone will look at
  5047. */
  5048. target: Vector3;
  5049. /**
  5050. * The mesh that the bone is attached to
  5051. */
  5052. mesh: AbstractMesh;
  5053. /**
  5054. * The bone that will be looking to the target
  5055. */
  5056. bone: Bone;
  5057. /**
  5058. * The up axis of the coordinate system that is used when the bone is rotated
  5059. */
  5060. upAxis: Vector3;
  5061. /**
  5062. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5063. */
  5064. upAxisSpace: Space;
  5065. /**
  5066. * Used to make an adjustment to the yaw of the bone
  5067. */
  5068. adjustYaw: number;
  5069. /**
  5070. * Used to make an adjustment to the pitch of the bone
  5071. */
  5072. adjustPitch: number;
  5073. /**
  5074. * Used to make an adjustment to the roll of the bone
  5075. */
  5076. adjustRoll: number;
  5077. /**
  5078. * 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)
  5079. */
  5080. slerpAmount: number;
  5081. private _minYaw;
  5082. private _maxYaw;
  5083. private _minPitch;
  5084. private _maxPitch;
  5085. private _minYawSin;
  5086. private _minYawCos;
  5087. private _maxYawSin;
  5088. private _maxYawCos;
  5089. private _midYawConstraint;
  5090. private _minPitchTan;
  5091. private _maxPitchTan;
  5092. private _boneQuat;
  5093. private _slerping;
  5094. private _transformYawPitch;
  5095. private _transformYawPitchInv;
  5096. private _firstFrameSkipped;
  5097. private _yawRange;
  5098. private _fowardAxis;
  5099. /**
  5100. * Gets or sets the minimum yaw angle that the bone can look to
  5101. */
  5102. minYaw: number;
  5103. /**
  5104. * Gets or sets the maximum yaw angle that the bone can look to
  5105. */
  5106. maxYaw: number;
  5107. /**
  5108. * Gets or sets the minimum pitch angle that the bone can look to
  5109. */
  5110. minPitch: number;
  5111. /**
  5112. * Gets or sets the maximum pitch angle that the bone can look to
  5113. */
  5114. maxPitch: number;
  5115. /**
  5116. * Create a BoneLookController
  5117. * @param mesh the mesh that the bone belongs to
  5118. * @param bone the bone that will be looking to the target
  5119. * @param target the target Vector3 to look at
  5120. * @param settings optional settings:
  5121. * * maxYaw: the maximum angle the bone will yaw to
  5122. * * minYaw: the minimum angle the bone will yaw to
  5123. * * maxPitch: the maximum angle the bone will pitch to
  5124. * * minPitch: the minimum angle the bone will yaw to
  5125. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5126. * * upAxis: the up axis of the coordinate system
  5127. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5128. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5129. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5130. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5131. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5132. * * adjustRoll: used to make an adjustment to the roll of the bone
  5133. **/
  5134. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5135. maxYaw?: number;
  5136. minYaw?: number;
  5137. maxPitch?: number;
  5138. minPitch?: number;
  5139. slerpAmount?: number;
  5140. upAxis?: Vector3;
  5141. upAxisSpace?: Space;
  5142. yawAxis?: Vector3;
  5143. pitchAxis?: Vector3;
  5144. adjustYaw?: number;
  5145. adjustPitch?: number;
  5146. adjustRoll?: number;
  5147. });
  5148. /**
  5149. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5150. */
  5151. update(): void;
  5152. private _getAngleDiff(ang1, ang2);
  5153. private _getAngleBetween(ang1, ang2);
  5154. private _isAngleBetween(ang, ang1, ang2);
  5155. }
  5156. }
  5157. declare module BABYLON {
  5158. /**
  5159. * Class used to handle skinning animations
  5160. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5161. */
  5162. class Skeleton implements IAnimatable {
  5163. /** defines the skeleton name */
  5164. name: string;
  5165. /** defines the skeleton Id */
  5166. id: string;
  5167. /**
  5168. * Gets the list of child bones
  5169. */
  5170. bones: Bone[];
  5171. /**
  5172. * Gets an estimate of the dimension of the skeleton at rest
  5173. */
  5174. dimensionsAtRest: Vector3;
  5175. /**
  5176. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5177. */
  5178. needInitialSkinMatrix: boolean;
  5179. /**
  5180. * Gets the list of animations attached to this skeleton
  5181. */
  5182. animations: Array<Animation>;
  5183. private _scene;
  5184. private _isDirty;
  5185. private _transformMatrices;
  5186. private _meshesWithPoseMatrix;
  5187. private _animatables;
  5188. private _identity;
  5189. private _synchronizedWithMesh;
  5190. private _ranges;
  5191. private _lastAbsoluteTransformsUpdateId;
  5192. /**
  5193. * Specifies if the skeleton should be serialized
  5194. */
  5195. doNotSerialize: boolean;
  5196. private _animationPropertiesOverride;
  5197. /**
  5198. * Gets or sets the animation properties override
  5199. */
  5200. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5201. /**
  5202. * An observable triggered before computing the skeleton's matrices
  5203. */
  5204. onBeforeComputeObservable: Observable<Skeleton>;
  5205. /**
  5206. * Creates a new skeleton
  5207. * @param name defines the skeleton name
  5208. * @param id defines the skeleton Id
  5209. * @param scene defines the hosting scene
  5210. */
  5211. constructor(
  5212. /** defines the skeleton name */
  5213. name: string,
  5214. /** defines the skeleton Id */
  5215. id: string, scene: Scene);
  5216. /**
  5217. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5218. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5219. * @returns a Float32Array containing matrices data
  5220. */
  5221. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5222. /**
  5223. * Gets the current hosting scene
  5224. * @returns a scene object
  5225. */
  5226. getScene(): Scene;
  5227. /**
  5228. * Gets a string representing the current skeleton data
  5229. * @param fullDetails defines a boolean indicating if we want a verbose version
  5230. * @returns a string representing the current skeleton data
  5231. */
  5232. toString(fullDetails?: boolean): string;
  5233. /**
  5234. * Get bone's index searching by name
  5235. * @param name defines bone's name to search for
  5236. * @return the indice of the bone. Returns -1 if not found
  5237. */
  5238. getBoneIndexByName(name: string): number;
  5239. /**
  5240. * Creater a new animation range
  5241. * @param name defines the name of the range
  5242. * @param from defines the start key
  5243. * @param to defines the end key
  5244. */
  5245. createAnimationRange(name: string, from: number, to: number): void;
  5246. /**
  5247. * Delete a specific animation range
  5248. * @param name defines the name of the range
  5249. * @param deleteFrames defines if frames must be removed as well
  5250. */
  5251. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5252. /**
  5253. * Gets a specific animation range
  5254. * @param name defines the name of the range to look for
  5255. * @returns the requested animation range or null if not found
  5256. */
  5257. getAnimationRange(name: string): Nullable<AnimationRange>;
  5258. /**
  5259. * Gets the list of all animation ranges defined on this skeleton
  5260. * @returns an array
  5261. */
  5262. getAnimationRanges(): Nullable<AnimationRange>[];
  5263. /**
  5264. * Copy animation range from a source skeleton.
  5265. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5266. * @param source defines the source skeleton
  5267. * @param name defines the name of the range to copy
  5268. * @param rescaleAsRequired defines if rescaling must be applied if required
  5269. * @returns true if operation was successful
  5270. */
  5271. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5272. /**
  5273. * Forces the skeleton to go to rest pose
  5274. */
  5275. returnToRest(): void;
  5276. private _getHighestAnimationFrame();
  5277. /**
  5278. * Begin a specific animation range
  5279. * @param name defines the name of the range to start
  5280. * @param loop defines if looping must be turned on (false by default)
  5281. * @param speedRatio defines the speed ratio to apply (1 by default)
  5282. * @param onAnimationEnd defines a callback which will be called when animation will end
  5283. * @returns a new animatable
  5284. */
  5285. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5286. /** @hidden */
  5287. _markAsDirty(): void;
  5288. /** @hidden */
  5289. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5290. /** @hidden */
  5291. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5292. /** @hidden */
  5293. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5294. /**
  5295. * Build all resources required to render a skeleton
  5296. */
  5297. prepare(): void;
  5298. /**
  5299. * Gets the list of animatables currently running for this skeleton
  5300. * @returns an array of animatables
  5301. */
  5302. getAnimatables(): IAnimatable[];
  5303. /**
  5304. * Clone the current skeleton
  5305. * @param name defines the name of the new skeleton
  5306. * @param id defines the id of the enw skeleton
  5307. * @returns the new skeleton
  5308. */
  5309. clone(name: string, id: string): Skeleton;
  5310. /**
  5311. * Enable animation blending for this skeleton
  5312. * @param blendingSpeed defines the blending speed to apply
  5313. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5314. */
  5315. enableBlending(blendingSpeed?: number): void;
  5316. /**
  5317. * Releases all resources associated with the current skeleton
  5318. */
  5319. dispose(): void;
  5320. /**
  5321. * Serialize the skeleton in a JSON object
  5322. * @returns a JSON object
  5323. */
  5324. serialize(): any;
  5325. /**
  5326. * Creates a new skeleton from serialized data
  5327. * @param parsedSkeleton defines the serialized data
  5328. * @param scene defines the hosting scene
  5329. * @returns a new skeleton
  5330. */
  5331. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5332. /**
  5333. * Compute all node absolute transforms
  5334. * @param forceUpdate defines if computation must be done even if cache is up to date
  5335. */
  5336. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5337. /**
  5338. * Gets the root pose matrix
  5339. * @returns a matrix
  5340. */
  5341. getPoseMatrix(): Nullable<Matrix>;
  5342. /**
  5343. * Sorts bones per internal index
  5344. */
  5345. sortBones(): void;
  5346. private _sortBones(index, bones, visited);
  5347. }
  5348. }
  5349. declare module BABYLON {
  5350. class Collider {
  5351. /** Define if a collision was found */
  5352. collisionFound: boolean;
  5353. /**
  5354. * Define last intersection point in local space
  5355. */
  5356. intersectionPoint: Vector3;
  5357. /**
  5358. * Define last collided mesh
  5359. */
  5360. collidedMesh: Nullable<AbstractMesh>;
  5361. private _collisionPoint;
  5362. private _planeIntersectionPoint;
  5363. private _tempVector;
  5364. private _tempVector2;
  5365. private _tempVector3;
  5366. private _tempVector4;
  5367. private _edge;
  5368. private _baseToVertex;
  5369. private _destinationPoint;
  5370. private _slidePlaneNormal;
  5371. private _displacementVector;
  5372. _radius: Vector3;
  5373. _retry: number;
  5374. private _velocity;
  5375. private _basePoint;
  5376. private _epsilon;
  5377. _velocityWorldLength: number;
  5378. _basePointWorld: Vector3;
  5379. private _velocityWorld;
  5380. private _normalizedVelocity;
  5381. _initialVelocity: Vector3;
  5382. _initialPosition: Vector3;
  5383. private _nearestDistance;
  5384. private _collisionMask;
  5385. collisionMask: number;
  5386. /**
  5387. * Gets the plane normal used to compute the sliding response (in local space)
  5388. */
  5389. readonly slidePlaneNormal: Vector3;
  5390. _initialize(source: Vector3, dir: Vector3, e: number): void;
  5391. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  5392. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  5393. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  5394. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  5395. _getResponse(pos: Vector3, vel: Vector3): void;
  5396. }
  5397. }
  5398. declare module BABYLON {
  5399. var CollisionWorker: string;
  5400. interface ICollisionCoordinator {
  5401. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5402. init(scene: Scene): void;
  5403. destroy(): void;
  5404. onMeshAdded(mesh: AbstractMesh): void;
  5405. onMeshUpdated(mesh: AbstractMesh): void;
  5406. onMeshRemoved(mesh: AbstractMesh): void;
  5407. onGeometryAdded(geometry: Geometry): void;
  5408. onGeometryUpdated(geometry: Geometry): void;
  5409. onGeometryDeleted(geometry: Geometry): void;
  5410. }
  5411. interface SerializedMesh {
  5412. id: string;
  5413. name: string;
  5414. uniqueId: number;
  5415. geometryId: Nullable<string>;
  5416. sphereCenter: Array<number>;
  5417. sphereRadius: number;
  5418. boxMinimum: Array<number>;
  5419. boxMaximum: Array<number>;
  5420. worldMatrixFromCache: any;
  5421. subMeshes: Array<SerializedSubMesh>;
  5422. checkCollisions: boolean;
  5423. }
  5424. interface SerializedSubMesh {
  5425. position: number;
  5426. verticesStart: number;
  5427. verticesCount: number;
  5428. indexStart: number;
  5429. indexCount: number;
  5430. hasMaterial: boolean;
  5431. sphereCenter: Array<number>;
  5432. sphereRadius: number;
  5433. boxMinimum: Array<number>;
  5434. boxMaximum: Array<number>;
  5435. }
  5436. /**
  5437. * Interface describing the value associated with a geometry
  5438. */
  5439. interface SerializedGeometry {
  5440. /**
  5441. * Defines the unique ID of the geometry
  5442. */
  5443. id: string;
  5444. /**
  5445. * Defines the array containing the positions
  5446. */
  5447. positions: Float32Array;
  5448. /**
  5449. * Defines the array containing the indices
  5450. */
  5451. indices: Uint32Array;
  5452. /**
  5453. * Defines the array containing the normals
  5454. */
  5455. normals: Float32Array;
  5456. }
  5457. interface BabylonMessage {
  5458. taskType: WorkerTaskType;
  5459. payload: InitPayload | CollidePayload | UpdatePayload;
  5460. }
  5461. interface SerializedColliderToWorker {
  5462. position: Array<number>;
  5463. velocity: Array<number>;
  5464. radius: Array<number>;
  5465. }
  5466. /** Defines supported task for worker process */
  5467. enum WorkerTaskType {
  5468. /** Initialization */
  5469. INIT = 0,
  5470. /** Update of geometry */
  5471. UPDATE = 1,
  5472. /** Evaluate collision */
  5473. COLLIDE = 2,
  5474. }
  5475. interface WorkerReply {
  5476. error: WorkerReplyType;
  5477. taskType: WorkerTaskType;
  5478. payload?: any;
  5479. }
  5480. interface CollisionReplyPayload {
  5481. newPosition: Array<number>;
  5482. collisionId: number;
  5483. collidedMeshUniqueId: number;
  5484. }
  5485. interface InitPayload {
  5486. }
  5487. interface CollidePayload {
  5488. collisionId: number;
  5489. collider: SerializedColliderToWorker;
  5490. maximumRetry: number;
  5491. excludedMeshUniqueId: Nullable<number>;
  5492. }
  5493. interface UpdatePayload {
  5494. updatedMeshes: {
  5495. [n: number]: SerializedMesh;
  5496. };
  5497. updatedGeometries: {
  5498. [s: string]: SerializedGeometry;
  5499. };
  5500. removedMeshes: Array<number>;
  5501. removedGeometries: Array<string>;
  5502. }
  5503. /** Defines kind of replies returned by worker */
  5504. enum WorkerReplyType {
  5505. /** Success */
  5506. SUCCESS = 0,
  5507. /** Unkown error */
  5508. UNKNOWN_ERROR = 1,
  5509. }
  5510. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  5511. private _scene;
  5512. private _scaledPosition;
  5513. private _scaledVelocity;
  5514. private _collisionsCallbackArray;
  5515. private _init;
  5516. private _runningUpdated;
  5517. private _worker;
  5518. private _addUpdateMeshesList;
  5519. private _addUpdateGeometriesList;
  5520. private _toRemoveMeshesArray;
  5521. private _toRemoveGeometryArray;
  5522. constructor();
  5523. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  5524. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  5525. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5526. init(scene: Scene): void;
  5527. destroy(): void;
  5528. onMeshAdded(mesh: AbstractMesh): void;
  5529. onMeshUpdated: (transformNode: TransformNode) => void;
  5530. onMeshRemoved(mesh: AbstractMesh): void;
  5531. onGeometryAdded(geometry: Geometry): void;
  5532. onGeometryUpdated: (geometry: Geometry) => void;
  5533. onGeometryDeleted(geometry: Geometry): void;
  5534. private _afterRender;
  5535. private _onMessageFromWorker;
  5536. }
  5537. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  5538. private _scene;
  5539. private _scaledPosition;
  5540. private _scaledVelocity;
  5541. private _finalPosition;
  5542. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5543. init(scene: Scene): void;
  5544. destroy(): void;
  5545. onMeshAdded(mesh: AbstractMesh): void;
  5546. onMeshUpdated(mesh: AbstractMesh): void;
  5547. onMeshRemoved(mesh: AbstractMesh): void;
  5548. onGeometryAdded(geometry: Geometry): void;
  5549. onGeometryUpdated(geometry: Geometry): void;
  5550. onGeometryDeleted(geometry: Geometry): void;
  5551. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  5552. }
  5553. }
  5554. declare function importScripts(...urls: string[]): void;
  5555. declare const safePostMessage: any;
  5556. declare module BABYLON {
  5557. var WorkerIncluded: boolean;
  5558. class CollisionCache {
  5559. private _meshes;
  5560. private _geometries;
  5561. getMeshes(): {
  5562. [n: number]: SerializedMesh;
  5563. };
  5564. getGeometries(): {
  5565. [s: number]: SerializedGeometry;
  5566. };
  5567. getMesh(id: any): SerializedMesh;
  5568. addMesh(mesh: SerializedMesh): void;
  5569. removeMesh(uniqueId: number): void;
  5570. getGeometry(id: string): SerializedGeometry;
  5571. addGeometry(geometry: SerializedGeometry): void;
  5572. removeGeometry(id: string): void;
  5573. }
  5574. class CollideWorker {
  5575. collider: Collider;
  5576. private _collisionCache;
  5577. private finalPosition;
  5578. private collisionsScalingMatrix;
  5579. private collisionTranformationMatrix;
  5580. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5581. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  5582. private checkCollision(mesh);
  5583. private processCollisionsForSubMeshes(transformMatrix, mesh);
  5584. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  5585. private checkSubmeshCollision(subMesh);
  5586. }
  5587. interface ICollisionDetector {
  5588. onInit(payload: InitPayload): void;
  5589. onUpdate(payload: UpdatePayload): void;
  5590. onCollision(payload: CollidePayload): void;
  5591. }
  5592. class CollisionDetectorTransferable implements ICollisionDetector {
  5593. private _collisionCache;
  5594. onInit(payload: InitPayload): void;
  5595. onUpdate(payload: UpdatePayload): void;
  5596. onCollision(payload: CollidePayload): void;
  5597. }
  5598. }
  5599. declare module BABYLON {
  5600. class IntersectionInfo {
  5601. bu: Nullable<number>;
  5602. bv: Nullable<number>;
  5603. distance: number;
  5604. faceId: number;
  5605. subMeshId: number;
  5606. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  5607. }
  5608. class PickingInfo {
  5609. hit: boolean;
  5610. distance: number;
  5611. pickedPoint: Nullable<Vector3>;
  5612. pickedMesh: Nullable<AbstractMesh>;
  5613. bu: number;
  5614. bv: number;
  5615. faceId: number;
  5616. subMeshId: number;
  5617. pickedSprite: Nullable<Sprite>;
  5618. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  5619. getTextureCoordinates(): Nullable<Vector2>;
  5620. }
  5621. }
  5622. /**
  5623. * Module Debug contains the (visual) components to debug a scene correctly
  5624. */
  5625. declare module BABYLON.Debug {
  5626. /**
  5627. * The Axes viewer will show 3 axes in a specific point in space
  5628. */
  5629. class AxesViewer {
  5630. private _xline;
  5631. private _yline;
  5632. private _zline;
  5633. private _xmesh;
  5634. private _ymesh;
  5635. private _zmesh;
  5636. scene: Nullable<Scene>;
  5637. scaleLines: number;
  5638. constructor(scene: Scene, scaleLines?: number);
  5639. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  5640. dispose(): void;
  5641. }
  5642. }
  5643. declare module BABYLON.Debug {
  5644. /**
  5645. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  5646. */
  5647. class BoneAxesViewer extends AxesViewer {
  5648. mesh: Nullable<Mesh>;
  5649. bone: Nullable<Bone>;
  5650. pos: Vector3;
  5651. xaxis: Vector3;
  5652. yaxis: Vector3;
  5653. zaxis: Vector3;
  5654. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  5655. update(): void;
  5656. dispose(): void;
  5657. }
  5658. }
  5659. declare module BABYLON {
  5660. class DebugLayer {
  5661. private _scene;
  5662. static InspectorURL: string;
  5663. private _inspector;
  5664. private BJSINSPECTOR;
  5665. constructor(scene: Scene);
  5666. /** Creates the inspector window. */
  5667. private _createInspector(config?);
  5668. isVisible(): boolean;
  5669. hide(): void;
  5670. show(config?: {
  5671. popup?: boolean;
  5672. initialTab?: number;
  5673. parentElement?: HTMLElement;
  5674. newColors?: {
  5675. backgroundColor?: string;
  5676. backgroundColorLighter?: string;
  5677. backgroundColorLighter2?: string;
  5678. backgroundColorLighter3?: string;
  5679. color?: string;
  5680. colorTop?: string;
  5681. colorBot?: string;
  5682. };
  5683. }): void;
  5684. }
  5685. }
  5686. declare module BABYLON.Debug {
  5687. /**
  5688. * Used to show the physics impostor around the specific mesh.
  5689. */
  5690. class PhysicsViewer {
  5691. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  5692. protected _meshes: Array<Nullable<AbstractMesh>>;
  5693. protected _scene: Nullable<Scene>;
  5694. protected _numMeshes: number;
  5695. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  5696. private _renderFunction;
  5697. private _debugBoxMesh;
  5698. private _debugSphereMesh;
  5699. private _debugMaterial;
  5700. constructor(scene: Scene);
  5701. protected _updateDebugMeshes(): void;
  5702. showImpostor(impostor: PhysicsImpostor): void;
  5703. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  5704. private _getDebugMaterial(scene);
  5705. private _getDebugBoxMesh(scene);
  5706. private _getDebugSphereMesh(scene);
  5707. private _getDebugMesh(impostor, scene);
  5708. dispose(): void;
  5709. }
  5710. }
  5711. declare module BABYLON {
  5712. class RayHelper {
  5713. ray: Nullable<Ray>;
  5714. private _renderPoints;
  5715. private _renderLine;
  5716. private _renderFunction;
  5717. private _scene;
  5718. private _updateToMeshFunction;
  5719. private _attachedToMesh;
  5720. private _meshSpaceDirection;
  5721. private _meshSpaceOrigin;
  5722. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  5723. constructor(ray: Ray);
  5724. show(scene: Scene, color: Color3): void;
  5725. hide(): void;
  5726. private _render();
  5727. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  5728. detachFromMesh(): void;
  5729. private _updateToMesh();
  5730. dispose(): void;
  5731. }
  5732. }
  5733. declare module BABYLON.Debug {
  5734. /**
  5735. * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8
  5736. */
  5737. class SkeletonViewer {
  5738. skeleton: Skeleton;
  5739. mesh: AbstractMesh;
  5740. autoUpdateBonesMatrices: boolean;
  5741. renderingGroupId: number;
  5742. color: Color3;
  5743. private _scene;
  5744. private _debugLines;
  5745. private _debugMesh;
  5746. private _isEnabled;
  5747. private _renderFunction;
  5748. constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number);
  5749. isEnabled: boolean;
  5750. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  5751. private _getLinesForBonesWithLength(bones, meshMat);
  5752. private _getLinesForBonesNoLength(bones, meshMat);
  5753. update(): void;
  5754. dispose(): void;
  5755. }
  5756. }
  5757. declare module BABYLON {
  5758. class BoundingBox implements ICullable {
  5759. vectors: Vector3[];
  5760. center: Vector3;
  5761. centerWorld: Vector3;
  5762. extendSize: Vector3;
  5763. extendSizeWorld: Vector3;
  5764. directions: Vector3[];
  5765. vectorsWorld: Vector3[];
  5766. minimumWorld: Vector3;
  5767. maximumWorld: Vector3;
  5768. minimum: Vector3;
  5769. maximum: Vector3;
  5770. private _worldMatrix;
  5771. /**
  5772. * Creates a new bounding box
  5773. * @param min defines the minimum vector (in local space)
  5774. * @param max defines the maximum vector (in local space)
  5775. */
  5776. constructor(min: Vector3, max: Vector3);
  5777. /**
  5778. * Recreates the entire bounding box from scratch
  5779. * @param min defines the new minimum vector (in local space)
  5780. * @param max defines the new maximum vector (in local space)
  5781. */
  5782. reConstruct(min: Vector3, max: Vector3): void;
  5783. getWorldMatrix(): Matrix;
  5784. setWorldMatrix(matrix: Matrix): BoundingBox;
  5785. _update(world: Matrix): void;
  5786. isInFrustum(frustumPlanes: Plane[]): boolean;
  5787. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5788. intersectsPoint(point: Vector3): boolean;
  5789. intersectsSphere(sphere: BoundingSphere): boolean;
  5790. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  5791. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  5792. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  5793. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5794. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5795. }
  5796. }
  5797. declare module BABYLON {
  5798. interface ICullable {
  5799. isInFrustum(frustumPlanes: Plane[]): boolean;
  5800. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5801. }
  5802. class BoundingInfo implements ICullable {
  5803. minimum: Vector3;
  5804. maximum: Vector3;
  5805. boundingBox: BoundingBox;
  5806. boundingSphere: BoundingSphere;
  5807. private _isLocked;
  5808. constructor(minimum: Vector3, maximum: Vector3);
  5809. isLocked: boolean;
  5810. update(world: Matrix): void;
  5811. /**
  5812. * Recreate the bounding info to be centered around a specific point given a specific extend.
  5813. * @param center New center of the bounding info
  5814. * @param extend New extend of the bounding info
  5815. */
  5816. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  5817. isInFrustum(frustumPlanes: Plane[]): boolean;
  5818. /**
  5819. * Gets the world distance between the min and max points of the bounding box
  5820. */
  5821. readonly diagonalLength: number;
  5822. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5823. _checkCollision(collider: Collider): boolean;
  5824. intersectsPoint(point: Vector3): boolean;
  5825. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  5826. }
  5827. }
  5828. declare module BABYLON {
  5829. class BoundingSphere {
  5830. center: Vector3;
  5831. radius: number;
  5832. centerWorld: Vector3;
  5833. radiusWorld: number;
  5834. minimum: Vector3;
  5835. maximum: Vector3;
  5836. private _tempRadiusVector;
  5837. /**
  5838. * Creates a new bounding sphere
  5839. * @param min defines the minimum vector (in local space)
  5840. * @param max defines the maximum vector (in local space)
  5841. */
  5842. constructor(min: Vector3, max: Vector3);
  5843. /**
  5844. * Recreates the entire bounding sphere from scratch
  5845. * @param min defines the new minimum vector (in local space)
  5846. * @param max defines the new maximum vector (in local space)
  5847. */
  5848. reConstruct(min: Vector3, max: Vector3): void;
  5849. _update(world: Matrix): void;
  5850. isInFrustum(frustumPlanes: Plane[]): boolean;
  5851. intersectsPoint(point: Vector3): boolean;
  5852. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  5853. }
  5854. }
  5855. declare module BABYLON {
  5856. class Ray {
  5857. origin: Vector3;
  5858. direction: Vector3;
  5859. length: number;
  5860. private _edge1;
  5861. private _edge2;
  5862. private _pvec;
  5863. private _tvec;
  5864. private _qvec;
  5865. private _tmpRay;
  5866. constructor(origin: Vector3, direction: Vector3, length?: number);
  5867. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  5868. intersectsBox(box: BoundingBox): boolean;
  5869. intersectsSphere(sphere: BoundingSphere): boolean;
  5870. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  5871. intersectsPlane(plane: Plane): Nullable<number>;
  5872. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  5873. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  5874. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  5875. private static smallnum;
  5876. private static rayl;
  5877. /**
  5878. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  5879. * @param sega the first point of the segment to test the intersection against
  5880. * @param segb the second point of the segment to test the intersection against
  5881. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  5882. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  5883. */
  5884. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  5885. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5886. static Zero(): Ray;
  5887. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5888. /**
  5889. * 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
  5890. * transformed to the given world matrix.
  5891. * @param origin The origin point
  5892. * @param end The end point
  5893. * @param world a matrix to transform the ray to. Default is the identity matrix.
  5894. */
  5895. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  5896. static Transform(ray: Ray, matrix: Matrix): Ray;
  5897. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  5898. }
  5899. }
  5900. declare module BABYLON {
  5901. class KeyboardEventTypes {
  5902. static _KEYDOWN: number;
  5903. static _KEYUP: number;
  5904. static readonly KEYDOWN: number;
  5905. static readonly KEYUP: number;
  5906. }
  5907. class KeyboardInfo {
  5908. type: number;
  5909. event: KeyboardEvent;
  5910. constructor(type: number, event: KeyboardEvent);
  5911. }
  5912. /**
  5913. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  5914. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  5915. */
  5916. class KeyboardInfoPre extends KeyboardInfo {
  5917. constructor(type: number, event: KeyboardEvent);
  5918. skipOnPointerObservable: boolean;
  5919. }
  5920. }
  5921. declare module BABYLON {
  5922. class PointerEventTypes {
  5923. static _POINTERDOWN: number;
  5924. static _POINTERUP: number;
  5925. static _POINTERMOVE: number;
  5926. static _POINTERWHEEL: number;
  5927. static _POINTERPICK: number;
  5928. static _POINTERTAP: number;
  5929. static _POINTERDOUBLETAP: number;
  5930. static readonly POINTERDOWN: number;
  5931. static readonly POINTERUP: number;
  5932. static readonly POINTERMOVE: number;
  5933. static readonly POINTERWHEEL: number;
  5934. static readonly POINTERPICK: number;
  5935. static readonly POINTERTAP: number;
  5936. static readonly POINTERDOUBLETAP: number;
  5937. }
  5938. class PointerInfoBase {
  5939. type: number;
  5940. event: PointerEvent | MouseWheelEvent;
  5941. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  5942. }
  5943. /**
  5944. * This class is used to store pointer related info for the onPrePointerObservable event.
  5945. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  5946. */
  5947. class PointerInfoPre extends PointerInfoBase {
  5948. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  5949. localPosition: Vector2;
  5950. skipOnPointerObservable: boolean;
  5951. }
  5952. /**
  5953. * This type contains all the data related to a pointer event in Babylon.js.
  5954. * 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.
  5955. */
  5956. class PointerInfo extends PointerInfoBase {
  5957. pickInfo: Nullable<PickingInfo>;
  5958. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  5959. }
  5960. }
  5961. declare module BABYLON {
  5962. /**
  5963. * Interface for attribute information associated with buffer instanciation
  5964. */
  5965. class InstancingAttributeInfo {
  5966. /**
  5967. * Index/offset of the attribute in the vertex shader
  5968. */
  5969. index: number;
  5970. /**
  5971. * size of the attribute, 1, 2, 3 or 4
  5972. */
  5973. attributeSize: number;
  5974. /**
  5975. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  5976. * default is FLOAT
  5977. */
  5978. attribyteType: number;
  5979. /**
  5980. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  5981. */
  5982. normalized: boolean;
  5983. /**
  5984. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  5985. */
  5986. offset: number;
  5987. /**
  5988. * Name of the GLSL attribute, for debugging purpose only
  5989. */
  5990. attributeName: string;
  5991. }
  5992. /**
  5993. * Define options used to create a render target texture
  5994. */
  5995. class RenderTargetCreationOptions {
  5996. /**
  5997. * Specifies is mipmaps must be generated
  5998. */
  5999. generateMipMaps?: boolean;
  6000. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6001. generateDepthBuffer?: boolean;
  6002. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6003. generateStencilBuffer?: boolean;
  6004. /** Defines texture type (int by default) */
  6005. type?: number;
  6006. /** Defines sampling mode (trilinear by default) */
  6007. samplingMode?: number;
  6008. /** Defines format (RGBA by default) */
  6009. format?: number;
  6010. }
  6011. /**
  6012. * Define options used to create a depth texture
  6013. */
  6014. class DepthTextureCreationOptions {
  6015. /** Specifies whether or not a stencil should be allocated in the texture */
  6016. generateStencil?: boolean;
  6017. /** Specifies whether or not bilinear filtering is enable on the texture */
  6018. bilinearFiltering?: boolean;
  6019. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  6020. comparisonFunction?: number;
  6021. /** Specifies if the created texture is a cube texture */
  6022. isCube?: boolean;
  6023. }
  6024. /**
  6025. * Class used to describe the capabilities of the engine relatively to the current browser
  6026. */
  6027. class EngineCapabilities {
  6028. /** Maximum textures units per fragment shader */
  6029. maxTexturesImageUnits: number;
  6030. /** Maximum texture units per vertex shader */
  6031. maxVertexTextureImageUnits: number;
  6032. /** Maximum textures units in the entire pipeline */
  6033. maxCombinedTexturesImageUnits: number;
  6034. /** Maximum texture size */
  6035. maxTextureSize: number;
  6036. /** Maximum cube texture size */
  6037. maxCubemapTextureSize: number;
  6038. /** Maximum render texture size */
  6039. maxRenderTextureSize: number;
  6040. /** Maximum number of vertex attributes */
  6041. maxVertexAttribs: number;
  6042. /** Maximum number of varyings */
  6043. maxVaryingVectors: number;
  6044. /** Maximum number of uniforms per vertex shader */
  6045. maxVertexUniformVectors: number;
  6046. /** Maximum number of uniforms per fragment shader */
  6047. maxFragmentUniformVectors: number;
  6048. /** Defines if standard derivates (dx/dy) are supported */
  6049. standardDerivatives: boolean;
  6050. /** Defines if s3tc texture compression is supported */
  6051. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  6052. /** Defines if pvrtc texture compression is supported */
  6053. pvrtc: any;
  6054. /** Defines if etc1 texture compression is supported */
  6055. etc1: any;
  6056. /** Defines if etc2 texture compression is supported */
  6057. etc2: any;
  6058. /** Defines if astc texture compression is supported */
  6059. astc: any;
  6060. /** Defines if float textures are supported */
  6061. textureFloat: boolean;
  6062. /** Defines if vertex array objects are supported */
  6063. vertexArrayObject: boolean;
  6064. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  6065. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  6066. /** Gets the maximum level of anisotropy supported */
  6067. maxAnisotropy: number;
  6068. /** Defines if instancing is supported */
  6069. instancedArrays: boolean;
  6070. /** Defines if 32 bits indices are supported */
  6071. uintIndices: boolean;
  6072. /** Defines if high precision shaders are supported */
  6073. highPrecisionShaderSupported: boolean;
  6074. /** Defines if depth reading in the fragment shader is supported */
  6075. fragmentDepthSupported: boolean;
  6076. /** Defines if float texture linear filtering is supported*/
  6077. textureFloatLinearFiltering: boolean;
  6078. /** Defines if rendering to float textures is supported */
  6079. textureFloatRender: boolean;
  6080. /** Defines if half float textures are supported*/
  6081. textureHalfFloat: boolean;
  6082. /** Defines if half float texture linear filtering is supported*/
  6083. textureHalfFloatLinearFiltering: boolean;
  6084. /** Defines if rendering to half float textures is supported */
  6085. textureHalfFloatRender: boolean;
  6086. /** Defines if textureLOD shader command is supported */
  6087. textureLOD: boolean;
  6088. /** Defines if draw buffers extension is supported */
  6089. drawBuffersExtension: boolean;
  6090. /** Defines if depth textures are supported */
  6091. depthTextureExtension: boolean;
  6092. /** Defines if float color buffer are supported */
  6093. colorBufferFloat: boolean;
  6094. /** Gets disjoint timer query extension (null if not supported) */
  6095. timerQuery: EXT_disjoint_timer_query;
  6096. /** Defines if timestamp can be used with timer query */
  6097. canUseTimestampForTimerQuery: boolean;
  6098. }
  6099. /** Interface defining initialization parameters for Engine class */
  6100. interface EngineOptions extends WebGLContextAttributes {
  6101. /**
  6102. * Defines if the engine should no exceed a specified device ratio
  6103. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  6104. */
  6105. limitDeviceRatio?: number;
  6106. /**
  6107. * Defines if webvr should be enabled automatically
  6108. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6109. */
  6110. autoEnableWebVR?: boolean;
  6111. /**
  6112. * Defines if webgl2 should be turned off even if supported
  6113. * @see http://doc.babylonjs.com/features/webgl2
  6114. */
  6115. disableWebGL2Support?: boolean;
  6116. /**
  6117. * Defines if webaudio should be initialized as well
  6118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6119. */
  6120. audioEngine?: boolean;
  6121. /**
  6122. * Defines if animations should run using a deterministic lock step
  6123. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6124. */
  6125. deterministicLockstep?: boolean;
  6126. /** Defines the maximum steps to use with deterministic lock step mode */
  6127. lockstepMaxSteps?: number;
  6128. /**
  6129. * Defines that engine should ignore context lost events
  6130. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  6131. */
  6132. doNotHandleContextLost?: boolean;
  6133. }
  6134. /**
  6135. * Defines the interface used by display changed events
  6136. */
  6137. interface IDisplayChangedEventArgs {
  6138. /** Gets the vrDisplay object (if any) */
  6139. vrDisplay: Nullable<any>;
  6140. /** Gets a boolean indicating if webVR is supported */
  6141. vrSupported: boolean;
  6142. }
  6143. /**
  6144. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  6145. */
  6146. class Engine {
  6147. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  6148. static ExceptionList: ({
  6149. key: string;
  6150. capture: string;
  6151. captureConstraint: number;
  6152. targets: string[];
  6153. } | {
  6154. key: string;
  6155. capture: null;
  6156. captureConstraint: null;
  6157. targets: string[];
  6158. })[];
  6159. /** Gets the list of created engines */
  6160. static Instances: Engine[];
  6161. /**
  6162. * Gets the latest created engine
  6163. */
  6164. static readonly LastCreatedEngine: Nullable<Engine>;
  6165. /**
  6166. * Gets the latest created scene
  6167. */
  6168. static readonly LastCreatedScene: Nullable<Scene>;
  6169. /**
  6170. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  6171. * @param flag defines which part of the materials must be marked as dirty
  6172. * @param predicate defines a predicate used to filter which materials should be affected
  6173. */
  6174. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  6175. private static _ALPHA_DISABLE;
  6176. private static _ALPHA_ADD;
  6177. private static _ALPHA_COMBINE;
  6178. private static _ALPHA_SUBTRACT;
  6179. private static _ALPHA_MULTIPLY;
  6180. private static _ALPHA_MAXIMIZED;
  6181. private static _ALPHA_ONEONE;
  6182. private static _ALPHA_PREMULTIPLIED;
  6183. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  6184. private static _ALPHA_INTERPOLATE;
  6185. private static _ALPHA_SCREENMODE;
  6186. private static _DELAYLOADSTATE_NONE;
  6187. private static _DELAYLOADSTATE_LOADED;
  6188. private static _DELAYLOADSTATE_LOADING;
  6189. private static _DELAYLOADSTATE_NOTLOADED;
  6190. private static _TEXTUREFORMAT_ALPHA;
  6191. private static _TEXTUREFORMAT_LUMINANCE;
  6192. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  6193. private static _TEXTUREFORMAT_RGB;
  6194. private static _TEXTUREFORMAT_RGBA;
  6195. private static _TEXTUREFORMAT_R32F;
  6196. private static _TEXTUREFORMAT_RG32F;
  6197. private static _TEXTUREFORMAT_RGB32F;
  6198. private static _TEXTUREFORMAT_RGBA32F;
  6199. private static _TEXTURETYPE_UNSIGNED_INT;
  6200. private static _TEXTURETYPE_FLOAT;
  6201. private static _TEXTURETYPE_HALF_FLOAT;
  6202. private static _NEVER;
  6203. private static _ALWAYS;
  6204. private static _LESS;
  6205. private static _EQUAL;
  6206. private static _LEQUAL;
  6207. private static _GREATER;
  6208. private static _GEQUAL;
  6209. private static _NOTEQUAL;
  6210. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  6211. static readonly NEVER: number;
  6212. /** 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 */
  6213. static readonly ALWAYS: number;
  6214. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  6215. static readonly LESS: number;
  6216. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  6217. static readonly EQUAL: number;
  6218. /** 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 */
  6219. static readonly LEQUAL: number;
  6220. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  6221. static readonly GREATER: number;
  6222. /** 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 */
  6223. static readonly GEQUAL: number;
  6224. /** 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 */
  6225. static readonly NOTEQUAL: number;
  6226. private static _KEEP;
  6227. private static _REPLACE;
  6228. private static _INCR;
  6229. private static _DECR;
  6230. private static _INVERT;
  6231. private static _INCR_WRAP;
  6232. private static _DECR_WRAP;
  6233. /** Passed to stencilOperation to specify that stencil value must be kept */
  6234. static readonly KEEP: number;
  6235. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6236. static readonly REPLACE: number;
  6237. /** Passed to stencilOperation to specify that stencil value must be incremented */
  6238. static readonly INCR: number;
  6239. /** Passed to stencilOperation to specify that stencil value must be decremented */
  6240. static readonly DECR: number;
  6241. /** Passed to stencilOperation to specify that stencil value must be inverted */
  6242. static readonly INVERT: number;
  6243. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  6244. static readonly INCR_WRAP: number;
  6245. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  6246. static readonly DECR_WRAP: number;
  6247. /** Defines that alpha blending is disabled */
  6248. static readonly ALPHA_DISABLE: number;
  6249. /** Defines that alpha blending to SRC + DEST */
  6250. static readonly ALPHA_ONEONE: number;
  6251. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  6252. static readonly ALPHA_ADD: number;
  6253. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  6254. static readonly ALPHA_COMBINE: number;
  6255. /** Defines that alpha blending to DEST - SRC * DEST */
  6256. static readonly ALPHA_SUBTRACT: number;
  6257. /** Defines that alpha blending to SRC * DEST */
  6258. static readonly ALPHA_MULTIPLY: number;
  6259. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  6260. static readonly ALPHA_MAXIMIZED: number;
  6261. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  6262. static readonly ALPHA_PREMULTIPLIED: number;
  6263. /**
  6264. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  6265. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  6266. */
  6267. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  6268. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  6269. static readonly ALPHA_INTERPOLATE: number;
  6270. /**
  6271. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  6272. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  6273. */
  6274. static readonly ALPHA_SCREENMODE: number;
  6275. /** Defines that the ressource is not delayed*/
  6276. static readonly DELAYLOADSTATE_NONE: number;
  6277. /** Defines that the ressource was successfully delay loaded */
  6278. static readonly DELAYLOADSTATE_LOADED: number;
  6279. /** Defines that the ressource is currently delay loading */
  6280. static readonly DELAYLOADSTATE_LOADING: number;
  6281. /** Defines that the ressource is delayed and has not started loading */
  6282. static readonly DELAYLOADSTATE_NOTLOADED: number;
  6283. /** ALPHA */
  6284. static readonly TEXTUREFORMAT_ALPHA: number;
  6285. /** LUMINANCE */
  6286. static readonly TEXTUREFORMAT_LUMINANCE: number;
  6287. /**
  6288. * R32F
  6289. */
  6290. static readonly TEXTUREFORMAT_R32F: number;
  6291. /**
  6292. * RG32F
  6293. */
  6294. static readonly TEXTUREFORMAT_RG32F: number;
  6295. /**
  6296. * RGB32F
  6297. */
  6298. static readonly TEXTUREFORMAT_RGB32F: number;
  6299. /**
  6300. * RGBA32F
  6301. */
  6302. static readonly TEXTUREFORMAT_RGBA32F: number;
  6303. /** LUMINANCE_ALPHA */
  6304. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  6305. /** RGB */
  6306. static readonly TEXTUREFORMAT_RGB: number;
  6307. /** RGBA */
  6308. static readonly TEXTUREFORMAT_RGBA: number;
  6309. /** UNSIGNED_INT */
  6310. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  6311. /** FLOAT */
  6312. static readonly TEXTURETYPE_FLOAT: number;
  6313. /** HALF_FLOAT */
  6314. static readonly TEXTURETYPE_HALF_FLOAT: number;
  6315. private static _SCALEMODE_FLOOR;
  6316. private static _SCALEMODE_NEAREST;
  6317. private static _SCALEMODE_CEILING;
  6318. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  6319. static readonly SCALEMODE_FLOOR: number;
  6320. /** Defines that texture rescaling will look for the nearest power of 2 size */
  6321. static readonly SCALEMODE_NEAREST: number;
  6322. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  6323. static readonly SCALEMODE_CEILING: number;
  6324. /**
  6325. * Returns the current version of the framework
  6326. */
  6327. static readonly Version: string;
  6328. /**
  6329. * Gets or sets the epsilon value used by collision engine
  6330. */
  6331. static CollisionsEpsilon: number;
  6332. /**
  6333. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  6334. */
  6335. static CodeRepository: string;
  6336. /**
  6337. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  6338. */
  6339. static ShadersRepository: string;
  6340. /**
  6341. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  6342. */
  6343. forcePOTTextures: boolean;
  6344. /**
  6345. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  6346. */
  6347. isFullscreen: boolean;
  6348. /**
  6349. * Gets a boolean indicating if the pointer is currently locked
  6350. */
  6351. isPointerLock: boolean;
  6352. /**
  6353. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  6354. */
  6355. cullBackFaces: boolean;
  6356. /**
  6357. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  6358. */
  6359. renderEvenInBackground: boolean;
  6360. /**
  6361. * Gets or sets a boolean indicating that cache can be kept between frames
  6362. */
  6363. preventCacheWipeBetweenFrames: boolean;
  6364. /**
  6365. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  6366. **/
  6367. enableOfflineSupport: boolean;
  6368. /**
  6369. * 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)
  6370. **/
  6371. disableManifestCheck: boolean;
  6372. /**
  6373. * Gets the list of created scenes
  6374. */
  6375. scenes: Scene[];
  6376. /**
  6377. * Gets the list of created postprocesses
  6378. */
  6379. postProcesses: PostProcess[];
  6380. /**
  6381. * Observable event triggered each time the rendering canvas is resized
  6382. */
  6383. onResizeObservable: Observable<Engine>;
  6384. /**
  6385. * Observable event triggered each time the canvas loses focus
  6386. */
  6387. onCanvasBlurObservable: Observable<Engine>;
  6388. /**
  6389. * Observable event triggered each time the canvas gains focus
  6390. */
  6391. onCanvasFocusObservable: Observable<Engine>;
  6392. /**
  6393. * Observable event triggered each time the canvas receives pointerout event
  6394. */
  6395. onCanvasPointerOutObservable: Observable<PointerEvent>;
  6396. /**
  6397. * Observable event triggered before each texture is initialized
  6398. */
  6399. onBeforeTextureInitObservable: Observable<Texture>;
  6400. private _vrDisplay;
  6401. private _vrSupported;
  6402. private _oldSize;
  6403. private _oldHardwareScaleFactor;
  6404. private _vrExclusivePointerMode;
  6405. private _webVRInitPromise;
  6406. /**
  6407. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  6408. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  6409. */
  6410. readonly isInVRExclusivePointerMode: boolean;
  6411. /**
  6412. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  6413. */
  6414. disableUniformBuffers: boolean;
  6415. /** @hidden */
  6416. _uniformBuffers: UniformBuffer[];
  6417. /**
  6418. * Gets a boolean indicating that the engine supports uniform buffers
  6419. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6420. */
  6421. readonly supportsUniformBuffers: boolean;
  6422. /**
  6423. * Observable raised when the engine begins a new frame
  6424. */
  6425. onBeginFrameObservable: Observable<Engine>;
  6426. /**
  6427. * Observable raised when the engine ends the current frame
  6428. */
  6429. onEndFrameObservable: Observable<Engine>;
  6430. /**
  6431. * Observable raised when the engine is about to compile a shader
  6432. */
  6433. onBeforeShaderCompilationObservable: Observable<Engine>;
  6434. /**
  6435. * Observable raised when the engine has jsut compiled a shader
  6436. */
  6437. onAfterShaderCompilationObservable: Observable<Engine>;
  6438. private _gl;
  6439. private _renderingCanvas;
  6440. private _windowIsBackground;
  6441. private _webGLVersion;
  6442. /**
  6443. * Gets a boolean indicating that only power of 2 textures are supported
  6444. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  6445. */
  6446. readonly needPOTTextures: boolean;
  6447. /** @hidden */
  6448. _badOS: boolean;
  6449. /** @hidden */
  6450. _badDesktopOS: boolean;
  6451. /**
  6452. * Gets or sets a value indicating if we want to disable texture binding optmization.
  6453. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  6454. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  6455. */
  6456. disableTextureBindingOptimization: boolean;
  6457. /**
  6458. * Gets the audio engine
  6459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6460. * @ignorenaming
  6461. */
  6462. static audioEngine: AudioEngine;
  6463. private _onFocus;
  6464. private _onBlur;
  6465. private _onCanvasPointerOut;
  6466. private _onCanvasBlur;
  6467. private _onCanvasFocus;
  6468. private _onFullscreenChange;
  6469. private _onPointerLockChange;
  6470. private _onVRDisplayPointerRestricted;
  6471. private _onVRDisplayPointerUnrestricted;
  6472. private _onVrDisplayConnect;
  6473. private _onVrDisplayDisconnect;
  6474. private _onVrDisplayPresentChange;
  6475. /**
  6476. * Observable signaled when VR display mode changes
  6477. */
  6478. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  6479. /**
  6480. * Observable signaled when VR request present is complete
  6481. */
  6482. onVRRequestPresentComplete: Observable<boolean>;
  6483. /**
  6484. * Observable signaled when VR request present starts
  6485. */
  6486. onVRRequestPresentStart: Observable<Engine>;
  6487. private _hardwareScalingLevel;
  6488. /** @hidden */
  6489. protected _caps: EngineCapabilities;
  6490. private _pointerLockRequested;
  6491. private _isStencilEnable;
  6492. private _colorWrite;
  6493. private _loadingScreen;
  6494. /** @hidden */
  6495. _drawCalls: PerfCounter;
  6496. /** @hidden */
  6497. _textureCollisions: PerfCounter;
  6498. private _glVersion;
  6499. private _glRenderer;
  6500. private _glVendor;
  6501. private _videoTextureSupported;
  6502. private _renderingQueueLaunched;
  6503. private _activeRenderLoops;
  6504. private _deterministicLockstep;
  6505. private _lockstepMaxSteps;
  6506. /**
  6507. * Observable signaled when a context lost event is raised
  6508. */
  6509. onContextLostObservable: Observable<Engine>;
  6510. /**
  6511. * Observable signaled when a context restored event is raised
  6512. */
  6513. onContextRestoredObservable: Observable<Engine>;
  6514. private _onContextLost;
  6515. private _onContextRestored;
  6516. private _contextWasLost;
  6517. private _doNotHandleContextLost;
  6518. private _performanceMonitor;
  6519. private _fps;
  6520. private _deltaTime;
  6521. /**
  6522. * Turn this value on if you want to pause FPS computation when in background
  6523. */
  6524. disablePerformanceMonitorInBackground: boolean;
  6525. /**
  6526. * Gets the performance monitor attached to this engine
  6527. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  6528. */
  6529. readonly performanceMonitor: PerformanceMonitor;
  6530. /** @hidden */
  6531. protected _depthCullingState: _DepthCullingState;
  6532. /** @hidden */
  6533. protected _stencilState: _StencilState;
  6534. /** @hidden */
  6535. protected _alphaState: _AlphaState;
  6536. /** @hidden */
  6537. protected _alphaMode: number;
  6538. protected _internalTexturesCache: InternalTexture[];
  6539. /** @hidden */
  6540. protected _activeChannel: number;
  6541. private _currentTextureChannel;
  6542. /** @hidden */
  6543. protected _boundTexturesCache: {
  6544. [key: string]: Nullable<InternalTexture>;
  6545. };
  6546. /** @hidden */
  6547. protected _currentEffect: Nullable<Effect>;
  6548. /** @hidden */
  6549. protected _currentProgram: Nullable<WebGLProgram>;
  6550. private _compiledEffects;
  6551. private _vertexAttribArraysEnabled;
  6552. /** @hidden */
  6553. protected _cachedViewport: Nullable<Viewport>;
  6554. private _cachedVertexArrayObject;
  6555. /** @hidden */
  6556. protected _cachedVertexBuffers: any;
  6557. /** @hidden */
  6558. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  6559. /** @hidden */
  6560. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  6561. /** @hidden */
  6562. protected _currentRenderTarget: Nullable<InternalTexture>;
  6563. private _uintIndicesCurrentlySet;
  6564. private _currentBoundBuffer;
  6565. /** @hidden */
  6566. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  6567. private _currentBufferPointers;
  6568. private _currentInstanceLocations;
  6569. private _currentInstanceBuffers;
  6570. private _textureUnits;
  6571. private _firstBoundInternalTextureTracker;
  6572. private _lastBoundInternalTextureTracker;
  6573. private _workingCanvas;
  6574. private _workingContext;
  6575. private _rescalePostProcess;
  6576. private _dummyFramebuffer;
  6577. private _externalData;
  6578. private _bindedRenderFunction;
  6579. private _vaoRecordInProgress;
  6580. private _mustWipeVertexAttributes;
  6581. private _emptyTexture;
  6582. private _emptyCubeTexture;
  6583. private _emptyTexture3D;
  6584. private _frameHandler;
  6585. private _nextFreeTextureSlots;
  6586. private _maxSimultaneousTextures;
  6587. private _activeRequests;
  6588. private _texturesSupported;
  6589. private _textureFormatInUse;
  6590. /**
  6591. * Gets the list of texture formats supported
  6592. */
  6593. readonly texturesSupported: Array<string>;
  6594. /**
  6595. * Gets the list of texture formats in use
  6596. */
  6597. readonly textureFormatInUse: Nullable<string>;
  6598. /**
  6599. * Gets the current viewport
  6600. */
  6601. readonly currentViewport: Nullable<Viewport>;
  6602. /**
  6603. * Gets the default empty texture
  6604. */
  6605. readonly emptyTexture: InternalTexture;
  6606. /**
  6607. * Gets the default empty 3D texture
  6608. */
  6609. readonly emptyTexture3D: InternalTexture;
  6610. /**
  6611. * Gets the default empty cube texture
  6612. */
  6613. readonly emptyCubeTexture: InternalTexture;
  6614. /**
  6615. * Creates a new engine
  6616. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  6617. * @param antialias defines enable antialiasing (default: false)
  6618. * @param options defines further options to be sent to the getContext() function
  6619. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  6620. */
  6621. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  6622. private _rebuildInternalTextures();
  6623. private _rebuildEffects();
  6624. private _rebuildBuffers();
  6625. private _initGLContext();
  6626. /**
  6627. * Gets version of the current webGL context
  6628. */
  6629. readonly webGLVersion: number;
  6630. /**
  6631. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  6632. */
  6633. readonly isStencilEnable: boolean;
  6634. private _prepareWorkingCanvas();
  6635. /**
  6636. * Reset the texture cache to empty state
  6637. */
  6638. resetTextureCache(): void;
  6639. /**
  6640. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  6641. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6642. * @returns true if engine is in deterministic lock step mode
  6643. */
  6644. isDeterministicLockStep(): boolean;
  6645. /**
  6646. * Gets the max steps when engine is running in deterministic lock step
  6647. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6648. * @returns the max steps
  6649. */
  6650. getLockstepMaxSteps(): number;
  6651. /**
  6652. * Gets an object containing information about the current webGL context
  6653. * @returns an object containing the vender, the renderer and the version of the current webGL context
  6654. */
  6655. getGlInfo(): {
  6656. vendor: string;
  6657. renderer: string;
  6658. version: string;
  6659. };
  6660. /**
  6661. * Gets current aspect ratio
  6662. * @param camera defines the camera to use to get the aspect ratio
  6663. * @param useScreen defines if screen size must be used (or the current render target if any)
  6664. * @returns a number defining the aspect ratio
  6665. */
  6666. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  6667. /**
  6668. * Gets current screen aspect ratio
  6669. * @returns a number defining the aspect ratio
  6670. */
  6671. getScreenAspectRatio(): number;
  6672. /**
  6673. * Gets the current render width
  6674. * @param useScreen defines if screen size must be used (or the current render target if any)
  6675. * @returns a number defining the current render width
  6676. */
  6677. getRenderWidth(useScreen?: boolean): number;
  6678. /**
  6679. * Gets the current render height
  6680. * @param useScreen defines if screen size must be used (or the current render target if any)
  6681. * @returns a number defining the current render height
  6682. */
  6683. getRenderHeight(useScreen?: boolean): number;
  6684. /**
  6685. * Gets the HTML canvas attached with the current webGL context
  6686. * @returns a HTML canvas
  6687. */
  6688. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  6689. /**
  6690. * Gets the client rect of the HTML canvas attached with the current webGL context
  6691. * @returns a client rectanglee
  6692. */
  6693. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  6694. /**
  6695. * Defines the hardware scaling level.
  6696. * By default the hardware scaling level is computed from the window device ratio.
  6697. * 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.
  6698. * @param level defines the level to use
  6699. */
  6700. setHardwareScalingLevel(level: number): void;
  6701. /**
  6702. * Gets the current hardware scaling level.
  6703. * By default the hardware scaling level is computed from the window device ratio.
  6704. * 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.
  6705. * @returns a number indicating the current hardware scaling level
  6706. */
  6707. getHardwareScalingLevel(): number;
  6708. /**
  6709. * Gets the list of loaded textures
  6710. * @returns an array containing all loaded textures
  6711. */
  6712. getLoadedTexturesCache(): InternalTexture[];
  6713. /**
  6714. * Gets the object containing all engine capabilities
  6715. * @returns the EngineCapabilities object
  6716. */
  6717. getCaps(): EngineCapabilities;
  6718. /** @hidden */
  6719. readonly drawCalls: number;
  6720. /** @hidden */
  6721. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  6722. /**
  6723. * Gets the current depth function
  6724. * @returns a number defining the depth function
  6725. */
  6726. getDepthFunction(): Nullable<number>;
  6727. /**
  6728. * Sets the current depth function
  6729. * @param depthFunc defines the function to use
  6730. */
  6731. setDepthFunction(depthFunc: number): void;
  6732. /**
  6733. * Sets the current depth function to GREATER
  6734. */
  6735. setDepthFunctionToGreater(): void;
  6736. /**
  6737. * Sets the current depth function to GEQUAL
  6738. */
  6739. setDepthFunctionToGreaterOrEqual(): void;
  6740. /**
  6741. * Sets the current depth function to LESS
  6742. */
  6743. setDepthFunctionToLess(): void;
  6744. /**
  6745. * Sets the current depth function to LEQUAL
  6746. */
  6747. setDepthFunctionToLessOrEqual(): void;
  6748. /**
  6749. * Gets a boolean indicating if stencil buffer is enabled
  6750. * @returns the current stencil buffer state
  6751. */
  6752. getStencilBuffer(): boolean;
  6753. /**
  6754. * Enable or disable the stencil buffer
  6755. * @param enable defines if the stencil buffer must be enabled or disabled
  6756. */
  6757. setStencilBuffer(enable: boolean): void;
  6758. /**
  6759. * Gets the current stencil mask
  6760. * @returns a number defining the new stencil mask to use
  6761. */
  6762. getStencilMask(): number;
  6763. /**
  6764. * Sets the current stencil mask
  6765. * @param mask defines the new stencil mask to use
  6766. */
  6767. setStencilMask(mask: number): void;
  6768. /**
  6769. * Gets the current stencil function
  6770. * @returns a number defining the stencil function to use
  6771. */
  6772. getStencilFunction(): number;
  6773. /**
  6774. * Gets the current stencil reference value
  6775. * @returns a number defining the stencil reference value to use
  6776. */
  6777. getStencilFunctionReference(): number;
  6778. /**
  6779. * Gets the current stencil mask
  6780. * @returns a number defining the stencil mask to use
  6781. */
  6782. getStencilFunctionMask(): number;
  6783. /**
  6784. * Sets the current stencil function
  6785. * @param stencilFunc defines the new stencil function to use
  6786. */
  6787. setStencilFunction(stencilFunc: number): void;
  6788. /**
  6789. * Sets the current stencil reference
  6790. * @param reference defines the new stencil reference to use
  6791. */
  6792. setStencilFunctionReference(reference: number): void;
  6793. /**
  6794. * Sets the current stencil mask
  6795. * @param mask defines the new stencil mask to use
  6796. */
  6797. setStencilFunctionMask(mask: number): void;
  6798. /**
  6799. * Gets the current stencil operation when stencil fails
  6800. * @returns a number defining stencil operation to use when stencil fails
  6801. */
  6802. getStencilOperationFail(): number;
  6803. /**
  6804. * Gets the current stencil operation when depth fails
  6805. * @returns a number defining stencil operation to use when depth fails
  6806. */
  6807. getStencilOperationDepthFail(): number;
  6808. /**
  6809. * Gets the current stencil operation when stencil passes
  6810. * @returns a number defining stencil operation to use when stencil passes
  6811. */
  6812. getStencilOperationPass(): number;
  6813. /**
  6814. * Sets the stencil operation to use when stencil fails
  6815. * @param operation defines the stencil operation to use when stencil fails
  6816. */
  6817. setStencilOperationFail(operation: number): void;
  6818. /**
  6819. * Sets the stencil operation to use when depth fails
  6820. * @param operation defines the stencil operation to use when depth fails
  6821. */
  6822. setStencilOperationDepthFail(operation: number): void;
  6823. /**
  6824. * Sets the stencil operation to use when stencil passes
  6825. * @param operation defines the stencil operation to use when stencil passes
  6826. */
  6827. setStencilOperationPass(operation: number): void;
  6828. /**
  6829. * Sets a boolean indicating if the dithering state is enabled or disabled
  6830. * @param value defines the dithering state
  6831. */
  6832. setDitheringState(value: boolean): void;
  6833. /**
  6834. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  6835. * @param value defines the rasterizer state
  6836. */
  6837. setRasterizerState(value: boolean): void;
  6838. /**
  6839. * stop executing a render loop function and remove it from the execution array
  6840. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  6841. */
  6842. stopRenderLoop(renderFunction?: () => void): void;
  6843. /** @hidden */
  6844. _renderLoop(): void;
  6845. /**
  6846. * Register and execute a render loop. The engine can have more than one render function
  6847. * @param renderFunction defines the function to continuously execute
  6848. */
  6849. runRenderLoop(renderFunction: () => void): void;
  6850. /**
  6851. * Toggle full screen mode
  6852. * @param requestPointerLock defines if a pointer lock should be requested from the user
  6853. * @param options defines an option object to be sent to the requestFullscreen function
  6854. */
  6855. switchFullscreen(requestPointerLock: boolean): void;
  6856. /**
  6857. * Clear the current render buffer or the current render target (if any is set up)
  6858. * @param color defines the color to use
  6859. * @param backBuffer defines if the back buffer must be cleared
  6860. * @param depth defines if the depth buffer must be cleared
  6861. * @param stencil defines if the stencil buffer must be cleared
  6862. */
  6863. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  6864. /**
  6865. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  6866. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  6867. * @param y defines the y-coordinate of the corner of the clear rectangle
  6868. * @param width defines the width of the clear rectangle
  6869. * @param height defines the height of the clear rectangle
  6870. * @param clearColor defines the clear color
  6871. */
  6872. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  6873. /**
  6874. * Set the WebGL's viewport
  6875. * @param viewport defines the viewport element to be used
  6876. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  6877. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  6878. */
  6879. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  6880. /**
  6881. * Directly set the WebGL Viewport
  6882. * @param x defines the x coordinate of the viewport (in screen space)
  6883. * @param y defines the y coordinate of the viewport (in screen space)
  6884. * @param width defines the width of the viewport (in screen space)
  6885. * @param height defines the height of the viewport (in screen space)
  6886. * @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
  6887. */
  6888. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  6889. /**
  6890. * Begin a new frame
  6891. */
  6892. beginFrame(): void;
  6893. /**
  6894. * Enf the current frame
  6895. */
  6896. endFrame(): void;
  6897. /**
  6898. * Resize the view according to the canvas' size
  6899. */
  6900. resize(): void;
  6901. /**
  6902. * Force a specific size of the canvas
  6903. * @param width defines the new canvas' width
  6904. * @param height defines the new canvas' height
  6905. */
  6906. setSize(width: number, height: number): void;
  6907. /**
  6908. * Gets a boolean indicating if a webVR device was detected
  6909. * @returns true if a webVR device was detected
  6910. */
  6911. isVRDevicePresent(): boolean;
  6912. /**
  6913. * Gets the current webVR device
  6914. * @returns the current webVR device (or null)
  6915. */
  6916. getVRDevice(): any;
  6917. /**
  6918. * Initializes a webVR display and starts listening to display change events
  6919. * The onVRDisplayChangedObservable will be notified upon these changes
  6920. * @returns The onVRDisplayChangedObservable
  6921. */
  6922. initWebVR(): Observable<IDisplayChangedEventArgs>;
  6923. /**
  6924. * Initializes a webVR display and starts listening to display change events
  6925. * The onVRDisplayChangedObservable will be notified upon these changes
  6926. * @returns A promise containing a VRDisplay and if vr is supported
  6927. */
  6928. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  6929. /**
  6930. * Call this function to switch to webVR mode
  6931. * Will do nothing if webVR is not supported or if there is no webVR device
  6932. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6933. */
  6934. enableVR(): void;
  6935. /**
  6936. * Call this function to leave webVR mode
  6937. * Will do nothing if webVR is not supported or if there is no webVR device
  6938. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6939. */
  6940. disableVR(): void;
  6941. private _onVRFullScreenTriggered;
  6942. private _getVRDisplaysAsync();
  6943. /**
  6944. * Binds the frame buffer to the specified texture.
  6945. * @param texture The texture to render to or null for the default canvas
  6946. * @param faceIndex The face of the texture to render to in case of cube texture
  6947. * @param requiredWidth The width of the target to render to
  6948. * @param requiredHeight The height of the target to render to
  6949. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  6950. * @param depthStencilTexture The depth stencil texture to use to render
  6951. */
  6952. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture): void;
  6953. private bindUnboundFramebuffer(framebuffer);
  6954. /**
  6955. * Unbind the current render target texture from the webGL context
  6956. * @param texture defines the render target texture to unbind
  6957. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  6958. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  6959. */
  6960. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  6961. /**
  6962. * Unbind a list of render target textures from the webGL context
  6963. * This is used only when drawBuffer extension or webGL2 are active
  6964. * @param textures defines the render target textures to unbind
  6965. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  6966. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  6967. */
  6968. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  6969. /**
  6970. * Force the mipmap generation for the given render target texture
  6971. * @param texture defines the render target texture to use
  6972. */
  6973. generateMipMapsForCubemap(texture: InternalTexture): void;
  6974. /**
  6975. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  6976. */
  6977. flushFramebuffer(): void;
  6978. /**
  6979. * Unbind the current render target and bind the default framebuffer
  6980. */
  6981. restoreDefaultFramebuffer(): void;
  6982. /**
  6983. * Create an uniform buffer
  6984. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6985. * @param elements defines the content of the uniform buffer
  6986. * @returns the webGL uniform buffer
  6987. */
  6988. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  6989. /**
  6990. * Create a dynamic uniform buffer
  6991. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6992. * @param elements defines the content of the uniform buffer
  6993. * @returns the webGL uniform buffer
  6994. */
  6995. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  6996. /**
  6997. * Update an existing uniform buffer
  6998. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6999. * @param uniformBuffer defines the target uniform buffer
  7000. * @param elements defines the content to update
  7001. * @param offset defines the offset in the uniform buffer where update should start
  7002. * @param count defines the size of the data to update
  7003. */
  7004. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7005. private _resetVertexBufferBinding();
  7006. /**
  7007. * Creates a vertex buffer
  7008. * @param data the data for the vertex buffer
  7009. * @returns the new WebGL static buffer
  7010. */
  7011. createVertexBuffer(data: DataArray): WebGLBuffer;
  7012. /**
  7013. * Creates a dynamic vertex buffer
  7014. * @param data the data for the dynamic vertex buffer
  7015. * @returns the new WebGL dynamic buffer
  7016. */
  7017. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  7018. /**
  7019. * Update a dynamic index buffer
  7020. * @param indexBuffer defines the target index buffer
  7021. * @param indices defines the data to update
  7022. * @param offset defines the offset in the target index buffer where update should start
  7023. */
  7024. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  7025. /**
  7026. * Updates a dynamic vertex buffer.
  7027. * @param vertexBuffer the vertex buffer to update
  7028. * @param data the data used to update the vertex buffer
  7029. * @param byteOffset the byte offset of the data
  7030. * @param byteLength the byte length of the data
  7031. */
  7032. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  7033. private _resetIndexBufferBinding();
  7034. /**
  7035. * Creates a new index buffer
  7036. * @param indices defines the content of the index buffer
  7037. * @param updatable defines if the index buffer must be updatable
  7038. * @returns a new webGL buffer
  7039. */
  7040. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  7041. /**
  7042. * Bind a webGL buffer to the webGL context
  7043. * @param buffer defines the buffer to bind
  7044. */
  7045. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  7046. /**
  7047. * Bind an uniform buffer to the current webGL context
  7048. * @param buffer defines the buffer to bind
  7049. */
  7050. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  7051. /**
  7052. * Bind a buffer to the current webGL context at a given location
  7053. * @param buffer defines the buffer to bind
  7054. * @param location defines the index where to bind the buffer
  7055. */
  7056. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  7057. /**
  7058. * Bind a specific block at a given index in a specific shader program
  7059. * @param shaderProgram defines the shader program
  7060. * @param blockName defines the block name
  7061. * @param index defines the index where to bind the block
  7062. */
  7063. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  7064. private bindIndexBuffer(buffer);
  7065. private bindBuffer(buffer, target);
  7066. /**
  7067. * update the bound buffer with the given data
  7068. * @param data defines the data to update
  7069. */
  7070. updateArrayBuffer(data: Float32Array): void;
  7071. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  7072. private _bindIndexBufferWithCache(indexBuffer);
  7073. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  7074. /**
  7075. * Records a vertex array object
  7076. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7077. * @param vertexBuffers defines the list of vertex buffers to store
  7078. * @param indexBuffer defines the index buffer to store
  7079. * @param effect defines the effect to store
  7080. * @returns the new vertex array object
  7081. */
  7082. recordVertexArrayObject(vertexBuffers: {
  7083. [key: string]: VertexBuffer;
  7084. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  7085. /**
  7086. * Bind a specific vertex array object
  7087. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7088. * @param vertexArrayObject defines the vertex array object to bind
  7089. * @param indexBuffer defines the index buffer to bind
  7090. */
  7091. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  7092. /**
  7093. * Bind webGl buffers directly to the webGL context
  7094. * @param vertexBuffer defines the vertex buffer to bind
  7095. * @param indexBuffer defines the index buffer to bind
  7096. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  7097. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  7098. * @param effect defines the effect associated with the vertex buffer
  7099. */
  7100. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  7101. private _unbindVertexArrayObject();
  7102. /**
  7103. * Bind a list of vertex buffers to the webGL context
  7104. * @param vertexBuffers defines the list of vertex buffers to bind
  7105. * @param indexBuffer defines the index buffer to bind
  7106. * @param effect defines the effect associated with the vertex buffers
  7107. */
  7108. bindBuffers(vertexBuffers: {
  7109. [key: string]: Nullable<VertexBuffer>;
  7110. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  7111. /**
  7112. * Unbind all instance attributes
  7113. */
  7114. unbindInstanceAttributes(): void;
  7115. /**
  7116. * Release and free the memory of a vertex array object
  7117. * @param vao defines the vertex array object to delete
  7118. */
  7119. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  7120. /** @hidden */
  7121. _releaseBuffer(buffer: WebGLBuffer): boolean;
  7122. /**
  7123. * Creates a webGL buffer to use with instanciation
  7124. * @param capacity defines the size of the buffer
  7125. * @returns the webGL buffer
  7126. */
  7127. createInstancesBuffer(capacity: number): WebGLBuffer;
  7128. /**
  7129. * Delete a webGL buffer used with instanciation
  7130. * @param buffer defines the webGL buffer to delete
  7131. */
  7132. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  7133. /**
  7134. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  7135. * @param instancesBuffer defines the webGL buffer to update and bind
  7136. * @param data defines the data to store in the buffer
  7137. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  7138. */
  7139. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  7140. /**
  7141. * Apply all cached states (depth, culling, stencil and alpha)
  7142. */
  7143. applyStates(): void;
  7144. /**
  7145. * Send a draw order
  7146. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7147. * @param indexStart defines the starting index
  7148. * @param indexCount defines the number of index to draw
  7149. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7150. */
  7151. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  7152. /**
  7153. * Draw a list of points
  7154. * @param verticesStart defines the index of first vertex to draw
  7155. * @param verticesCount defines the count of vertices to draw
  7156. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7157. */
  7158. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7159. /**
  7160. * Draw a list of unindexed primitives
  7161. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7162. * @param verticesStart defines the index of first vertex to draw
  7163. * @param verticesCount defines the count of vertices to draw
  7164. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7165. */
  7166. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7167. /**
  7168. * Draw a list of indexed primitives
  7169. * @param fillMode defines the primitive to use
  7170. * @param indexStart defines the starting index
  7171. * @param indexCount defines the number of index to draw
  7172. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7173. */
  7174. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  7175. /**
  7176. * Draw a list of unindexed primitives
  7177. * @param fillMode defines the primitive to use
  7178. * @param verticesStart defines the index of first vertex to draw
  7179. * @param verticesCount defines the count of vertices to draw
  7180. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7181. */
  7182. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7183. private _drawMode(fillMode);
  7184. /** @hidden */
  7185. _releaseEffect(effect: Effect): void;
  7186. /** @hidden */
  7187. _deleteProgram(program: WebGLProgram): void;
  7188. /**
  7189. * Create a new effect (used to store vertex/fragment shaders)
  7190. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  7191. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  7192. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  7193. * @param samplers defines an array of string used to represent textures
  7194. * @param defines defines the string containing the defines to use to compile the shaders
  7195. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  7196. * @param onCompiled defines a function to call when the effect creation is successful
  7197. * @param onError defines a function to call when the effect creation has failed
  7198. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  7199. * @returns the new Effect
  7200. */
  7201. 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;
  7202. /**
  7203. * Create an effect to use with particle systems
  7204. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  7205. * @param uniformsNames defines a list of attribute names
  7206. * @param samplers defines an array of string used to represent textures
  7207. * @param defines defines the string containing the defines to use to compile the shaders
  7208. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  7209. * @param onCompiled defines a function to call when the effect creation is successful
  7210. * @param onError defines a function to call when the effect creation has failed
  7211. * @returns the new Effect
  7212. */
  7213. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  7214. /**
  7215. * Directly creates a webGL program
  7216. * @param vertexCode defines the vertex shader code to use
  7217. * @param fragmentCode defines the fragment shader code to use
  7218. * @param context defines the webGL context to use (if not set, the current one will be used)
  7219. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  7220. * @returns the new webGL program
  7221. */
  7222. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  7223. /**
  7224. * Creates a webGL program
  7225. * @param vertexCode defines the vertex shader code to use
  7226. * @param fragmentCode defines the fragment shader code to use
  7227. * @param defines defines the string containing the defines to use to compile the shaders
  7228. * @param context defines the webGL context to use (if not set, the current one will be used)
  7229. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  7230. * @returns the new webGL program
  7231. */
  7232. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  7233. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  7234. /**
  7235. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  7236. * @param shaderProgram defines the webGL program to use
  7237. * @param uniformsNames defines the list of uniform names
  7238. * @returns an array of webGL uniform locations
  7239. */
  7240. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  7241. /**
  7242. * Gets the lsit of active attributes for a given webGL program
  7243. * @param shaderProgram defines the webGL program to use
  7244. * @param attributesNames defines the list of attribute names to get
  7245. * @returns an array of indices indicating the offset of each attribute
  7246. */
  7247. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  7248. /**
  7249. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  7250. * @param effect defines the effect to activate
  7251. */
  7252. enableEffect(effect: Nullable<Effect>): void;
  7253. /**
  7254. * Set the value of an uniform to an array of int32
  7255. * @param uniform defines the webGL uniform location where to store the value
  7256. * @param array defines the array of int32 to store
  7257. */
  7258. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7259. /**
  7260. * Set the value of an uniform to an array of int32 (stored as vec2)
  7261. * @param uniform defines the webGL uniform location where to store the value
  7262. * @param array defines the array of int32 to store
  7263. */
  7264. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7265. /**
  7266. * Set the value of an uniform to an array of int32 (stored as vec3)
  7267. * @param uniform defines the webGL uniform location where to store the value
  7268. * @param array defines the array of int32 to store
  7269. */
  7270. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7271. /**
  7272. * Set the value of an uniform to an array of int32 (stored as vec4)
  7273. * @param uniform defines the webGL uniform location where to store the value
  7274. * @param array defines the array of int32 to store
  7275. */
  7276. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  7277. /**
  7278. * Set the value of an uniform to an array of float32
  7279. * @param uniform defines the webGL uniform location where to store the value
  7280. * @param array defines the array of float32 to store
  7281. */
  7282. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7283. /**
  7284. * Set the value of an uniform to an array of float32 (stored as vec2)
  7285. * @param uniform defines the webGL uniform location where to store the value
  7286. * @param array defines the array of float32 to store
  7287. */
  7288. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7289. /**
  7290. * Set the value of an uniform to an array of float32 (stored as vec3)
  7291. * @param uniform defines the webGL uniform location where to store the value
  7292. * @param array defines the array of float32 to store
  7293. */
  7294. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7295. /**
  7296. * Set the value of an uniform to an array of float32 (stored as vec4)
  7297. * @param uniform defines the webGL uniform location where to store the value
  7298. * @param array defines the array of float32 to store
  7299. */
  7300. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  7301. /**
  7302. * Set the value of an uniform to an array of number
  7303. * @param uniform defines the webGL uniform location where to store the value
  7304. * @param array defines the array of number to store
  7305. */
  7306. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7307. /**
  7308. * Set the value of an uniform to an array of number (stored as vec2)
  7309. * @param uniform defines the webGL uniform location where to store the value
  7310. * @param array defines the array of number to store
  7311. */
  7312. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7313. /**
  7314. * Set the value of an uniform to an array of number (stored as vec3)
  7315. * @param uniform defines the webGL uniform location where to store the value
  7316. * @param array defines the array of number to store
  7317. */
  7318. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7319. /**
  7320. * Set the value of an uniform to an array of number (stored as vec4)
  7321. * @param uniform defines the webGL uniform location where to store the value
  7322. * @param array defines the array of number to store
  7323. */
  7324. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  7325. /**
  7326. * Set the value of an uniform to an array of float32 (stored as matrices)
  7327. * @param uniform defines the webGL uniform location where to store the value
  7328. * @param matrices defines the array of float32 to store
  7329. */
  7330. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  7331. /**
  7332. * Set the value of an uniform to a matrix
  7333. * @param uniform defines the webGL uniform location where to store the value
  7334. * @param matrix defines the matrix to store
  7335. */
  7336. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  7337. /**
  7338. * Set the value of an uniform to a matrix (3x3)
  7339. * @param uniform defines the webGL uniform location where to store the value
  7340. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  7341. */
  7342. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  7343. /**
  7344. * Set the value of an uniform to a matrix (2x2)
  7345. * @param uniform defines the webGL uniform location where to store the value
  7346. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  7347. */
  7348. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  7349. /**
  7350. * Set the value of an uniform to a number (int)
  7351. * @param uniform defines the webGL uniform location where to store the value
  7352. * @param value defines the int number to store
  7353. */
  7354. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  7355. /**
  7356. * Set the value of an uniform to a number (float)
  7357. * @param uniform defines the webGL uniform location where to store the value
  7358. * @param value defines the float number to store
  7359. */
  7360. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  7361. /**
  7362. * Set the value of an uniform to a vec2
  7363. * @param uniform defines the webGL uniform location where to store the value
  7364. * @param x defines the 1st component of the value
  7365. * @param y defines the 2nd component of the value
  7366. */
  7367. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  7368. /**
  7369. * Set the value of an uniform to a vec3
  7370. * @param uniform defines the webGL uniform location where to store the value
  7371. * @param x defines the 1st component of the value
  7372. * @param y defines the 2nd component of the value
  7373. * @param z defines the 3rd component of the value
  7374. */
  7375. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  7376. /**
  7377. * Set the value of an uniform to a boolean
  7378. * @param uniform defines the webGL uniform location where to store the value
  7379. * @param bool defines the boolean to store
  7380. */
  7381. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  7382. /**
  7383. * Set the value of an uniform to a vec4
  7384. * @param uniform defines the webGL uniform location where to store the value
  7385. * @param x defines the 1st component of the value
  7386. * @param y defines the 2nd component of the value
  7387. * @param z defines the 3rd component of the value
  7388. * @param w defines the 4th component of the value
  7389. */
  7390. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  7391. /**
  7392. * Set the value of an uniform to a Color3
  7393. * @param uniform defines the webGL uniform location where to store the value
  7394. * @param color3 defines the color to store
  7395. */
  7396. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  7397. /**
  7398. * Set the value of an uniform to a Color3 and an alpha value
  7399. * @param uniform defines the webGL uniform location where to store the value
  7400. * @param color3 defines the color to store
  7401. * @param alpha defines the alpha component to store
  7402. */
  7403. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  7404. /**
  7405. * Sets a Color4 on a uniform variable
  7406. * @param uniform defines the uniform location
  7407. * @param color4 defines the value to be set
  7408. */
  7409. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  7410. /**
  7411. * Set various states to the webGL context
  7412. * @param culling defines backface culling state
  7413. * @param zOffset defines the value to apply to zOffset (0 by default)
  7414. * @param force defines if states must be applied even if cache is up to date
  7415. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  7416. */
  7417. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  7418. /**
  7419. * Set the z offset to apply to current rendering
  7420. * @param value defines the offset to apply
  7421. */
  7422. setZOffset(value: number): void;
  7423. /**
  7424. * Gets the current value of the zOffset
  7425. * @returns the current zOffset state
  7426. */
  7427. getZOffset(): number;
  7428. /**
  7429. * Enable or disable depth buffering
  7430. * @param enable defines the state to set
  7431. */
  7432. setDepthBuffer(enable: boolean): void;
  7433. /**
  7434. * Gets a boolean indicating if depth writing is enabled
  7435. * @returns the current depth writing state
  7436. */
  7437. getDepthWrite(): boolean;
  7438. /**
  7439. * Enable or disable depth writing
  7440. * @param enable defines the state to set
  7441. */
  7442. setDepthWrite(enable: boolean): void;
  7443. /**
  7444. * Enable or disable color writing
  7445. * @param enable defines the state to set
  7446. */
  7447. setColorWrite(enable: boolean): void;
  7448. /**
  7449. * Gets a boolean indicating if color writing is enabled
  7450. * @returns the current color writing state
  7451. */
  7452. getColorWrite(): boolean;
  7453. /**
  7454. * Sets alpha constants used by some alpha blending modes
  7455. * @param r defines the red component
  7456. * @param g defines the green component
  7457. * @param b defines the blue component
  7458. * @param a defines the alpha component
  7459. */
  7460. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  7461. /**
  7462. * Sets the current alpha mode
  7463. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  7464. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  7465. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  7466. */
  7467. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  7468. /**
  7469. * Gets the current alpha mode
  7470. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  7471. * @returns the current alpha mode
  7472. */
  7473. getAlphaMode(): number;
  7474. /**
  7475. * Force the entire cache to be cleared
  7476. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  7477. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  7478. */
  7479. wipeCaches(bruteForce?: boolean): void;
  7480. /**
  7481. * Set the compressed texture format to use, based on the formats you have, and the formats
  7482. * supported by the hardware / browser.
  7483. *
  7484. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  7485. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  7486. * to API arguments needed to compressed textures. This puts the burden on the container
  7487. * generator to house the arcane code for determining these for current & future formats.
  7488. *
  7489. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  7490. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  7491. *
  7492. * Note: The result of this call is not taken into account when a texture is base64.
  7493. *
  7494. * @param formatsAvailable defines the list of those format families you have created
  7495. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  7496. *
  7497. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  7498. * @returns The extension selected.
  7499. */
  7500. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  7501. /** @hidden */
  7502. _createTexture(): WebGLTexture;
  7503. /**
  7504. * Usually called from BABYLON.Texture.ts.
  7505. * Passed information to create a WebGLTexture
  7506. * @param urlArg defines a value which contains one of the following:
  7507. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  7508. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  7509. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  7510. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  7511. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  7512. * @param scene needed for loading to the correct scene
  7513. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  7514. * @param onLoad optional callback to be called upon successful completion
  7515. * @param onError optional callback to be called upon failure
  7516. * @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
  7517. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  7518. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  7519. * @returns a InternalTexture for assignment back into BABYLON.Texture
  7520. */
  7521. 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;
  7522. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  7523. /**
  7524. * Update a raw texture
  7525. * @param texture defines the texture to update
  7526. * @param data defines the data to store in the texture
  7527. * @param format defines the format of the data
  7528. * @param invertY defines if data must be stored with Y axis inverted
  7529. * @param compression defines the compression used (null by default)
  7530. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  7531. */
  7532. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  7533. /**
  7534. * Creates a raw texture
  7535. * @param data defines the data to store in the texture
  7536. * @param width defines the width of the texture
  7537. * @param height defines the height of the texture
  7538. * @param format defines the format of the data
  7539. * @param generateMipMaps defines if the engine should generate the mip levels
  7540. * @param invertY defines if data must be stored with Y axis inverted
  7541. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  7542. * @param compression defines the compression used (null by default)
  7543. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  7544. * @returns the raw texture inside an InternalTexture
  7545. */
  7546. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  7547. /**
  7548. * Creates a dynamic texture
  7549. * @param width defines the width of the texture
  7550. * @param height defines the height of the texture
  7551. * @param generateMipMaps defines if the engine should generate the mip levels
  7552. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  7553. * @returns the dynamic texture inside an InternalTexture
  7554. */
  7555. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  7556. /**
  7557. * Update the sampling mode of a given texture
  7558. * @param samplingMode defines the required sampling mode
  7559. * @param texture defines the texture to update
  7560. */
  7561. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  7562. /**
  7563. * Update the content of a dynamic texture
  7564. * @param texture defines the texture to update
  7565. * @param canvas defines the canvas containing the source
  7566. * @param invertY defines if data must be stored with Y axis inverted
  7567. * @param premulAlpha defines if alpha is stored as premultiplied
  7568. * @param format defines the format of the data
  7569. */
  7570. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  7571. /**
  7572. * Update a video texture
  7573. * @param texture defines the texture to update
  7574. * @param video defines the video element to use
  7575. * @param invertY defines if data must be stored with Y axis inverted
  7576. */
  7577. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  7578. /**
  7579. * Updates a depth texture Comparison Mode and Function.
  7580. * If the comparison Function is equal to 0, the mode will be set to none.
  7581. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  7582. * @param texture The texture to set the comparison function for
  7583. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  7584. */
  7585. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  7586. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  7587. /**
  7588. * Creates a depth stencil texture.
  7589. * This is only available in WebGL 2 or with the depth texture extension available.
  7590. * @param size The size of face edge in the texture.
  7591. * @param options The options defining the texture.
  7592. * @returns The texture
  7593. */
  7594. createDepthStencilTexture(size: number | {
  7595. width: number;
  7596. height: number;
  7597. }, options: DepthTextureCreationOptions): InternalTexture;
  7598. /**
  7599. * Creates a depth stencil texture.
  7600. * This is only available in WebGL 2 or with the depth texture extension available.
  7601. * @param size The size of face edge in the texture.
  7602. * @param options The options defining the texture.
  7603. * @returns The texture
  7604. */
  7605. private _createDepthStencilTexture(size, options);
  7606. /**
  7607. * Creates a depth stencil cube texture.
  7608. * This is only available in WebGL 2.
  7609. * @param size The size of face edge in the cube texture.
  7610. * @param options The options defining the cube texture.
  7611. * @returns The cube texture
  7612. */
  7613. private _createDepthStencilCubeTexture(size, options);
  7614. /**
  7615. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  7616. * @param renderTarget The render target to set the frame buffer for
  7617. */
  7618. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  7619. /**
  7620. * Creates a new render target texture
  7621. * @param size defines the size of the texture
  7622. * @param options defines the options used to create the texture
  7623. * @returns a new render target texture stored in an InternalTexture
  7624. */
  7625. createRenderTargetTexture(size: number | {
  7626. width: number;
  7627. height: number;
  7628. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  7629. /**
  7630. * Create a multi render target texture
  7631. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  7632. * @param size defines the size of the texture
  7633. * @param options defines the creation options
  7634. * @returns the cube texture as an InternalTexture
  7635. */
  7636. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  7637. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  7638. /**
  7639. * Updates the sample count of a render target texture
  7640. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  7641. * @param texture defines the texture to update
  7642. * @param samples defines the sample count to set
  7643. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  7644. */
  7645. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  7646. /**
  7647. * Update the sample count for a given multiple render target texture
  7648. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  7649. * @param textures defines the textures to update
  7650. * @param samples defines the sample count to set
  7651. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  7652. */
  7653. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  7654. /** @hidden */
  7655. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  7656. /** @hidden */
  7657. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  7658. /**
  7659. * Creates a new render target cube texture
  7660. * @param size defines the size of the texture
  7661. * @param options defines the options used to create the texture
  7662. * @returns a new render target cube texture stored in an InternalTexture
  7663. */
  7664. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  7665. /**
  7666. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  7667. * @param rootUrl defines the url where the file to load is located
  7668. * @param scene defines the current scene
  7669. * @param scale defines scale to apply to the mip map selection
  7670. * @param offset defines offset to apply to the mip map selection
  7671. * @param onLoad defines an optional callback raised when the texture is loaded
  7672. * @param onError defines an optional callback raised if there is an issue to load the texture
  7673. * @param format defines the format of the data
  7674. * @param forcedExtension defines the extension to use to pick the right loader
  7675. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  7676. * @returns the cube texture as an InternalTexture
  7677. */
  7678. 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, createPolynomials?: boolean): InternalTexture;
  7679. /**
  7680. * Creates a cube texture
  7681. * @param rootUrl defines the url where the files to load is located
  7682. * @param scene defines the current scene
  7683. * @param files defines the list of files to load (1 per face)
  7684. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7685. * @param onLoad defines an optional callback raised when the texture is loaded
  7686. * @param onError defines an optional callback raised if there is an issue to load the texture
  7687. * @param format defines the format of the data
  7688. * @param forcedExtension defines the extension to use to pick the right loader
  7689. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7690. * @returns the cube texture as an InternalTexture
  7691. */
  7692. 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;
  7693. private setCubeMapTextureParams(gl, loadMipmap);
  7694. /**
  7695. * Update a raw cube texture
  7696. * @param texture defines the texture to udpdate
  7697. * @param data defines the data to store
  7698. * @param format defines the data format
  7699. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  7700. * @param invertY defines if data must be stored with Y axis inverted
  7701. * @param compression defines the compression used (null by default)
  7702. * @param level defines which level of the texture to update
  7703. */
  7704. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  7705. /**
  7706. * Creates a new raw cube texture
  7707. * @param data defines the array of data to use to create each face
  7708. * @param size defines the size of the textures
  7709. * @param format defines the format of the data
  7710. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  7711. * @param generateMipMaps defines if the engine should generate the mip levels
  7712. * @param invertY defines if data must be stored with Y axis inverted
  7713. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  7714. * @param compression defines the compression used (null by default)
  7715. * @returns the cube texture as an InternalTexture
  7716. */
  7717. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  7718. /**
  7719. * Creates a new raw cube texture from a specified url
  7720. * @param url defines the url where the data is located
  7721. * @param scene defines the current scene
  7722. * @param size defines the size of the textures
  7723. * @param format defines the format of the data
  7724. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  7725. * @param noMipmap defines if the engine should avoid generating the mip levels
  7726. * @param callback defines a callback used to extract texture data from loaded data
  7727. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  7728. * @param onLoad defines a callback called when texture is loaded
  7729. * @param onError defines a callback called if there is an error
  7730. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  7731. * @param invertY defines if data must be stored with Y axis inverted
  7732. * @returns the cube texture as an InternalTexture
  7733. */
  7734. 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;
  7735. /**
  7736. * Update a raw 3D texture
  7737. * @param texture defines the texture to update
  7738. * @param data defines the data to store
  7739. * @param format defines the data format
  7740. * @param invertY defines if data must be stored with Y axis inverted
  7741. * @param compression defines the used compression (can be null)
  7742. */
  7743. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>): void;
  7744. /**
  7745. * Creates a new raw 3D texture
  7746. * @param data defines the data used to create the texture
  7747. * @param width defines the width of the texture
  7748. * @param height defines the height of the texture
  7749. * @param depth defines the depth of the texture
  7750. * @param format defines the format of the texture
  7751. * @param generateMipMaps defines if the engine must generate mip levels
  7752. * @param invertY defines if data must be stored with Y axis inverted
  7753. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  7754. * @param compression defines the compressed used (can be null)
  7755. * @returns a new raw 3D texture (stored in an InternalTexture)
  7756. */
  7757. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  7758. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  7759. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  7760. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  7761. /** @hidden */
  7762. _releaseFramebufferObjects(texture: InternalTexture): void;
  7763. /** @hidden */
  7764. _releaseTexture(texture: InternalTexture): void;
  7765. private setProgram(program);
  7766. private _boundUniforms;
  7767. /**
  7768. * Binds an effect to the webGL context
  7769. * @param effect defines the effect to bind
  7770. */
  7771. bindSamplers(effect: Effect): void;
  7772. private _moveBoundTextureOnTop(internalTexture);
  7773. private _getCorrectTextureChannel(channel, internalTexture);
  7774. private _linkTrackers(previous, next);
  7775. private _removeDesignatedSlot(internalTexture);
  7776. private _activateCurrentTexture();
  7777. /** @hidden */
  7778. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): void;
  7779. /** @hidden */
  7780. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  7781. /**
  7782. * Sets a texture to the webGL context from a postprocess
  7783. * @param channel defines the channel to use
  7784. * @param postProcess defines the source postprocess
  7785. */
  7786. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  7787. /**
  7788. * Binds the output of the passed in post process to the texture channel specified
  7789. * @param channel The channel the texture should be bound to
  7790. * @param postProcess The post process which's output should be bound
  7791. */
  7792. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  7793. /**
  7794. * Unbind all textures from the webGL context
  7795. */
  7796. unbindAllTextures(): void;
  7797. /**
  7798. * Sets a texture to the according uniform.
  7799. * @param channel The texture channel
  7800. * @param uniform The uniform to set
  7801. * @param texture The texture to apply
  7802. */
  7803. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  7804. /**
  7805. * Sets a depth stencil texture from a render target to the according uniform.
  7806. * @param channel The texture channel
  7807. * @param uniform The uniform to set
  7808. * @param texture The render target texture containing the depth stencil texture to apply
  7809. */
  7810. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  7811. private _bindSamplerUniformToChannel(sourceSlot, destination);
  7812. private _getTextureWrapMode(mode);
  7813. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  7814. /**
  7815. * Sets an array of texture to the webGL context
  7816. * @param channel defines the channel where the texture array must be set
  7817. * @param uniform defines the associated uniform location
  7818. * @param textures defines the array of textures to bind
  7819. */
  7820. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  7821. /** @hidden */
  7822. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  7823. private _setTextureParameterFloat(target, parameter, value, texture);
  7824. private _setTextureParameterInteger(target, parameter, value, texture?);
  7825. /**
  7826. * Reads pixels from the current frame buffer. Please note that this function can be slow
  7827. * @param x defines the x coordinate of the rectangle where pixels must be read
  7828. * @param y defines the y coordinate of the rectangle where pixels must be read
  7829. * @param width defines the width of the rectangle where pixels must be read
  7830. * @param height defines the height of the rectangle where pixels must be read
  7831. * @returns a Uint8Array containing RGBA colors
  7832. */
  7833. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  7834. /**
  7835. * Add an externaly attached data from its key.
  7836. * This method call will fail and return false, if such key already exists.
  7837. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  7838. * @param key the unique key that identifies the data
  7839. * @param data the data object to associate to the key for this Engine instance
  7840. * @return true if no such key were already present and the data was added successfully, false otherwise
  7841. */
  7842. addExternalData<T>(key: string, data: T): boolean;
  7843. /**
  7844. * Get an externaly attached data from its key
  7845. * @param key the unique key that identifies the data
  7846. * @return the associated data, if present (can be null), or undefined if not present
  7847. */
  7848. getExternalData<T>(key: string): T;
  7849. /**
  7850. * Get an externaly attached data from its key, create it using a factory if it's not already present
  7851. * @param key the unique key that identifies the data
  7852. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  7853. * @return the associated data, can be null if the factory returned null.
  7854. */
  7855. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  7856. /**
  7857. * Remove an externaly attached data from the Engine instance
  7858. * @param key the unique key that identifies the data
  7859. * @return true if the data was successfully removed, false if it doesn't exist
  7860. */
  7861. removeExternalData(key: string): boolean;
  7862. /**
  7863. * Unbind all vertex attributes from the webGL context
  7864. */
  7865. unbindAllAttributes(): void;
  7866. /**
  7867. * 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
  7868. */
  7869. releaseEffects(): void;
  7870. /**
  7871. * Dispose and release all associated resources
  7872. */
  7873. dispose(): void;
  7874. /**
  7875. * Display the loading screen
  7876. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7877. */
  7878. displayLoadingUI(): void;
  7879. /**
  7880. * Hide the loading screen
  7881. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7882. */
  7883. hideLoadingUI(): void;
  7884. /**
  7885. * Gets the current loading screen object
  7886. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7887. */
  7888. /**
  7889. * Sets the current loading screen object
  7890. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7891. */
  7892. loadingScreen: ILoadingScreen;
  7893. /**
  7894. * Sets the current loading screen text
  7895. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7896. */
  7897. loadingUIText: string;
  7898. /**
  7899. * Sets the current loading screen background color
  7900. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  7901. */
  7902. loadingUIBackgroundColor: string;
  7903. /**
  7904. * Attach a new callback raised when context lost event is fired
  7905. * @param callback defines the callback to call
  7906. */
  7907. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  7908. /**
  7909. * Attach a new callback raised when context restored event is fired
  7910. * @param callback defines the callback to call
  7911. */
  7912. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  7913. /**
  7914. * Gets the source code of the vertex shader associated with a specific webGL program
  7915. * @param program defines the program to use
  7916. * @returns a string containing the source code of the vertex shader associated with the program
  7917. */
  7918. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  7919. /**
  7920. * Gets the source code of the fragment shader associated with a specific webGL program
  7921. * @param program defines the program to use
  7922. * @returns a string containing the source code of the fragment shader associated with the program
  7923. */
  7924. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  7925. /**
  7926. * Get the current error code of the webGL context
  7927. * @returns the error code
  7928. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  7929. */
  7930. getError(): number;
  7931. /**
  7932. * Gets the current framerate
  7933. * @returns a number representing the framerate
  7934. */
  7935. getFps(): number;
  7936. /**
  7937. * Gets the time spent between current and previous frame
  7938. * @returns a number representing the delta time in ms
  7939. */
  7940. getDeltaTime(): number;
  7941. private _measureFps();
  7942. /** @hidden */
  7943. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number): ArrayBufferView;
  7944. private _canRenderToFloatFramebuffer();
  7945. private _canRenderToHalfFloatFramebuffer();
  7946. private _canRenderToFramebuffer(type);
  7947. /** @hidden */
  7948. _getWebGLTextureType(type: number): number;
  7949. private _getInternalFormat(format);
  7950. /** @hidden */
  7951. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  7952. /** @hidden */
  7953. _getRGBAMultiSampleBufferFormat(type: number): number;
  7954. /**
  7955. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  7956. * @return the new query
  7957. */
  7958. createQuery(): WebGLQuery;
  7959. /**
  7960. * Delete and release a webGL query
  7961. * @param query defines the query to delete
  7962. * @return the current engine
  7963. */
  7964. deleteQuery(query: WebGLQuery): Engine;
  7965. /**
  7966. * Check if a given query has resolved and got its value
  7967. * @param query defines the query to check
  7968. * @returns true if the query got its value
  7969. */
  7970. isQueryResultAvailable(query: WebGLQuery): boolean;
  7971. /**
  7972. * Gets the value of a given query
  7973. * @param query defines the query to check
  7974. * @returns the value of the query
  7975. */
  7976. getQueryResult(query: WebGLQuery): number;
  7977. /**
  7978. * Initiates an occlusion query
  7979. * @param algorithmType defines the algorithm to use
  7980. * @param query defines the query to use
  7981. * @returns the current engine
  7982. * @see http://doc.babylonjs.com/features/occlusionquery
  7983. */
  7984. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  7985. /**
  7986. * Ends an occlusion query
  7987. * @see http://doc.babylonjs.com/features/occlusionquery
  7988. * @param algorithmType defines the algorithm to use
  7989. * @returns the current engine
  7990. */
  7991. endOcclusionQuery(algorithmType: number): Engine;
  7992. private _createTimeQuery();
  7993. private _deleteTimeQuery(query);
  7994. private _getTimeQueryResult(query);
  7995. private _getTimeQueryAvailability(query);
  7996. private _currentNonTimestampToken;
  7997. /**
  7998. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  7999. * Please note that only one query can be issued at a time
  8000. * @returns a time token used to track the time span
  8001. */
  8002. startTimeQuery(): Nullable<_TimeToken>;
  8003. /**
  8004. * Ends a time query
  8005. * @param token defines the token used to measure the time span
  8006. * @returns the time spent (in ns)
  8007. */
  8008. endTimeQuery(token: _TimeToken): int;
  8009. private getGlAlgorithmType(algorithmType);
  8010. /**
  8011. * Creates a webGL transform feedback object
  8012. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  8013. * @returns the webGL transform feedback object
  8014. */
  8015. createTransformFeedback(): WebGLTransformFeedback;
  8016. /**
  8017. * Delete a webGL transform feedback object
  8018. * @param value defines the webGL transform feedback object to delete
  8019. */
  8020. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  8021. /**
  8022. * Bind a webGL transform feedback object to the webgl context
  8023. * @param value defines the webGL transform feedback object to bind
  8024. */
  8025. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  8026. /**
  8027. * Begins a transform feedback operation
  8028. * @param usePoints defines if points or triangles must be used
  8029. */
  8030. beginTransformFeedback(usePoints?: boolean): void;
  8031. /**
  8032. * Ends a transform feedback operation
  8033. */
  8034. endTransformFeedback(): void;
  8035. /**
  8036. * Specify the varyings to use with transform feedback
  8037. * @param program defines the associated webGL program
  8038. * @param value defines the list of strings representing the varying names
  8039. */
  8040. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  8041. /**
  8042. * Bind a webGL buffer for a transform feedback operation
  8043. * @param value defines the webGL buffer to bind
  8044. */
  8045. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  8046. /** @hidden */
  8047. _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;
  8048. /** @hidden */
  8049. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  8050. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  8051. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  8052. /**
  8053. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  8054. * @returns true if the engine can be created
  8055. * @ignorenaming
  8056. */
  8057. static isSupported(): boolean;
  8058. }
  8059. }
  8060. declare module BABYLON {
  8061. class NullEngineOptions {
  8062. renderWidth: number;
  8063. renderHeight: number;
  8064. textureSize: number;
  8065. deterministicLockstep: boolean;
  8066. lockstepMaxSteps: number;
  8067. }
  8068. /**
  8069. * The null engine class provides support for headless version of babylon.js.
  8070. * This can be used in server side scenario or for testing purposes
  8071. */
  8072. class NullEngine extends Engine {
  8073. private _options;
  8074. isDeterministicLockStep(): boolean;
  8075. getLockstepMaxSteps(): number;
  8076. getHardwareScalingLevel(): number;
  8077. constructor(options?: NullEngineOptions);
  8078. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8079. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  8080. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8081. getRenderWidth(useScreen?: boolean): number;
  8082. getRenderHeight(useScreen?: boolean): number;
  8083. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8084. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  8085. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  8086. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8087. bindSamplers(effect: Effect): void;
  8088. enableEffect(effect: Effect): void;
  8089. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8090. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  8091. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  8092. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  8093. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  8094. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  8095. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  8096. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  8097. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  8098. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  8099. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  8100. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  8101. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  8102. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  8103. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  8104. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8105. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8106. setFloat(uniform: WebGLUniformLocation, value: number): void;
  8107. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  8108. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  8109. setBool(uniform: WebGLUniformLocation, bool: number): void;
  8110. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  8111. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  8112. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  8113. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8114. bindBuffers(vertexBuffers: {
  8115. [key: string]: VertexBuffer;
  8116. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  8117. wipeCaches(bruteForce?: boolean): void;
  8118. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8119. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8120. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8121. _createTexture(): WebGLTexture;
  8122. _releaseTexture(texture: InternalTexture): void;
  8123. 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;
  8124. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8125. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8126. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  8127. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8128. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8129. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8130. /**
  8131. * Updates a dynamic vertex buffer.
  8132. * @param vertexBuffer the vertex buffer to update
  8133. * @param data the data used to update the vertex buffer
  8134. * @param byteOffset the byte offset of the data (optional)
  8135. * @param byteLength the byte length of the data (optional)
  8136. */
  8137. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  8138. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  8139. _bindTexture(channel: number, texture: InternalTexture): void;
  8140. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8141. releaseEffects(): void;
  8142. }
  8143. }
  8144. interface WebGLRenderingContext {
  8145. readonly RASTERIZER_DISCARD: number;
  8146. readonly DEPTH_COMPONENT24: number;
  8147. readonly TEXTURE_3D: number;
  8148. readonly TEXTURE_2D_ARRAY: number;
  8149. readonly TEXTURE_COMPARE_FUNC: number;
  8150. readonly TEXTURE_COMPARE_MODE: number;
  8151. readonly COMPARE_REF_TO_TEXTURE: number;
  8152. readonly TEXTURE_WRAP_R: number;
  8153. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  8154. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  8155. 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;
  8156. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  8157. readonly TRANSFORM_FEEDBACK: number;
  8158. readonly INTERLEAVED_ATTRIBS: number;
  8159. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  8160. createTransformFeedback(): WebGLTransformFeedback;
  8161. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  8162. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  8163. beginTransformFeedback(primitiveMode: number): void;
  8164. endTransformFeedback(): void;
  8165. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  8166. }
  8167. interface ImageBitmap {
  8168. readonly width: number;
  8169. readonly height: number;
  8170. close(): void;
  8171. }
  8172. interface WebGLQuery extends WebGLObject {
  8173. }
  8174. declare var WebGLQuery: {
  8175. prototype: WebGLQuery;
  8176. new (): WebGLQuery;
  8177. };
  8178. interface WebGLSampler extends WebGLObject {
  8179. }
  8180. declare var WebGLSampler: {
  8181. prototype: WebGLSampler;
  8182. new (): WebGLSampler;
  8183. };
  8184. interface WebGLSync extends WebGLObject {
  8185. }
  8186. declare var WebGLSync: {
  8187. prototype: WebGLSync;
  8188. new (): WebGLSync;
  8189. };
  8190. interface WebGLTransformFeedback extends WebGLObject {
  8191. }
  8192. declare var WebGLTransformFeedback: {
  8193. prototype: WebGLTransformFeedback;
  8194. new (): WebGLTransformFeedback;
  8195. };
  8196. interface WebGLVertexArrayObject extends WebGLObject {
  8197. }
  8198. declare var WebGLVertexArrayObject: {
  8199. prototype: WebGLVertexArrayObject;
  8200. new (): WebGLVertexArrayObject;
  8201. };
  8202. declare module BABYLON {
  8203. class ArcRotateCamera extends TargetCamera {
  8204. alpha: number;
  8205. beta: number;
  8206. radius: number;
  8207. protected _target: Vector3;
  8208. protected _targetHost: Nullable<AbstractMesh>;
  8209. target: Vector3;
  8210. inertialAlphaOffset: number;
  8211. inertialBetaOffset: number;
  8212. inertialRadiusOffset: number;
  8213. lowerAlphaLimit: Nullable<number>;
  8214. upperAlphaLimit: Nullable<number>;
  8215. lowerBetaLimit: number;
  8216. upperBetaLimit: number;
  8217. lowerRadiusLimit: Nullable<number>;
  8218. upperRadiusLimit: Nullable<number>;
  8219. inertialPanningX: number;
  8220. inertialPanningY: number;
  8221. pinchToPanMaxDistance: number;
  8222. panningDistanceLimit: Nullable<number>;
  8223. panningOriginTarget: Vector3;
  8224. panningInertia: number;
  8225. angularSensibilityX: number;
  8226. angularSensibilityY: number;
  8227. pinchPrecision: number;
  8228. pinchDeltaPercentage: number;
  8229. panningSensibility: number;
  8230. keysUp: number[];
  8231. keysDown: number[];
  8232. keysLeft: number[];
  8233. keysRight: number[];
  8234. wheelPrecision: number;
  8235. wheelDeltaPercentage: number;
  8236. zoomOnFactor: number;
  8237. targetScreenOffset: Vector2;
  8238. allowUpsideDown: boolean;
  8239. _viewMatrix: Matrix;
  8240. _useCtrlForPanning: boolean;
  8241. _panningMouseButton: number;
  8242. inputs: ArcRotateCameraInputsManager;
  8243. _reset: () => void;
  8244. panningAxis: Vector3;
  8245. protected _localDirection: Vector3;
  8246. protected _transformedDirection: Vector3;
  8247. private _bouncingBehavior;
  8248. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  8249. useBouncingBehavior: boolean;
  8250. private _framingBehavior;
  8251. readonly framingBehavior: Nullable<FramingBehavior>;
  8252. useFramingBehavior: boolean;
  8253. private _autoRotationBehavior;
  8254. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  8255. useAutoRotationBehavior: boolean;
  8256. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  8257. onCollide: (collidedMesh: AbstractMesh) => void;
  8258. checkCollisions: boolean;
  8259. collisionRadius: Vector3;
  8260. protected _collider: Collider;
  8261. protected _previousPosition: Vector3;
  8262. protected _collisionVelocity: Vector3;
  8263. protected _newPosition: Vector3;
  8264. protected _previousAlpha: number;
  8265. protected _previousBeta: number;
  8266. protected _previousRadius: number;
  8267. protected _collisionTriggered: boolean;
  8268. protected _targetBoundingCenter: Nullable<Vector3>;
  8269. private _computationVector;
  8270. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8271. _initCache(): void;
  8272. _updateCache(ignoreParentClass?: boolean): void;
  8273. protected _getTargetPosition(): Vector3;
  8274. /**
  8275. * Store current camera state (fov, position, etc..)
  8276. */
  8277. private _storedAlpha;
  8278. private _storedBeta;
  8279. private _storedRadius;
  8280. private _storedTarget;
  8281. storeState(): Camera;
  8282. /**
  8283. * Restored camera state. You must call storeState() first
  8284. */
  8285. _restoreStateValues(): boolean;
  8286. _isSynchronizedViewMatrix(): boolean;
  8287. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  8288. detachControl(element: HTMLElement): void;
  8289. _checkInputs(): void;
  8290. protected _checkLimits(): void;
  8291. rebuildAnglesAndRadius(): void;
  8292. setPosition(position: Vector3): void;
  8293. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  8294. _getViewMatrix(): Matrix;
  8295. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  8296. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  8297. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  8298. min: Vector3;
  8299. max: Vector3;
  8300. distance: number;
  8301. }, doNotUpdateMaxZ?: boolean): void;
  8302. /**
  8303. * @override
  8304. * Override Camera.createRigCamera
  8305. */
  8306. createRigCamera(name: string, cameraIndex: number): Camera;
  8307. /**
  8308. * @override
  8309. * Override Camera._updateRigCameras
  8310. */
  8311. _updateRigCameras(): void;
  8312. dispose(): void;
  8313. getClassName(): string;
  8314. }
  8315. }
  8316. declare module BABYLON {
  8317. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  8318. constructor(camera: ArcRotateCamera);
  8319. addMouseWheel(): ArcRotateCameraInputsManager;
  8320. addPointers(): ArcRotateCameraInputsManager;
  8321. addKeyboard(): ArcRotateCameraInputsManager;
  8322. addGamepad(): ArcRotateCameraInputsManager;
  8323. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  8324. }
  8325. }
  8326. declare module BABYLON {
  8327. class Camera extends Node {
  8328. inputs: CameraInputsManager<Camera>;
  8329. private static _PERSPECTIVE_CAMERA;
  8330. private static _ORTHOGRAPHIC_CAMERA;
  8331. private static _FOVMODE_VERTICAL_FIXED;
  8332. private static _FOVMODE_HORIZONTAL_FIXED;
  8333. private static _RIG_MODE_NONE;
  8334. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  8335. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  8336. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  8337. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  8338. private static _RIG_MODE_VR;
  8339. private static _RIG_MODE_WEBVR;
  8340. static readonly PERSPECTIVE_CAMERA: number;
  8341. static readonly ORTHOGRAPHIC_CAMERA: number;
  8342. /**
  8343. * This is the default FOV mode for perspective cameras.
  8344. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  8345. *
  8346. */
  8347. static readonly FOVMODE_VERTICAL_FIXED: number;
  8348. /**
  8349. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  8350. *
  8351. */
  8352. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  8353. static readonly RIG_MODE_NONE: number;
  8354. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  8355. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  8356. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  8357. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  8358. static readonly RIG_MODE_VR: number;
  8359. static readonly RIG_MODE_WEBVR: number;
  8360. static ForceAttachControlToAlwaysPreventDefault: boolean;
  8361. static UseAlternateWebVRRendering: boolean;
  8362. position: Vector3;
  8363. /**
  8364. * The vector the camera should consider as up.
  8365. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  8366. */
  8367. upVector: Vector3;
  8368. orthoLeft: Nullable<number>;
  8369. orthoRight: Nullable<number>;
  8370. orthoBottom: Nullable<number>;
  8371. orthoTop: Nullable<number>;
  8372. /**
  8373. * FOV is set in Radians. (default is 0.8)
  8374. */
  8375. fov: number;
  8376. minZ: number;
  8377. maxZ: number;
  8378. inertia: number;
  8379. mode: number;
  8380. isIntermediate: boolean;
  8381. viewport: Viewport;
  8382. /**
  8383. * Restricts the camera to viewing objects with the same layerMask.
  8384. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  8385. */
  8386. layerMask: number;
  8387. /**
  8388. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  8389. */
  8390. fovMode: number;
  8391. cameraRigMode: number;
  8392. interaxialDistance: number;
  8393. isStereoscopicSideBySide: boolean;
  8394. _cameraRigParams: any;
  8395. _rigCameras: Camera[];
  8396. _rigPostProcess: Nullable<PostProcess>;
  8397. protected _webvrViewMatrix: Matrix;
  8398. _skipRendering: boolean;
  8399. _alternateCamera: Camera;
  8400. customRenderTargets: RenderTargetTexture[];
  8401. onViewMatrixChangedObservable: Observable<Camera>;
  8402. onProjectionMatrixChangedObservable: Observable<Camera>;
  8403. onAfterCheckInputsObservable: Observable<Camera>;
  8404. onRestoreStateObservable: Observable<Camera>;
  8405. private _computedViewMatrix;
  8406. _projectionMatrix: Matrix;
  8407. private _doNotComputeProjectionMatrix;
  8408. private _worldMatrix;
  8409. _postProcesses: Nullable<PostProcess>[];
  8410. private _transformMatrix;
  8411. _activeMeshes: SmartArray<AbstractMesh>;
  8412. protected _globalPosition: Vector3;
  8413. private _frustumPlanes;
  8414. private _refreshFrustumPlanes;
  8415. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8416. private _storedFov;
  8417. private _stateStored;
  8418. /**
  8419. * Store current camera state (fov, position, etc..)
  8420. */
  8421. storeState(): Camera;
  8422. /**
  8423. * Restores the camera state values if it has been stored. You must call storeState() first
  8424. */
  8425. protected _restoreStateValues(): boolean;
  8426. /**
  8427. * Restored camera state. You must call storeState() first
  8428. */
  8429. restoreState(): boolean;
  8430. getClassName(): string;
  8431. /**
  8432. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  8433. */
  8434. toString(fullDetails?: boolean): string;
  8435. readonly globalPosition: Vector3;
  8436. getActiveMeshes(): SmartArray<AbstractMesh>;
  8437. isActiveMesh(mesh: Mesh): boolean;
  8438. /**
  8439. * Is this camera ready to be used/rendered
  8440. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  8441. * @return true if the camera is ready
  8442. */
  8443. isReady(completeCheck?: boolean): boolean;
  8444. _initCache(): void;
  8445. _updateCache(ignoreParentClass?: boolean): void;
  8446. _isSynchronized(): boolean;
  8447. _isSynchronizedViewMatrix(): boolean;
  8448. _isSynchronizedProjectionMatrix(): boolean;
  8449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8450. detachControl(element: HTMLElement): void;
  8451. update(): void;
  8452. _checkInputs(): void;
  8453. readonly rigCameras: Camera[];
  8454. readonly rigPostProcess: Nullable<PostProcess>;
  8455. /**
  8456. * Internal, gets the first post proces.
  8457. * @returns the first post process to be run on this camera.
  8458. */
  8459. _getFirstPostProcess(): Nullable<PostProcess>;
  8460. private _cascadePostProcessesToRigCams();
  8461. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  8462. detachPostProcess(postProcess: PostProcess): void;
  8463. getWorldMatrix(): Matrix;
  8464. _getViewMatrix(): Matrix;
  8465. getViewMatrix(force?: boolean): Matrix;
  8466. freezeProjectionMatrix(projection?: Matrix): void;
  8467. unfreezeProjectionMatrix(): void;
  8468. getProjectionMatrix(force?: boolean): Matrix;
  8469. getTranformationMatrix(): Matrix;
  8470. private updateFrustumPlanes();
  8471. isInFrustum(target: ICullable): boolean;
  8472. isCompletelyInFrustum(target: ICullable): boolean;
  8473. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  8474. /**
  8475. * Releases resources associated with this node.
  8476. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8477. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8478. */
  8479. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8480. readonly leftCamera: Nullable<FreeCamera>;
  8481. readonly rightCamera: Nullable<FreeCamera>;
  8482. getLeftTarget(): Nullable<Vector3>;
  8483. getRightTarget(): Nullable<Vector3>;
  8484. setCameraRigMode(mode: number, rigParams: any): void;
  8485. private _getVRProjectionMatrix();
  8486. protected _updateCameraRotationMatrix(): void;
  8487. protected _updateWebVRCameraRotationMatrix(): void;
  8488. /**
  8489. * This function MUST be overwritten by the different WebVR cameras available.
  8490. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8491. */
  8492. protected _getWebVRProjectionMatrix(): Matrix;
  8493. /**
  8494. * This function MUST be overwritten by the different WebVR cameras available.
  8495. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8496. */
  8497. protected _getWebVRViewMatrix(): Matrix;
  8498. setCameraRigParameter(name: string, value: any): void;
  8499. /**
  8500. * needs to be overridden by children so sub has required properties to be copied
  8501. */
  8502. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8503. /**
  8504. * May need to be overridden by children
  8505. */
  8506. _updateRigCameras(): void;
  8507. _setupInputs(): void;
  8508. serialize(): any;
  8509. clone(name: string): Camera;
  8510. getDirection(localAxis: Vector3): Vector3;
  8511. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  8512. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  8513. computeWorldMatrix(): Matrix;
  8514. static Parse(parsedCamera: any, scene: Scene): Camera;
  8515. }
  8516. }
  8517. declare module BABYLON {
  8518. var CameraInputTypes: {};
  8519. interface ICameraInput<TCamera extends Camera> {
  8520. camera: Nullable<TCamera>;
  8521. getClassName(): string;
  8522. getSimpleName(): string;
  8523. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  8524. detachControl: (element: Nullable<HTMLElement>) => void;
  8525. checkInputs?: () => void;
  8526. }
  8527. interface CameraInputsMap<TCamera extends Camera> {
  8528. [name: string]: ICameraInput<TCamera>;
  8529. [idx: number]: ICameraInput<TCamera>;
  8530. }
  8531. class CameraInputsManager<TCamera extends Camera> {
  8532. attached: CameraInputsMap<TCamera>;
  8533. attachedElement: Nullable<HTMLElement>;
  8534. noPreventDefault: boolean;
  8535. camera: TCamera;
  8536. checkInputs: () => void;
  8537. constructor(camera: TCamera);
  8538. /**
  8539. * Add an input method to a camera.
  8540. * builtin inputs example: camera.inputs.addGamepad();
  8541. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  8542. * @param input camera input method
  8543. */
  8544. add(input: ICameraInput<TCamera>): void;
  8545. /**
  8546. * Remove a specific input method from a camera
  8547. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8548. * @param inputToRemove camera input method
  8549. */
  8550. remove(inputToRemove: ICameraInput<TCamera>): void;
  8551. removeByType(inputType: string): void;
  8552. private _addCheckInputs(fn);
  8553. attachInput(input: ICameraInput<TCamera>): void;
  8554. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8555. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8556. rebuildInputCheck(): void;
  8557. /**
  8558. * Remove all attached input methods from a camera
  8559. */
  8560. clear(): void;
  8561. serialize(serializedCamera: any): void;
  8562. parse(parsedCamera: any): void;
  8563. }
  8564. }
  8565. declare module BABYLON {
  8566. /**
  8567. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  8568. * being tilted forward or back and left or right.
  8569. */
  8570. class DeviceOrientationCamera extends FreeCamera {
  8571. private _initialQuaternion;
  8572. private _quaternionCache;
  8573. /**
  8574. * Creates a new device orientation camera
  8575. * @param name The name of the camera
  8576. * @param position The start position camera
  8577. * @param scene The scene the camera belongs to
  8578. */
  8579. constructor(name: string, position: Vector3, scene: Scene);
  8580. /**
  8581. * Gets the current instance class name ("DeviceOrientationCamera").
  8582. * This helps avoiding instanceof at run time.
  8583. * @returns the class name
  8584. */
  8585. getClassName(): string;
  8586. /**
  8587. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  8588. */
  8589. _checkInputs(): void;
  8590. /**
  8591. * Reset the camera to its default orientation on the specified axis only.
  8592. * @param axis The axis to reset
  8593. */
  8594. resetToCurrentRotation(axis?: Axis): void;
  8595. }
  8596. }
  8597. declare module BABYLON {
  8598. class FollowCamera extends TargetCamera {
  8599. radius: number;
  8600. rotationOffset: number;
  8601. heightOffset: number;
  8602. cameraAcceleration: number;
  8603. maxCameraSpeed: number;
  8604. lockedTarget: Nullable<AbstractMesh>;
  8605. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8606. private getRadians(degrees);
  8607. private follow(cameraTarget);
  8608. _checkInputs(): void;
  8609. getClassName(): string;
  8610. }
  8611. class ArcFollowCamera extends TargetCamera {
  8612. alpha: number;
  8613. beta: number;
  8614. radius: number;
  8615. target: Nullable<AbstractMesh>;
  8616. private _cartesianCoordinates;
  8617. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  8618. private follow();
  8619. _checkInputs(): void;
  8620. getClassName(): string;
  8621. }
  8622. }
  8623. declare module BABYLON {
  8624. class FreeCamera extends TargetCamera {
  8625. ellipsoid: Vector3;
  8626. ellipsoidOffset: Vector3;
  8627. checkCollisions: boolean;
  8628. applyGravity: boolean;
  8629. inputs: FreeCameraInputsManager;
  8630. /**
  8631. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8632. * Higher values reduce sensitivity.
  8633. */
  8634. /**
  8635. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8636. * Higher values reduce sensitivity.
  8637. */
  8638. angularSensibility: number;
  8639. keysUp: number[];
  8640. keysDown: number[];
  8641. keysLeft: number[];
  8642. keysRight: number[];
  8643. onCollide: (collidedMesh: AbstractMesh) => void;
  8644. private _collider;
  8645. private _needMoveForGravity;
  8646. private _oldPosition;
  8647. private _diffPosition;
  8648. private _newPosition;
  8649. _localDirection: Vector3;
  8650. _transformedDirection: Vector3;
  8651. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8652. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8653. detachControl(element: HTMLElement): void;
  8654. private _collisionMask;
  8655. collisionMask: number;
  8656. _collideWithWorld(displacement: Vector3): void;
  8657. private _onCollisionPositionChange;
  8658. _checkInputs(): void;
  8659. _decideIfNeedsToMove(): boolean;
  8660. _updatePosition(): void;
  8661. dispose(): void;
  8662. getClassName(): string;
  8663. }
  8664. }
  8665. declare module BABYLON {
  8666. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8667. constructor(camera: FreeCamera);
  8668. addKeyboard(): FreeCameraInputsManager;
  8669. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8670. addGamepad(): FreeCameraInputsManager;
  8671. addDeviceOrientation(): FreeCameraInputsManager;
  8672. addTouch(): FreeCameraInputsManager;
  8673. addVirtualJoystick(): FreeCameraInputsManager;
  8674. }
  8675. }
  8676. declare module BABYLON {
  8677. class GamepadCamera extends UniversalCamera {
  8678. gamepadAngularSensibility: number;
  8679. gamepadMoveSensibility: number;
  8680. constructor(name: string, position: Vector3, scene: Scene);
  8681. getClassName(): string;
  8682. }
  8683. }
  8684. declare module BABYLON {
  8685. /**
  8686. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  8687. */
  8688. class AnaglyphFreeCamera extends FreeCamera {
  8689. /**
  8690. * Creates a new AnaglyphFreeCamera
  8691. * @param name defines camera name
  8692. * @param position defines initial position
  8693. * @param interaxialDistance defines distance between each color axis
  8694. * @param scene defines the hosting scene
  8695. */
  8696. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  8697. /**
  8698. * Gets camera class name
  8699. * @returns AnaglyphFreeCamera
  8700. */
  8701. getClassName(): string;
  8702. }
  8703. /**
  8704. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  8705. */
  8706. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  8707. /**
  8708. * Creates a new AnaglyphArcRotateCamera
  8709. * @param name defines camera name
  8710. * @param alpha defines alpha angle (in radians)
  8711. * @param beta defines beta angle (in radians)
  8712. * @param radius defines radius
  8713. * @param target defines camera target
  8714. * @param interaxialDistance defines distance between each color axis
  8715. * @param scene defines the hosting scene
  8716. */
  8717. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  8718. /**
  8719. * Gets camera class name
  8720. * @returns AnaglyphArcRotateCamera
  8721. */
  8722. getClassName(): string;
  8723. }
  8724. /**
  8725. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  8726. */
  8727. class AnaglyphGamepadCamera extends GamepadCamera {
  8728. /**
  8729. * Creates a new AnaglyphGamepadCamera
  8730. * @param name defines camera name
  8731. * @param position defines initial position
  8732. * @param interaxialDistance defines distance between each color axis
  8733. * @param scene defines the hosting scene
  8734. */
  8735. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  8736. /**
  8737. * Gets camera class name
  8738. * @returns AnaglyphGamepadCamera
  8739. */
  8740. getClassName(): string;
  8741. }
  8742. /**
  8743. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  8744. */
  8745. class AnaglyphUniversalCamera extends UniversalCamera {
  8746. /**
  8747. * Creates a new AnaglyphUniversalCamera
  8748. * @param name defines camera name
  8749. * @param position defines initial position
  8750. * @param interaxialDistance defines distance between each color axis
  8751. * @param scene defines the hosting scene
  8752. */
  8753. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  8754. /**
  8755. * Gets camera class name
  8756. * @returns AnaglyphUniversalCamera
  8757. */
  8758. getClassName(): string;
  8759. }
  8760. /**
  8761. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  8762. */
  8763. class StereoscopicFreeCamera extends FreeCamera {
  8764. /**
  8765. * Creates a new StereoscopicFreeCamera
  8766. * @param name defines camera name
  8767. * @param position defines initial position
  8768. * @param interaxialDistance defines distance between each color axis
  8769. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  8770. * @param scene defines the hosting scene
  8771. */
  8772. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  8773. /**
  8774. * Gets camera class name
  8775. * @returns StereoscopicFreeCamera
  8776. */
  8777. getClassName(): string;
  8778. }
  8779. /**
  8780. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  8781. */
  8782. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  8783. /**
  8784. * Creates a new StereoscopicArcRotateCamera
  8785. * @param name defines camera name
  8786. * @param alpha defines alpha angle (in radians)
  8787. * @param beta defines beta angle (in radians)
  8788. * @param radius defines radius
  8789. * @param target defines camera target
  8790. * @param interaxialDistance defines distance between each color axis
  8791. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  8792. * @param scene defines the hosting scene
  8793. */
  8794. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  8795. /**
  8796. * Gets camera class name
  8797. * @returns StereoscopicArcRotateCamera
  8798. */
  8799. getClassName(): string;
  8800. }
  8801. /**
  8802. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  8803. */
  8804. class StereoscopicGamepadCamera extends GamepadCamera {
  8805. /**
  8806. * Creates a new StereoscopicGamepadCamera
  8807. * @param name defines camera name
  8808. * @param position defines initial position
  8809. * @param interaxialDistance defines distance between each color axis
  8810. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  8811. * @param scene defines the hosting scene
  8812. */
  8813. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  8814. /**
  8815. * Gets camera class name
  8816. * @returns StereoscopicGamepadCamera
  8817. */
  8818. getClassName(): string;
  8819. }
  8820. /**
  8821. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  8822. */
  8823. class StereoscopicUniversalCamera extends UniversalCamera {
  8824. /**
  8825. * Creates a new StereoscopicUniversalCamera
  8826. * @param name defines camera name
  8827. * @param position defines initial position
  8828. * @param interaxialDistance defines distance between each color axis
  8829. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  8830. * @param scene defines the hosting scene
  8831. */
  8832. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  8833. /**
  8834. * Gets camera class name
  8835. * @returns StereoscopicUniversalCamera
  8836. */
  8837. getClassName(): string;
  8838. }
  8839. }
  8840. declare module BABYLON {
  8841. class TargetCamera extends Camera {
  8842. cameraDirection: Vector3;
  8843. cameraRotation: Vector2;
  8844. rotation: Vector3;
  8845. rotationQuaternion: Quaternion;
  8846. speed: number;
  8847. noRotationConstraint: boolean;
  8848. lockedTarget: any;
  8849. _currentTarget: Vector3;
  8850. _viewMatrix: Matrix;
  8851. _camMatrix: Matrix;
  8852. _cameraTransformMatrix: Matrix;
  8853. _cameraRotationMatrix: Matrix;
  8854. private _rigCamTransformMatrix;
  8855. _referencePoint: Vector3;
  8856. private _currentUpVector;
  8857. _transformedReferencePoint: Vector3;
  8858. protected _globalCurrentTarget: Vector3;
  8859. protected _globalCurrentUpVector: Vector3;
  8860. _reset: () => void;
  8861. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8862. getFrontPosition(distance: number): Vector3;
  8863. _getLockedTargetPosition(): Nullable<Vector3>;
  8864. /**
  8865. * Store current camera state (fov, position, etc..)
  8866. */
  8867. private _storedPosition;
  8868. private _storedRotation;
  8869. private _storedRotationQuaternion;
  8870. storeState(): Camera;
  8871. /**
  8872. * Restored camera state. You must call storeState() first
  8873. */
  8874. _restoreStateValues(): boolean;
  8875. _initCache(): void;
  8876. _updateCache(ignoreParentClass?: boolean): void;
  8877. _isSynchronizedViewMatrix(): boolean;
  8878. _computeLocalCameraSpeed(): number;
  8879. setTarget(target: Vector3): void;
  8880. /**
  8881. * Return the current target position of the camera. This value is expressed in local space.
  8882. */
  8883. getTarget(): Vector3;
  8884. _decideIfNeedsToMove(): boolean;
  8885. _updatePosition(): void;
  8886. _checkInputs(): void;
  8887. protected _updateCameraRotationMatrix(): void;
  8888. _getViewMatrix(): Matrix;
  8889. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8890. /**
  8891. * @override
  8892. * Override Camera.createRigCamera
  8893. */
  8894. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8895. /**
  8896. * @override
  8897. * Override Camera._updateRigCameras
  8898. */
  8899. _updateRigCameras(): void;
  8900. private _getRigCamPosition(halfSpace, result);
  8901. getClassName(): string;
  8902. }
  8903. }
  8904. declare module BABYLON {
  8905. class TouchCamera extends FreeCamera {
  8906. touchAngularSensibility: number;
  8907. touchMoveSensibility: number;
  8908. constructor(name: string, position: Vector3, scene: Scene);
  8909. getClassName(): string;
  8910. _setupInputs(): void;
  8911. }
  8912. }
  8913. declare module BABYLON {
  8914. class UniversalCamera extends TouchCamera {
  8915. gamepadAngularSensibility: number;
  8916. gamepadMoveSensibility: number;
  8917. constructor(name: string, position: Vector3, scene: Scene);
  8918. getClassName(): string;
  8919. }
  8920. }
  8921. declare module BABYLON {
  8922. class VirtualJoysticksCamera extends FreeCamera {
  8923. constructor(name: string, position: Vector3, scene: Scene);
  8924. getClassName(): string;
  8925. }
  8926. }
  8927. interface VRDisplay extends EventTarget {
  8928. /**
  8929. * Dictionary of capabilities describing the VRDisplay.
  8930. */
  8931. readonly capabilities: VRDisplayCapabilities;
  8932. /**
  8933. * z-depth defining the far plane of the eye view frustum
  8934. * enables mapping of values in the render target depth
  8935. * attachment to scene coordinates. Initially set to 10000.0.
  8936. */
  8937. depthFar: number;
  8938. /**
  8939. * z-depth defining the near plane of the eye view frustum
  8940. * enables mapping of values in the render target depth
  8941. * attachment to scene coordinates. Initially set to 0.01.
  8942. */
  8943. depthNear: number;
  8944. /**
  8945. * An identifier for this distinct VRDisplay. Used as an
  8946. * association point in the Gamepad API.
  8947. */
  8948. readonly displayId: number;
  8949. /**
  8950. * A display name, a user-readable name identifying it.
  8951. */
  8952. readonly displayName: string;
  8953. readonly isConnected: boolean;
  8954. readonly isPresenting: boolean;
  8955. /**
  8956. * If this VRDisplay supports room-scale experiences, the optional
  8957. * stage attribute contains details on the room-scale parameters.
  8958. */
  8959. readonly stageParameters: VRStageParameters | null;
  8960. /**
  8961. * Passing the value returned by `requestAnimationFrame` to
  8962. * `cancelAnimationFrame` will unregister the callback.
  8963. */
  8964. cancelAnimationFrame(handle: number): void;
  8965. /**
  8966. * Stops presenting to the VRDisplay.
  8967. */
  8968. exitPresent(): Promise<void>;
  8969. getEyeParameters(whichEye: string): VREyeParameters;
  8970. /**
  8971. * Populates the passed VRFrameData with the information required to render
  8972. * the current frame.
  8973. */
  8974. getFrameData(frameData: VRFrameData): boolean;
  8975. /**
  8976. * Get the layers currently being presented.
  8977. */
  8978. getLayers(): VRLayer[];
  8979. /**
  8980. * Return a VRPose containing the future predicted pose of the VRDisplay
  8981. * when the current frame will be presented. The value returned will not
  8982. * change until JavaScript has returned control to the browser.
  8983. *
  8984. * The VRPose will contain the position, orientation, velocity,
  8985. * and acceleration of each of these properties.
  8986. */
  8987. getPose(): VRPose;
  8988. /**
  8989. * Return the current instantaneous pose of the VRDisplay, with no
  8990. * prediction applied.
  8991. */
  8992. getImmediatePose(): VRPose;
  8993. /**
  8994. * The callback passed to `requestAnimationFrame` will be called
  8995. * any time a new frame should be rendered. When the VRDisplay is
  8996. * presenting the callback will be called at the native refresh
  8997. * rate of the HMD. When not presenting this function acts
  8998. * identically to how window.requestAnimationFrame acts. Content should
  8999. * make no assumptions of frame rate or vsync behavior as the HMD runs
  9000. * asynchronously from other displays and at differing refresh rates.
  9001. */
  9002. requestAnimationFrame(callback: FrameRequestCallback): number;
  9003. /**
  9004. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  9005. * Repeat calls while already presenting will update the VRLayers being displayed.
  9006. */
  9007. requestPresent(layers: VRLayer[]): Promise<void>;
  9008. /**
  9009. * Reset the pose for this display, treating its current position and
  9010. * orientation as the "origin/zero" values. VRPose.position,
  9011. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  9012. * updated when calling resetPose(). This should be called in only
  9013. * sitting-space experiences.
  9014. */
  9015. resetPose(): void;
  9016. /**
  9017. * The VRLayer provided to the VRDisplay will be captured and presented
  9018. * in the HMD. Calling this function has the same effect on the source
  9019. * canvas as any other operation that uses its source image, and canvases
  9020. * created without preserveDrawingBuffer set to true will be cleared.
  9021. */
  9022. submitFrame(pose?: VRPose): void;
  9023. }
  9024. declare var VRDisplay: {
  9025. prototype: VRDisplay;
  9026. new (): VRDisplay;
  9027. };
  9028. interface VRLayer {
  9029. leftBounds?: number[] | null;
  9030. rightBounds?: number[] | null;
  9031. source?: HTMLCanvasElement | null;
  9032. }
  9033. interface VRDisplayCapabilities {
  9034. readonly canPresent: boolean;
  9035. readonly hasExternalDisplay: boolean;
  9036. readonly hasOrientation: boolean;
  9037. readonly hasPosition: boolean;
  9038. readonly maxLayers: number;
  9039. }
  9040. interface VREyeParameters {
  9041. /** @deprecated */
  9042. readonly fieldOfView: VRFieldOfView;
  9043. readonly offset: Float32Array;
  9044. readonly renderHeight: number;
  9045. readonly renderWidth: number;
  9046. }
  9047. interface VRFieldOfView {
  9048. readonly downDegrees: number;
  9049. readonly leftDegrees: number;
  9050. readonly rightDegrees: number;
  9051. readonly upDegrees: number;
  9052. }
  9053. interface VRFrameData {
  9054. readonly leftProjectionMatrix: Float32Array;
  9055. readonly leftViewMatrix: Float32Array;
  9056. readonly pose: VRPose;
  9057. readonly rightProjectionMatrix: Float32Array;
  9058. readonly rightViewMatrix: Float32Array;
  9059. readonly timestamp: number;
  9060. }
  9061. interface VRPose {
  9062. readonly angularAcceleration: Float32Array | null;
  9063. readonly angularVelocity: Float32Array | null;
  9064. readonly linearAcceleration: Float32Array | null;
  9065. readonly linearVelocity: Float32Array | null;
  9066. readonly orientation: Float32Array | null;
  9067. readonly position: Float32Array | null;
  9068. readonly timestamp: number;
  9069. }
  9070. interface VRStageParameters {
  9071. sittingToStandingTransform?: Float32Array;
  9072. sizeX?: number;
  9073. sizeY?: number;
  9074. }
  9075. interface Navigator {
  9076. getVRDisplays(): Promise<VRDisplay[]>;
  9077. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  9078. }
  9079. interface Window {
  9080. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  9081. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  9082. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  9083. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9084. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9085. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  9086. }
  9087. interface Gamepad {
  9088. readonly displayId: number;
  9089. }
  9090. declare module BABYLON {
  9091. /**
  9092. * Represents the different options available during the creation of
  9093. * a Environment helper.
  9094. *
  9095. * This can control the default ground, skybox and image processing setup of your scene.
  9096. */
  9097. interface IEnvironmentHelperOptions {
  9098. /**
  9099. * Specifies wether or not to create a ground.
  9100. * True by default.
  9101. */
  9102. createGround: boolean;
  9103. /**
  9104. * Specifies the ground size.
  9105. * 15 by default.
  9106. */
  9107. groundSize: number;
  9108. /**
  9109. * The texture used on the ground for the main color.
  9110. * Comes from the BabylonJS CDN by default.
  9111. *
  9112. * Remarks: Can be either a texture or a url.
  9113. */
  9114. groundTexture: string | BaseTexture;
  9115. /**
  9116. * The color mixed in the ground texture by default.
  9117. * BabylonJS clearColor by default.
  9118. */
  9119. groundColor: Color3;
  9120. /**
  9121. * Specifies the ground opacity.
  9122. * 1 by default.
  9123. */
  9124. groundOpacity: number;
  9125. /**
  9126. * Enables the ground to receive shadows.
  9127. * True by default.
  9128. */
  9129. enableGroundShadow: boolean;
  9130. /**
  9131. * Helps preventing the shadow to be fully black on the ground.
  9132. * 0.5 by default.
  9133. */
  9134. groundShadowLevel: number;
  9135. /**
  9136. * Creates a mirror texture attach to the ground.
  9137. * false by default.
  9138. */
  9139. enableGroundMirror: boolean;
  9140. /**
  9141. * Specifies the ground mirror size ratio.
  9142. * 0.3 by default as the default kernel is 64.
  9143. */
  9144. groundMirrorSizeRatio: number;
  9145. /**
  9146. * Specifies the ground mirror blur kernel size.
  9147. * 64 by default.
  9148. */
  9149. groundMirrorBlurKernel: number;
  9150. /**
  9151. * Specifies the ground mirror visibility amount.
  9152. * 1 by default
  9153. */
  9154. groundMirrorAmount: number;
  9155. /**
  9156. * Specifies the ground mirror reflectance weight.
  9157. * This uses the standard weight of the background material to setup the fresnel effect
  9158. * of the mirror.
  9159. * 1 by default.
  9160. */
  9161. groundMirrorFresnelWeight: number;
  9162. /**
  9163. * Specifies the ground mirror Falloff distance.
  9164. * This can helps reducing the size of the reflection.
  9165. * 0 by Default.
  9166. */
  9167. groundMirrorFallOffDistance: number;
  9168. /**
  9169. * Specifies the ground mirror texture type.
  9170. * Unsigned Int by Default.
  9171. */
  9172. groundMirrorTextureType: number;
  9173. /**
  9174. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  9175. * the shown objects.
  9176. */
  9177. groundYBias: number;
  9178. /**
  9179. * Specifies wether or not to create a skybox.
  9180. * True by default.
  9181. */
  9182. createSkybox: boolean;
  9183. /**
  9184. * Specifies the skybox size.
  9185. * 20 by default.
  9186. */
  9187. skyboxSize: number;
  9188. /**
  9189. * The texture used on the skybox for the main color.
  9190. * Comes from the BabylonJS CDN by default.
  9191. *
  9192. * Remarks: Can be either a texture or a url.
  9193. */
  9194. skyboxTexture: string | BaseTexture;
  9195. /**
  9196. * The color mixed in the skybox texture by default.
  9197. * BabylonJS clearColor by default.
  9198. */
  9199. skyboxColor: Color3;
  9200. /**
  9201. * The background rotation around the Y axis of the scene.
  9202. * This helps aligning the key lights of your scene with the background.
  9203. * 0 by default.
  9204. */
  9205. backgroundYRotation: number;
  9206. /**
  9207. * Compute automatically the size of the elements to best fit with the scene.
  9208. */
  9209. sizeAuto: boolean;
  9210. /**
  9211. * Default position of the rootMesh if autoSize is not true.
  9212. */
  9213. rootPosition: Vector3;
  9214. /**
  9215. * Sets up the image processing in the scene.
  9216. * true by default.
  9217. */
  9218. setupImageProcessing: boolean;
  9219. /**
  9220. * The texture used as your environment texture in the scene.
  9221. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  9222. *
  9223. * Remarks: Can be either a texture or a url.
  9224. */
  9225. environmentTexture: string | BaseTexture;
  9226. /**
  9227. * The value of the exposure to apply to the scene.
  9228. * 0.6 by default if setupImageProcessing is true.
  9229. */
  9230. cameraExposure: number;
  9231. /**
  9232. * The value of the contrast to apply to the scene.
  9233. * 1.6 by default if setupImageProcessing is true.
  9234. */
  9235. cameraContrast: number;
  9236. /**
  9237. * Specifies wether or not tonemapping should be enabled in the scene.
  9238. * true by default if setupImageProcessing is true.
  9239. */
  9240. toneMappingEnabled: boolean;
  9241. }
  9242. /**
  9243. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  9244. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  9245. * It also helps with the default setup of your imageProcessing configuration.
  9246. */
  9247. class EnvironmentHelper {
  9248. /**
  9249. * Default ground texture URL.
  9250. */
  9251. private static _groundTextureCDNUrl;
  9252. /**
  9253. * Default skybox texture URL.
  9254. */
  9255. private static _skyboxTextureCDNUrl;
  9256. /**
  9257. * Default environment texture URL.
  9258. */
  9259. private static _environmentTextureCDNUrl;
  9260. /**
  9261. * Creates the default options for the helper.
  9262. */
  9263. private static _getDefaultOptions();
  9264. private _rootMesh;
  9265. /**
  9266. * Gets the root mesh created by the helper.
  9267. */
  9268. readonly rootMesh: Mesh;
  9269. private _skybox;
  9270. /**
  9271. * Gets the skybox created by the helper.
  9272. */
  9273. readonly skybox: Nullable<Mesh>;
  9274. private _skyboxTexture;
  9275. /**
  9276. * Gets the skybox texture created by the helper.
  9277. */
  9278. readonly skyboxTexture: Nullable<BaseTexture>;
  9279. private _skyboxMaterial;
  9280. /**
  9281. * Gets the skybox material created by the helper.
  9282. */
  9283. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  9284. private _ground;
  9285. /**
  9286. * Gets the ground mesh created by the helper.
  9287. */
  9288. readonly ground: Nullable<Mesh>;
  9289. private _groundTexture;
  9290. /**
  9291. * Gets the ground texture created by the helper.
  9292. */
  9293. readonly groundTexture: Nullable<BaseTexture>;
  9294. private _groundMirror;
  9295. /**
  9296. * Gets the ground mirror created by the helper.
  9297. */
  9298. readonly groundMirror: Nullable<MirrorTexture>;
  9299. /**
  9300. * Gets the ground mirror render list to helps pushing the meshes
  9301. * you wish in the ground reflection.
  9302. */
  9303. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  9304. private _groundMaterial;
  9305. /**
  9306. * Gets the ground material created by the helper.
  9307. */
  9308. readonly groundMaterial: Nullable<BackgroundMaterial>;
  9309. /**
  9310. * Stores the creation options.
  9311. */
  9312. private readonly _scene;
  9313. private _options;
  9314. /**
  9315. * This observable will be notified with any error during the creation of the environment,
  9316. * mainly texture creation errors.
  9317. */
  9318. onErrorObservable: Observable<{
  9319. message?: string;
  9320. exception?: any;
  9321. }>;
  9322. /**
  9323. * constructor
  9324. * @param options
  9325. * @param scene The scene to add the material to
  9326. */
  9327. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  9328. /**
  9329. * Updates the background according to the new options
  9330. * @param options
  9331. */
  9332. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  9333. /**
  9334. * Sets the primary color of all the available elements.
  9335. * @param color the main color to affect to the ground and the background
  9336. */
  9337. setMainColor(color: Color3): void;
  9338. /**
  9339. * Setup the image processing according to the specified options.
  9340. */
  9341. private _setupImageProcessing();
  9342. /**
  9343. * Setup the environment texture according to the specified options.
  9344. */
  9345. private _setupEnvironmentTexture();
  9346. /**
  9347. * Setup the background according to the specified options.
  9348. */
  9349. private _setupBackground();
  9350. /**
  9351. * Get the scene sizes according to the setup.
  9352. */
  9353. private _getSceneSize();
  9354. /**
  9355. * Setup the ground according to the specified options.
  9356. */
  9357. private _setupGround(sceneSize);
  9358. /**
  9359. * Setup the ground material according to the specified options.
  9360. */
  9361. private _setupGroundMaterial();
  9362. /**
  9363. * Setup the ground diffuse texture according to the specified options.
  9364. */
  9365. private _setupGroundDiffuseTexture();
  9366. /**
  9367. * Setup the ground mirror texture according to the specified options.
  9368. */
  9369. private _setupGroundMirrorTexture(sceneSize);
  9370. /**
  9371. * Setup the ground to receive the mirror texture.
  9372. */
  9373. private _setupMirrorInGroundMaterial();
  9374. /**
  9375. * Setup the skybox according to the specified options.
  9376. */
  9377. private _setupSkybox(sceneSize);
  9378. /**
  9379. * Setup the skybox material according to the specified options.
  9380. */
  9381. private _setupSkyboxMaterial();
  9382. /**
  9383. * Setup the skybox reflection texture according to the specified options.
  9384. */
  9385. private _setupSkyboxReflectionTexture();
  9386. private _errorHandler;
  9387. /**
  9388. * Dispose all the elements created by the Helper.
  9389. */
  9390. dispose(): void;
  9391. }
  9392. }
  9393. declare module BABYLON {
  9394. /**
  9395. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  9396. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  9397. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  9398. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  9399. */
  9400. class VideoDome extends Node {
  9401. /**
  9402. * The video texture being displayed on the sphere
  9403. */
  9404. protected _videoTexture: VideoTexture;
  9405. /**
  9406. * The skybox material
  9407. */
  9408. protected _material: BackgroundMaterial;
  9409. /**
  9410. * The surface used for the skybox
  9411. */
  9412. protected _mesh: Mesh;
  9413. /**
  9414. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  9415. * Also see the options.resolution property.
  9416. */
  9417. fovMultiplier: number;
  9418. /**
  9419. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  9420. * @param name Element's name, child elements will append suffixes for their own names.
  9421. * @param urlsOrVideo
  9422. * @param options An object containing optional or exposed sub element properties:
  9423. * @param options **resolution=12** Integer, lower resolutions have more artifacts at extreme fovs
  9424. * @param options **clickToPlay=false** Add a click to play listener to the video, does not prevent autoplay.
  9425. * @param options **autoPlay=true** Automatically attempt to being playing the video.
  9426. * @param options **loop=true** Automatically loop video on end.
  9427. * @param options **size=1000** Physical radius to create the dome at, defaults to approximately half the far clip plane.
  9428. */
  9429. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  9430. resolution?: number;
  9431. clickToPlay?: boolean;
  9432. autoPlay?: boolean;
  9433. loop?: boolean;
  9434. size?: number;
  9435. }, scene: Scene);
  9436. /**
  9437. * Releases resources associated with this node.
  9438. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9439. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9440. */
  9441. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9442. }
  9443. }
  9444. declare module BABYLON {
  9445. class StickValues {
  9446. x: number;
  9447. y: number;
  9448. constructor(x: number, y: number);
  9449. }
  9450. interface GamepadButtonChanges {
  9451. changed: boolean;
  9452. pressChanged: boolean;
  9453. touchChanged: boolean;
  9454. valueChanged: boolean;
  9455. }
  9456. class Gamepad {
  9457. id: string;
  9458. index: number;
  9459. browserGamepad: any;
  9460. type: number;
  9461. private _leftStick;
  9462. private _rightStick;
  9463. _isConnected: boolean;
  9464. private _leftStickAxisX;
  9465. private _leftStickAxisY;
  9466. private _rightStickAxisX;
  9467. private _rightStickAxisY;
  9468. private _onleftstickchanged;
  9469. private _onrightstickchanged;
  9470. static GAMEPAD: number;
  9471. static GENERIC: number;
  9472. static XBOX: number;
  9473. static POSE_ENABLED: number;
  9474. protected _invertLeftStickY: boolean;
  9475. readonly isConnected: boolean;
  9476. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9477. onleftstickchanged(callback: (values: StickValues) => void): void;
  9478. onrightstickchanged(callback: (values: StickValues) => void): void;
  9479. leftStick: StickValues;
  9480. rightStick: StickValues;
  9481. update(): void;
  9482. dispose(): void;
  9483. }
  9484. class GenericPad extends Gamepad {
  9485. private _buttons;
  9486. private _onbuttondown;
  9487. private _onbuttonup;
  9488. onButtonDownObservable: Observable<number>;
  9489. onButtonUpObservable: Observable<number>;
  9490. onbuttondown(callback: (buttonPressed: number) => void): void;
  9491. onbuttonup(callback: (buttonReleased: number) => void): void;
  9492. constructor(id: string, index: number, browserGamepad: any);
  9493. private _setButtonValue(newValue, currentValue, buttonIndex);
  9494. update(): void;
  9495. dispose(): void;
  9496. }
  9497. }
  9498. declare module BABYLON {
  9499. class GamepadManager {
  9500. private _scene;
  9501. private _babylonGamepads;
  9502. private _oneGamepadConnected;
  9503. _isMonitoring: boolean;
  9504. private _gamepadEventSupported;
  9505. private _gamepadSupport;
  9506. onGamepadConnectedObservable: Observable<Gamepad>;
  9507. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9508. private _onGamepadConnectedEvent;
  9509. private _onGamepadDisconnectedEvent;
  9510. constructor(_scene?: Scene | undefined);
  9511. readonly gamepads: Gamepad[];
  9512. getGamepadByType(type?: number): Nullable<Gamepad>;
  9513. dispose(): void;
  9514. private _addNewGamepad(gamepad);
  9515. private _startMonitoringGamepads();
  9516. private _stopMonitoringGamepads();
  9517. _checkGamepadsStatus(): void;
  9518. private _updateGamepadObjects();
  9519. }
  9520. }
  9521. declare module BABYLON {
  9522. /**
  9523. * Defines supported buttons for XBox360 compatible gamepads
  9524. */
  9525. enum Xbox360Button {
  9526. /** A */
  9527. A = 0,
  9528. /** B */
  9529. B = 1,
  9530. /** X */
  9531. X = 2,
  9532. /** Y */
  9533. Y = 3,
  9534. /** Start */
  9535. Start = 4,
  9536. /** Back */
  9537. Back = 5,
  9538. /** Left button */
  9539. LB = 6,
  9540. /** Right button */
  9541. RB = 7,
  9542. /** Left stick */
  9543. LeftStick = 8,
  9544. /** Right stick */
  9545. RightStick = 9,
  9546. }
  9547. /** Defines values for XBox360 DPad */
  9548. enum Xbox360Dpad {
  9549. /** Up */
  9550. Up = 0,
  9551. /** Down */
  9552. Down = 1,
  9553. /** Left */
  9554. Left = 2,
  9555. /** Right */
  9556. Right = 3,
  9557. }
  9558. /**
  9559. * Defines a XBox360 gamepad
  9560. */
  9561. class Xbox360Pad extends Gamepad {
  9562. private _leftTrigger;
  9563. private _rightTrigger;
  9564. private _onlefttriggerchanged;
  9565. private _onrighttriggerchanged;
  9566. private _onbuttondown;
  9567. private _onbuttonup;
  9568. private _ondpaddown;
  9569. private _ondpadup;
  9570. /** Observable raised when a button is pressed */
  9571. onButtonDownObservable: Observable<Xbox360Button>;
  9572. /** Observable raised when a button is released */
  9573. onButtonUpObservable: Observable<Xbox360Button>;
  9574. /** Observable raised when a pad is pressed */
  9575. onPadDownObservable: Observable<Xbox360Dpad>;
  9576. /** Observable raised when a pad is released */
  9577. onPadUpObservable: Observable<Xbox360Dpad>;
  9578. private _buttonA;
  9579. private _buttonB;
  9580. private _buttonX;
  9581. private _buttonY;
  9582. private _buttonBack;
  9583. private _buttonStart;
  9584. private _buttonLB;
  9585. private _buttonRB;
  9586. private _buttonLeftStick;
  9587. private _buttonRightStick;
  9588. private _dPadUp;
  9589. private _dPadDown;
  9590. private _dPadLeft;
  9591. private _dPadRight;
  9592. private _isXboxOnePad;
  9593. /**
  9594. * Creates a new XBox360 gamepad object
  9595. * @param id defines the id of this gamepad
  9596. * @param index defines its index
  9597. * @param gamepad defines the internal HTML gamepad object
  9598. * @param xboxOne defines if it is a XBox One gamepad
  9599. */
  9600. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9601. /**
  9602. * Defines the callback to call when left trigger is pressed
  9603. * @param callback defines the callback to use
  9604. */
  9605. onlefttriggerchanged(callback: (value: number) => void): void;
  9606. /**
  9607. * Defines the callback to call when right trigger is pressed
  9608. * @param callback defines the callback to use
  9609. */
  9610. onrighttriggerchanged(callback: (value: number) => void): void;
  9611. /**
  9612. * Gets or sets left trigger value
  9613. */
  9614. leftTrigger: number;
  9615. /**
  9616. * Gets or sets right trigger value
  9617. */
  9618. rightTrigger: number;
  9619. /**
  9620. * Defines the callback to call when a button is pressed
  9621. * @param callback defines the callback to use
  9622. */
  9623. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9624. /**
  9625. * Defines the callback to call when a button is released
  9626. * @param callback defines the callback to use
  9627. */
  9628. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9629. /**
  9630. * Defines the callback to call when a pad is pressed
  9631. * @param callback defines the callback to use
  9632. */
  9633. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9634. /**
  9635. * Defines the callback to call when a pad is released
  9636. * @param callback defines the callback to use
  9637. */
  9638. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9639. private _setButtonValue(newValue, currentValue, buttonType);
  9640. private _setDPadValue(newValue, currentValue, buttonType);
  9641. /** Gets or sets value of A button */
  9642. buttonA: number;
  9643. /** Gets or sets value of B button */
  9644. buttonB: number;
  9645. /** Gets or sets value of X button */
  9646. buttonX: number;
  9647. /** Gets or sets value of Y button */
  9648. buttonY: number;
  9649. /** Gets or sets value of Start button */
  9650. buttonStart: number;
  9651. /** Gets or sets value of Back button */
  9652. buttonBack: number;
  9653. /** Gets or sets value of Left button */
  9654. buttonLB: number;
  9655. /** Gets or sets value of Right button */
  9656. buttonRB: number;
  9657. /** Gets or sets value of left stick */
  9658. buttonLeftStick: number;
  9659. /** Gets or sets value of right stick */
  9660. buttonRightStick: number;
  9661. /** Gets or sets value of DPad up */
  9662. dPadUp: number;
  9663. /** Gets or sets value of DPad down */
  9664. dPadDown: number;
  9665. /** Gets or sets value of DPad left */
  9666. dPadLeft: number;
  9667. /** Gets or sets value of DPad right */
  9668. dPadRight: number;
  9669. /**
  9670. * Force the gamepad to synchronize with device values
  9671. */
  9672. update(): void;
  9673. dispose(): void;
  9674. }
  9675. }
  9676. declare module BABYLON {
  9677. /**
  9678. * This class can be used to get instrumentation data from a Babylon engine
  9679. */
  9680. class EngineInstrumentation implements IDisposable {
  9681. engine: Engine;
  9682. private _captureGPUFrameTime;
  9683. private _gpuFrameTimeToken;
  9684. private _gpuFrameTime;
  9685. private _captureShaderCompilationTime;
  9686. private _shaderCompilationTime;
  9687. private _onBeginFrameObserver;
  9688. private _onEndFrameObserver;
  9689. private _onBeforeShaderCompilationObserver;
  9690. private _onAfterShaderCompilationObserver;
  9691. /**
  9692. * Gets the perf counter used for GPU frame time
  9693. */
  9694. readonly gpuFrameTimeCounter: PerfCounter;
  9695. /**
  9696. * Gets the GPU frame time capture status
  9697. */
  9698. /**
  9699. * Enable or disable the GPU frame time capture
  9700. */
  9701. captureGPUFrameTime: boolean;
  9702. /**
  9703. * Gets the perf counter used for shader compilation time
  9704. */
  9705. readonly shaderCompilationTimeCounter: PerfCounter;
  9706. /**
  9707. * Gets the shader compilation time capture status
  9708. */
  9709. /**
  9710. * Enable or disable the shader compilation time capture
  9711. */
  9712. captureShaderCompilationTime: boolean;
  9713. constructor(engine: Engine);
  9714. dispose(): void;
  9715. }
  9716. }
  9717. declare module BABYLON {
  9718. /**
  9719. * This class can be used to get instrumentation data from a Babylon engine
  9720. */
  9721. class SceneInstrumentation implements IDisposable {
  9722. scene: Scene;
  9723. private _captureActiveMeshesEvaluationTime;
  9724. private _activeMeshesEvaluationTime;
  9725. private _captureRenderTargetsRenderTime;
  9726. private _renderTargetsRenderTime;
  9727. private _captureFrameTime;
  9728. private _frameTime;
  9729. private _captureRenderTime;
  9730. private _renderTime;
  9731. private _captureInterFrameTime;
  9732. private _interFrameTime;
  9733. private _captureParticlesRenderTime;
  9734. private _particlesRenderTime;
  9735. private _captureSpritesRenderTime;
  9736. private _spritesRenderTime;
  9737. private _capturePhysicsTime;
  9738. private _physicsTime;
  9739. private _captureAnimationsTime;
  9740. private _animationsTime;
  9741. private _onBeforeActiveMeshesEvaluationObserver;
  9742. private _onAfterActiveMeshesEvaluationObserver;
  9743. private _onBeforeRenderTargetsRenderObserver;
  9744. private _onAfterRenderTargetsRenderObserver;
  9745. private _onAfterRenderObserver;
  9746. private _onBeforeDrawPhaseObserver;
  9747. private _onAfterDrawPhaseObserver;
  9748. private _onBeforeAnimationsObserver;
  9749. private _onBeforeParticlesRenderingObserver;
  9750. private _onAfterParticlesRenderingObserver;
  9751. private _onBeforeSpritesRenderingObserver;
  9752. private _onAfterSpritesRenderingObserver;
  9753. private _onBeforePhysicsObserver;
  9754. private _onAfterPhysicsObserver;
  9755. private _onAfterAnimationsObserver;
  9756. /**
  9757. * Gets the perf counter used for active meshes evaluation time
  9758. */
  9759. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  9760. /**
  9761. * Gets the active meshes evaluation time capture status
  9762. */
  9763. /**
  9764. * Enable or disable the active meshes evaluation time capture
  9765. */
  9766. captureActiveMeshesEvaluationTime: boolean;
  9767. /**
  9768. * Gets the perf counter used for render targets render time
  9769. */
  9770. readonly renderTargetsRenderTimeCounter: PerfCounter;
  9771. /**
  9772. * Gets the render targets render time capture status
  9773. */
  9774. /**
  9775. * Enable or disable the render targets render time capture
  9776. */
  9777. captureRenderTargetsRenderTime: boolean;
  9778. /**
  9779. * Gets the perf counter used for particles render time
  9780. */
  9781. readonly particlesRenderTimeCounter: PerfCounter;
  9782. /**
  9783. * Gets the particles render time capture status
  9784. */
  9785. /**
  9786. * Enable or disable the particles render time capture
  9787. */
  9788. captureParticlesRenderTime: boolean;
  9789. /**
  9790. * Gets the perf counter used for sprites render time
  9791. */
  9792. readonly spritesRenderTimeCounter: PerfCounter;
  9793. /**
  9794. * Gets the sprites render time capture status
  9795. */
  9796. /**
  9797. * Enable or disable the sprites render time capture
  9798. */
  9799. captureSpritesRenderTime: boolean;
  9800. /**
  9801. * Gets the perf counter used for physics time
  9802. */
  9803. readonly physicsTimeCounter: PerfCounter;
  9804. /**
  9805. * Gets the physics time capture status
  9806. */
  9807. /**
  9808. * Enable or disable the physics time capture
  9809. */
  9810. capturePhysicsTime: boolean;
  9811. /**
  9812. * Gets the perf counter used for animations time
  9813. */
  9814. readonly animationsTimeCounter: PerfCounter;
  9815. /**
  9816. * Gets the animations time capture status
  9817. */
  9818. /**
  9819. * Enable or disable the animations time capture
  9820. */
  9821. captureAnimationsTime: boolean;
  9822. /**
  9823. * Gets the perf counter used for frame time capture
  9824. */
  9825. readonly frameTimeCounter: PerfCounter;
  9826. /**
  9827. * Gets the frame time capture status
  9828. */
  9829. /**
  9830. * Enable or disable the frame time capture
  9831. */
  9832. captureFrameTime: boolean;
  9833. /**
  9834. * Gets the perf counter used for inter-frames time capture
  9835. */
  9836. readonly interFrameTimeCounter: PerfCounter;
  9837. /**
  9838. * Gets the inter-frames time capture status
  9839. */
  9840. /**
  9841. * Enable or disable the inter-frames time capture
  9842. */
  9843. captureInterFrameTime: boolean;
  9844. /**
  9845. * Gets the perf counter used for render time capture
  9846. */
  9847. readonly renderTimeCounter: PerfCounter;
  9848. /**
  9849. * Gets the render time capture status
  9850. */
  9851. /**
  9852. * Enable or disable the render time capture
  9853. */
  9854. captureRenderTime: boolean;
  9855. /**
  9856. * Gets the perf counter used for draw calls
  9857. */
  9858. readonly drawCallsCounter: PerfCounter;
  9859. /**
  9860. * Gets the perf counter used for texture collisions
  9861. */
  9862. readonly textureCollisionsCounter: PerfCounter;
  9863. constructor(scene: Scene);
  9864. dispose(): void;
  9865. }
  9866. }
  9867. declare module BABYLON {
  9868. /**
  9869. * @hidden
  9870. **/
  9871. class _TimeToken {
  9872. _startTimeQuery: Nullable<WebGLQuery>;
  9873. _endTimeQuery: Nullable<WebGLQuery>;
  9874. _timeElapsedQuery: Nullable<WebGLQuery>;
  9875. _timeElapsedQueryEnded: boolean;
  9876. }
  9877. }
  9878. declare module BABYLON {
  9879. class LensFlare {
  9880. size: number;
  9881. position: number;
  9882. color: Color3;
  9883. texture: Nullable<Texture>;
  9884. alphaMode: number;
  9885. private _system;
  9886. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  9887. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  9888. dispose(): void;
  9889. }
  9890. }
  9891. declare module BABYLON {
  9892. class LensFlareSystem {
  9893. name: string;
  9894. lensFlares: LensFlare[];
  9895. borderLimit: number;
  9896. viewportBorder: number;
  9897. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  9898. layerMask: number;
  9899. id: string;
  9900. private _scene;
  9901. private _emitter;
  9902. private _vertexBuffers;
  9903. private _indexBuffer;
  9904. private _effect;
  9905. private _positionX;
  9906. private _positionY;
  9907. private _isEnabled;
  9908. constructor(name: string, emitter: any, scene: Scene);
  9909. isEnabled: boolean;
  9910. getScene(): Scene;
  9911. getEmitter(): any;
  9912. setEmitter(newEmitter: any): void;
  9913. getEmitterPosition(): Vector3;
  9914. computeEffectivePosition(globalViewport: Viewport): boolean;
  9915. _isVisible(): boolean;
  9916. render(): boolean;
  9917. dispose(): void;
  9918. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  9919. serialize(): any;
  9920. }
  9921. }
  9922. declare module BABYLON {
  9923. interface ILoadingScreen {
  9924. displayLoadingUI: () => void;
  9925. hideLoadingUI: () => void;
  9926. loadingUIBackgroundColor: string;
  9927. loadingUIText: string;
  9928. }
  9929. class DefaultLoadingScreen implements ILoadingScreen {
  9930. private _renderingCanvas;
  9931. private _loadingText;
  9932. private _loadingDivBackgroundColor;
  9933. private _loadingDiv;
  9934. private _loadingTextDiv;
  9935. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  9936. displayLoadingUI(): void;
  9937. hideLoadingUI(): void;
  9938. loadingUIText: string;
  9939. loadingUIBackgroundColor: string;
  9940. private _resizeLoadingUI;
  9941. }
  9942. }
  9943. declare module BABYLON {
  9944. class SceneLoaderProgressEvent {
  9945. readonly lengthComputable: boolean;
  9946. readonly loaded: number;
  9947. readonly total: number;
  9948. constructor(lengthComputable: boolean, loaded: number, total: number);
  9949. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  9950. }
  9951. interface ISceneLoaderPluginExtensions {
  9952. [extension: string]: {
  9953. isBinary: boolean;
  9954. };
  9955. }
  9956. interface ISceneLoaderPluginFactory {
  9957. name: string;
  9958. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  9959. canDirectLoad?: (data: string) => boolean;
  9960. }
  9961. interface ISceneLoaderPlugin {
  9962. /**
  9963. * The friendly name of this plugin.
  9964. */
  9965. name: string;
  9966. /**
  9967. * The file extensions supported by this plugin.
  9968. */
  9969. extensions: string | ISceneLoaderPluginExtensions;
  9970. /**
  9971. * Import meshes into a scene.
  9972. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  9973. * @param scene The scene to import into
  9974. * @param data The data to import
  9975. * @param rootUrl The root url for scene and resources
  9976. * @param meshes The meshes array to import into
  9977. * @param particleSystems The particle systems array to import into
  9978. * @param skeletons The skeletons array to import into
  9979. * @param onError The callback when import fails
  9980. * @returns True if successful or false otherwise
  9981. */
  9982. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  9983. /**
  9984. * Load into a scene.
  9985. * @param scene The scene to load into
  9986. * @param data The data to import
  9987. * @param rootUrl The root url for scene and resources
  9988. * @param onError The callback when import fails
  9989. * @returns true if successful or false otherwise
  9990. */
  9991. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  9992. /**
  9993. * The callback that returns true if the data can be directly loaded.
  9994. */
  9995. canDirectLoad?: (data: string) => boolean;
  9996. /**
  9997. * The callback that allows custom handling of the root url based on the response url.
  9998. */
  9999. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  10000. /**
  10001. * Load into an asset container.
  10002. * @param scene The scene to load into
  10003. * @param data The data to import
  10004. * @param rootUrl The root url for scene and resources
  10005. * @param onError The callback when import fails
  10006. * @returns The loaded asset container
  10007. */
  10008. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  10009. }
  10010. interface ISceneLoaderPluginAsync {
  10011. /**
  10012. * The friendly name of this plugin.
  10013. */
  10014. name: string;
  10015. /**
  10016. * The file extensions supported by this plugin.
  10017. */
  10018. extensions: string | ISceneLoaderPluginExtensions;
  10019. /**
  10020. * Import meshes into a scene.
  10021. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  10022. * @param scene The scene to import into
  10023. * @param data The data to import
  10024. * @param rootUrl The root url for scene and resources
  10025. * @param onProgress The callback when the load progresses
  10026. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  10027. */
  10028. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  10029. meshes: AbstractMesh[];
  10030. particleSystems: ParticleSystem[];
  10031. skeletons: Skeleton[];
  10032. animationGroups: AnimationGroup[];
  10033. }>;
  10034. /**
  10035. * Load into a scene.
  10036. * @param scene The scene to load into
  10037. * @param data The data to import
  10038. * @param rootUrl The root url for scene and resources
  10039. * @param onProgress The callback when the load progresses
  10040. * @returns Nothing
  10041. */
  10042. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  10043. /**
  10044. * The callback that returns true if the data can be directly loaded.
  10045. */
  10046. canDirectLoad?: (data: string) => boolean;
  10047. /**
  10048. * The callback that allows custom handling of the root url based on the response url.
  10049. */
  10050. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  10051. /**
  10052. * Load into an asset container.
  10053. * @param scene The scene to load into
  10054. * @param data The data to import
  10055. * @param rootUrl The root url for scene and resources
  10056. * @param onProgress The callback when the load progresses
  10057. * @returns The loaded asset container
  10058. */
  10059. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  10060. }
  10061. class SceneLoader {
  10062. private static _ForceFullSceneLoadingForIncremental;
  10063. private static _ShowLoadingScreen;
  10064. private static _CleanBoneMatrixWeights;
  10065. static readonly NO_LOGGING: number;
  10066. static readonly MINIMAL_LOGGING: number;
  10067. static readonly SUMMARY_LOGGING: number;
  10068. static readonly DETAILED_LOGGING: number;
  10069. private static _loggingLevel;
  10070. static ForceFullSceneLoadingForIncremental: boolean;
  10071. static ShowLoadingScreen: boolean;
  10072. static loggingLevel: number;
  10073. static CleanBoneMatrixWeights: boolean;
  10074. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  10075. private static _registeredPlugins;
  10076. private static _getDefaultPlugin();
  10077. private static _getPluginForExtension(extension);
  10078. private static _getPluginForDirectLoad(data);
  10079. private static _getPluginForFilename(sceneFilename);
  10080. private static _getDirectLoad(sceneFilename);
  10081. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  10082. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  10083. static IsPluginForExtensionAvailable(extension: string): boolean;
  10084. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  10085. /**
  10086. * Import meshes into a scene
  10087. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  10088. * @param rootUrl a string that defines the root url for scene and resources
  10089. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  10090. * @param scene the instance of BABYLON.Scene to append to
  10091. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  10092. * @param onProgress a callback with a progress event for each file being loaded
  10093. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  10094. * @param pluginExtension the extension used to determine the plugin
  10095. * @returns The loaded plugin
  10096. */
  10097. 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>;
  10098. /**
  10099. * Import meshes into a scene
  10100. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  10101. * @param rootUrl a string that defines the root url for scene and resources
  10102. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  10103. * @param scene the instance of BABYLON.Scene to append to
  10104. * @param onProgress a callback with a progress event for each file being loaded
  10105. * @param pluginExtension the extension used to determine the plugin
  10106. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  10107. */
  10108. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  10109. meshes: AbstractMesh[];
  10110. particleSystems: ParticleSystem[];
  10111. skeletons: Skeleton[];
  10112. animationGroups: AnimationGroup[];
  10113. }>;
  10114. /**
  10115. * Load a scene
  10116. * @param rootUrl a string that defines the root url for scene and resources
  10117. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  10118. * @param engine is the instance of BABYLON.Engine to use to create the scene
  10119. * @param onSuccess a callback with the scene when import succeeds
  10120. * @param onProgress a callback with a progress event for each file being loaded
  10121. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  10122. * @param pluginExtension the extension used to determine the plugin
  10123. * @returns The loaded plugin
  10124. */
  10125. 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>;
  10126. /**
  10127. * Load a scene
  10128. * @param rootUrl a string that defines the root url for scene and resources
  10129. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  10130. * @param engine is the instance of BABYLON.Engine to use to create the scene
  10131. * @param onProgress a callback with a progress event for each file being loaded
  10132. * @param pluginExtension the extension used to determine the plugin
  10133. * @returns The loaded scene
  10134. */
  10135. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  10136. /**
  10137. * Append a scene
  10138. * @param rootUrl a string that defines the root url for scene and resources
  10139. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  10140. * @param scene is the instance of BABYLON.Scene to append to
  10141. * @param onSuccess a callback with the scene when import succeeds
  10142. * @param onProgress a callback with a progress event for each file being loaded
  10143. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  10144. * @param pluginExtension the extension used to determine the plugin
  10145. * @returns The loaded plugin
  10146. */
  10147. 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>;
  10148. /**
  10149. * Append a scene
  10150. * @param rootUrl a string that defines the root url for scene and resources
  10151. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  10152. * @param scene is the instance of BABYLON.Scene to append to
  10153. * @param onProgress a callback with a progress event for each file being loaded
  10154. * @param pluginExtension the extension used to determine the plugin
  10155. * @returns The given scene
  10156. */
  10157. static AppendAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  10158. /**
  10159. * Load a scene into an asset container
  10160. * @param rootUrl a string that defines the root url for scene and resources
  10161. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  10162. * @param scene is the instance of BABYLON.Scene to append to
  10163. * @param onSuccess a callback with the scene when import succeeds
  10164. * @param onProgress a callback with a progress event for each file being loaded
  10165. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  10166. * @param pluginExtension the extension used to determine the plugin
  10167. * @returns The loaded plugin
  10168. */
  10169. 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>;
  10170. /**
  10171. * Load a scene into an asset container
  10172. * @param rootUrl a string that defines the root url for scene and resources
  10173. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  10174. * @param scene is the instance of BABYLON.Scene to append to
  10175. * @param onProgress a callback with a progress event for each file being loaded
  10176. * @param pluginExtension the extension used to determine the plugin
  10177. * @returns The loaded asset container
  10178. */
  10179. static LoadAssetContainerAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  10180. }
  10181. }
  10182. declare module BABYLON {
  10183. /**
  10184. * A directional light is defined by a direction (what a surprise!).
  10185. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  10186. * 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.
  10187. * Documentation: https://doc.babylonjs.com/babylon101/lights
  10188. */
  10189. class DirectionalLight extends ShadowLight {
  10190. private _shadowFrustumSize;
  10191. /**
  10192. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  10193. */
  10194. /**
  10195. * Specifies a fix frustum size for the shadow generation.
  10196. */
  10197. shadowFrustumSize: number;
  10198. private _shadowOrthoScale;
  10199. /**
  10200. * Gets the shadow projection scale against the optimal computed one.
  10201. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  10202. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  10203. */
  10204. /**
  10205. * Sets the shadow projection scale against the optimal computed one.
  10206. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  10207. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  10208. */
  10209. shadowOrthoScale: number;
  10210. /**
  10211. * Automatically compute the projection matrix to best fit (including all the casters)
  10212. * on each frame.
  10213. */
  10214. autoUpdateExtends: boolean;
  10215. private _orthoLeft;
  10216. private _orthoRight;
  10217. private _orthoTop;
  10218. private _orthoBottom;
  10219. /**
  10220. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  10221. * The directional light is emitted from everywhere in the given direction.
  10222. * It can cast shawdows.
  10223. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10224. * @param name The friendly name of the light
  10225. * @param direction The direction of the light
  10226. * @param scene The scene the light belongs to
  10227. */
  10228. constructor(name: string, direction: Vector3, scene: Scene);
  10229. /**
  10230. * Returns the string "DirectionalLight".
  10231. * @return The class name
  10232. */
  10233. getClassName(): string;
  10234. /**
  10235. * Returns the integer 1.
  10236. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10237. */
  10238. getTypeID(): number;
  10239. /**
  10240. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  10241. * Returns the DirectionalLight Shadow projection matrix.
  10242. */
  10243. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10244. /**
  10245. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  10246. * Returns the DirectionalLight Shadow projection matrix.
  10247. */
  10248. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  10249. /**
  10250. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  10251. * Returns the DirectionalLight Shadow projection matrix.
  10252. */
  10253. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10254. protected _buildUniformLayout(): void;
  10255. /**
  10256. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  10257. * @param effect The effect to update
  10258. * @param lightIndex The index of the light in the effect to update
  10259. * @returns The directional light
  10260. */
  10261. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  10262. /**
  10263. * Gets the minZ used for shadow according to both the scene and the light.
  10264. *
  10265. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  10266. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  10267. * @param activeCamera The camera we are returning the min for
  10268. * @returns the depth min z
  10269. */
  10270. getDepthMinZ(activeCamera: Camera): number;
  10271. /**
  10272. * Gets the maxZ used for shadow according to both the scene and the light.
  10273. *
  10274. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  10275. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  10276. * @param activeCamera The camera we are returning the max for
  10277. * @returns the depth max z
  10278. */
  10279. getDepthMaxZ(activeCamera: Camera): number;
  10280. }
  10281. }
  10282. declare module BABYLON {
  10283. /**
  10284. * The HemisphericLight simulates the ambient environment light,
  10285. * so the passed direction is the light reflection direction, not the incoming direction.
  10286. */
  10287. class HemisphericLight extends Light {
  10288. /**
  10289. * The groundColor is the light in the opposite direction to the one specified during creation.
  10290. * 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.
  10291. */
  10292. groundColor: Color3;
  10293. /**
  10294. * The light reflection direction, not the incoming direction.
  10295. */
  10296. direction: Vector3;
  10297. private _worldMatrix;
  10298. /**
  10299. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  10300. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  10301. * The HemisphericLight can't cast shadows.
  10302. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10303. * @param name The friendly name of the light
  10304. * @param direction The direction of the light reflection
  10305. * @param scene The scene the light belongs to
  10306. */
  10307. constructor(name: string, direction: Vector3, scene: Scene);
  10308. protected _buildUniformLayout(): void;
  10309. /**
  10310. * Returns the string "HemisphericLight".
  10311. * @return The class name
  10312. */
  10313. getClassName(): string;
  10314. /**
  10315. * Sets the HemisphericLight direction towards the passed target (Vector3).
  10316. * Returns the updated direction.
  10317. * @param target The target the direction should point to
  10318. * @return The computed direction
  10319. */
  10320. setDirectionToTarget(target: Vector3): Vector3;
  10321. /**
  10322. * Returns the shadow generator associated to the light.
  10323. * @returns Always null for hemispheric lights because it does not support shadows.
  10324. */
  10325. getShadowGenerator(): Nullable<ShadowGenerator>;
  10326. /**
  10327. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  10328. * @param effect The effect to update
  10329. * @param lightIndex The index of the light in the effect to update
  10330. * @returns The hemispheric light
  10331. */
  10332. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  10333. /**
  10334. * @hidden internal use only.
  10335. */
  10336. _getWorldMatrix(): Matrix;
  10337. /**
  10338. * Returns the integer 3.
  10339. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10340. */
  10341. getTypeID(): number;
  10342. }
  10343. }
  10344. declare module BABYLON {
  10345. /**
  10346. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10347. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10348. * 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.
  10349. */
  10350. abstract class Light extends Node {
  10351. private static _LIGHTMAP_DEFAULT;
  10352. private static _LIGHTMAP_SPECULAR;
  10353. private static _LIGHTMAP_SHADOWSONLY;
  10354. /**
  10355. * If every light affecting the material is in this lightmapMode,
  10356. * material.lightmapTexture adds or multiplies
  10357. * (depends on material.useLightmapAsShadowmap)
  10358. * after every other light calculations.
  10359. */
  10360. static readonly LIGHTMAP_DEFAULT: number;
  10361. /**
  10362. * material.lightmapTexture as only diffuse lighting from this light
  10363. * adds only specular lighting from this light
  10364. * adds dynamic shadows
  10365. */
  10366. static readonly LIGHTMAP_SPECULAR: number;
  10367. /**
  10368. * material.lightmapTexture as only lighting
  10369. * no light calculation from this light
  10370. * only adds dynamic shadows from this light
  10371. */
  10372. static readonly LIGHTMAP_SHADOWSONLY: number;
  10373. private static _INTENSITYMODE_AUTOMATIC;
  10374. private static _INTENSITYMODE_LUMINOUSPOWER;
  10375. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  10376. private static _INTENSITYMODE_ILLUMINANCE;
  10377. private static _INTENSITYMODE_LUMINANCE;
  10378. /**
  10379. * Each light type uses the default quantity according to its type:
  10380. * point/spot lights use luminous intensity
  10381. * directional lights use illuminance
  10382. */
  10383. static readonly INTENSITYMODE_AUTOMATIC: number;
  10384. /**
  10385. * lumen (lm)
  10386. */
  10387. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10388. /**
  10389. * candela (lm/sr)
  10390. */
  10391. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10392. /**
  10393. * lux (lm/m^2)
  10394. */
  10395. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10396. /**
  10397. * nit (cd/m^2)
  10398. */
  10399. static readonly INTENSITYMODE_LUMINANCE: number;
  10400. private static _LIGHTTYPEID_POINTLIGHT;
  10401. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  10402. private static _LIGHTTYPEID_SPOTLIGHT;
  10403. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  10404. /**
  10405. * Light type const id of the point light.
  10406. */
  10407. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10408. /**
  10409. * Light type const id of the directional light.
  10410. */
  10411. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10412. /**
  10413. * Light type const id of the spot light.
  10414. */
  10415. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10416. /**
  10417. * Light type const id of the hemispheric light.
  10418. */
  10419. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10420. /**
  10421. * Diffuse gives the basic color to an object.
  10422. */
  10423. diffuse: Color3;
  10424. /**
  10425. * Specular produces a highlight color on an object.
  10426. * Note: This is note affecting PBR materials.
  10427. */
  10428. specular: Color3;
  10429. /**
  10430. * Strength of the light.
  10431. * Note: By default it is define in the framework own unit.
  10432. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10433. */
  10434. intensity: number;
  10435. /**
  10436. * Defines how far from the source the light is impacting in scene units.
  10437. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10438. */
  10439. range: number;
  10440. /**
  10441. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10442. * of light.
  10443. */
  10444. private _photometricScale;
  10445. private _intensityMode;
  10446. /**
  10447. * Gets the photometric scale used to interpret the intensity.
  10448. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10449. */
  10450. /**
  10451. * Sets the photometric scale used to interpret the intensity.
  10452. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10453. */
  10454. intensityMode: number;
  10455. private _radius;
  10456. /**
  10457. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10458. */
  10459. /**
  10460. * sets the light radius used by PBR Materials to simulate soft area lights.
  10461. */
  10462. radius: number;
  10463. private _renderPriority;
  10464. /**
  10465. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10466. * exceeding the number allowed of the materials.
  10467. */
  10468. renderPriority: number;
  10469. private _shadowEnabled;
  10470. /**
  10471. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10472. * the current shadow generator.
  10473. */
  10474. /**
  10475. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10476. * the current shadow generator.
  10477. */
  10478. shadowEnabled: boolean;
  10479. private _includedOnlyMeshes;
  10480. /**
  10481. * Gets the only meshes impacted by this light.
  10482. */
  10483. /**
  10484. * Sets the only meshes impacted by this light.
  10485. */
  10486. includedOnlyMeshes: AbstractMesh[];
  10487. private _excludedMeshes;
  10488. /**
  10489. * Gets the meshes not impacted by this light.
  10490. */
  10491. /**
  10492. * Sets the meshes not impacted by this light.
  10493. */
  10494. excludedMeshes: AbstractMesh[];
  10495. private _excludeWithLayerMask;
  10496. /**
  10497. * Gets the layer id use to find what meshes are not impacted by the light.
  10498. * Inactive if 0
  10499. */
  10500. /**
  10501. * Sets the layer id use to find what meshes are not impacted by the light.
  10502. * Inactive if 0
  10503. */
  10504. excludeWithLayerMask: number;
  10505. private _includeOnlyWithLayerMask;
  10506. /**
  10507. * Gets the layer id use to find what meshes are impacted by the light.
  10508. * Inactive if 0
  10509. */
  10510. /**
  10511. * Sets the layer id use to find what meshes are impacted by the light.
  10512. * Inactive if 0
  10513. */
  10514. includeOnlyWithLayerMask: number;
  10515. private _lightmapMode;
  10516. /**
  10517. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10518. */
  10519. /**
  10520. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10521. */
  10522. lightmapMode: number;
  10523. private _parentedWorldMatrix;
  10524. /**
  10525. * Shadow generator associted to the light.
  10526. * Internal use only.
  10527. */
  10528. _shadowGenerator: Nullable<IShadowGenerator>;
  10529. /**
  10530. * @hidden Internal use only.
  10531. */
  10532. _excludedMeshesIds: string[];
  10533. /**
  10534. * @hidden Internal use only.
  10535. */
  10536. _includedOnlyMeshesIds: string[];
  10537. /**
  10538. * The current light unifom buffer.
  10539. * @hidden Internal use only.
  10540. */
  10541. _uniformBuffer: UniformBuffer;
  10542. /**
  10543. * Creates a Light object in the scene.
  10544. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10545. * @param name The firendly name of the light
  10546. * @param scene The scene the light belongs too
  10547. */
  10548. constructor(name: string, scene: Scene);
  10549. protected abstract _buildUniformLayout(): void;
  10550. /**
  10551. * Sets the passed Effect "effect" with the Light information.
  10552. * @param effect The effect to update
  10553. * @param lightIndex The index of the light in the effect to update
  10554. * @returns The light
  10555. */
  10556. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10557. /**
  10558. * @hidden internal use only.
  10559. */
  10560. abstract _getWorldMatrix(): Matrix;
  10561. /**
  10562. * Returns the string "Light".
  10563. * @returns the class name
  10564. */
  10565. getClassName(): string;
  10566. /**
  10567. * Converts the light information to a readable string for debug purpose.
  10568. * @param fullDetails Supports for multiple levels of logging within scene loading
  10569. * @returns the human readable light info
  10570. */
  10571. toString(fullDetails?: boolean): string;
  10572. /**
  10573. * Set the enabled state of this node.
  10574. * @param value - the new enabled state
  10575. */
  10576. setEnabled(value: boolean): void;
  10577. /**
  10578. * Returns the Light associated shadow generator if any.
  10579. * @return the associated shadow generator.
  10580. */
  10581. getShadowGenerator(): Nullable<IShadowGenerator>;
  10582. /**
  10583. * Returns a Vector3, the absolute light position in the World.
  10584. * @returns the world space position of the light
  10585. */
  10586. getAbsolutePosition(): Vector3;
  10587. /**
  10588. * Specifies if the light will affect the passed mesh.
  10589. * @param mesh The mesh to test against the light
  10590. * @return true the mesh is affected otherwise, false.
  10591. */
  10592. canAffectMesh(mesh: AbstractMesh): boolean;
  10593. /**
  10594. * Computes and Returns the light World matrix.
  10595. * @returns the world matrix
  10596. */
  10597. getWorldMatrix(): Matrix;
  10598. /**
  10599. * Sort function to order lights for rendering.
  10600. * @param a First Light object to compare to second.
  10601. * @param b Second Light object to compare first.
  10602. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10603. */
  10604. static CompareLightsPriority(a: Light, b: Light): number;
  10605. /**
  10606. * Releases resources associated with this node.
  10607. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10608. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10609. */
  10610. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10611. /**
  10612. * Returns the light type ID (integer).
  10613. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10614. */
  10615. getTypeID(): number;
  10616. /**
  10617. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10618. * @returns the scaled intensity in intensity mode unit
  10619. */
  10620. getScaledIntensity(): number;
  10621. /**
  10622. * Returns a new Light object, named "name", from the current one.
  10623. * @param name The name of the cloned light
  10624. * @returns the new created light
  10625. */
  10626. clone(name: string): Nullable<Light>;
  10627. /**
  10628. * Serializes the current light into a Serialization object.
  10629. * @returns the serialized object.
  10630. */
  10631. serialize(): any;
  10632. /**
  10633. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10634. * This new light is named "name" and added to the passed scene.
  10635. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10636. * @param name The friendly name of the light
  10637. * @param scene The scene the new light will belong to
  10638. * @returns the constructor function
  10639. */
  10640. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10641. /**
  10642. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10643. * @param parsedLight The JSON representation of the light
  10644. * @param scene The scene to create the parsed light in
  10645. * @returns the created light after parsing
  10646. */
  10647. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10648. private _hookArrayForExcluded(array);
  10649. private _hookArrayForIncludedOnly(array);
  10650. private _resyncMeshes();
  10651. /**
  10652. * Forces the meshes to update their light related information in their rendering used effects
  10653. * @hidden Internal Use Only
  10654. */
  10655. _markMeshesAsLightDirty(): void;
  10656. /**
  10657. * Recomputes the cached photometric scale if needed.
  10658. */
  10659. private _computePhotometricScale();
  10660. /**
  10661. * Returns the Photometric Scale according to the light type and intensity mode.
  10662. */
  10663. private _getPhotometricScale();
  10664. /**
  10665. * Reorder the light in the scene according to their defined priority.
  10666. * @hidden Internal Use Only
  10667. */
  10668. _reorderLightsInScene(): void;
  10669. }
  10670. }
  10671. declare module BABYLON {
  10672. /**
  10673. * A point light is a light defined by an unique point in world space.
  10674. * The light is emitted in every direction from this point.
  10675. * A good example of a point light is a standard light bulb.
  10676. * Documentation: https://doc.babylonjs.com/babylon101/lights
  10677. */
  10678. class PointLight extends ShadowLight {
  10679. private _shadowAngle;
  10680. /**
  10681. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  10682. * This specifies what angle the shadow will use to be created.
  10683. *
  10684. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  10685. */
  10686. /**
  10687. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  10688. * This specifies what angle the shadow will use to be created.
  10689. *
  10690. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  10691. */
  10692. shadowAngle: number;
  10693. /**
  10694. * Gets the direction if it has been set.
  10695. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  10696. */
  10697. /**
  10698. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  10699. */
  10700. direction: Vector3;
  10701. /**
  10702. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  10703. * A PointLight emits the light in every direction.
  10704. * It can cast shadows.
  10705. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  10706. * ```javascript
  10707. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  10708. * ```
  10709. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10710. * @param name The light friendly name
  10711. * @param position The position of the point light in the scene
  10712. * @param scene The scene the lights belongs to
  10713. */
  10714. constructor(name: string, position: Vector3, scene: Scene);
  10715. /**
  10716. * Returns the string "PointLight"
  10717. * @returns the class name
  10718. */
  10719. getClassName(): string;
  10720. /**
  10721. * Returns the integer 0.
  10722. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10723. */
  10724. getTypeID(): number;
  10725. /**
  10726. * Specifies wether or not the shadowmap should be a cube texture.
  10727. * @returns true if the shadowmap needs to be a cube texture.
  10728. */
  10729. needCube(): boolean;
  10730. /**
  10731. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  10732. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10733. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10734. */
  10735. getShadowDirection(faceIndex?: number): Vector3;
  10736. /**
  10737. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  10738. * - fov = PI / 2
  10739. * - aspect ratio : 1.0
  10740. * - z-near and far equal to the active camera minZ and maxZ.
  10741. * Returns the PointLight.
  10742. */
  10743. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10744. protected _buildUniformLayout(): void;
  10745. /**
  10746. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  10747. * @param effect The effect to update
  10748. * @param lightIndex The index of the light in the effect to update
  10749. * @returns The point light
  10750. */
  10751. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  10752. }
  10753. }
  10754. declare module BABYLON {
  10755. /**
  10756. * Interface describing all the common properties and methods a shadow light needs to implement.
  10757. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10758. * as well as binding the different shadow properties to the effects.
  10759. */
  10760. interface IShadowLight extends Light {
  10761. /**
  10762. * The light id in the scene (used in scene.findLighById for instance)
  10763. */
  10764. id: string;
  10765. /**
  10766. * The position the shdow will be casted from.
  10767. */
  10768. position: Vector3;
  10769. /**
  10770. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10771. */
  10772. direction: Vector3;
  10773. /**
  10774. * The transformed position. Position of the light in world space taking parenting in account.
  10775. */
  10776. transformedPosition: Vector3;
  10777. /**
  10778. * The transformed direction. Direction of the light in world space taking parenting in account.
  10779. */
  10780. transformedDirection: Vector3;
  10781. /**
  10782. * The friendly name of the light in the scene.
  10783. */
  10784. name: string;
  10785. /**
  10786. * Defines the shadow projection clipping minimum z value.
  10787. */
  10788. shadowMinZ: number;
  10789. /**
  10790. * Defines the shadow projection clipping maximum z value.
  10791. */
  10792. shadowMaxZ: number;
  10793. /**
  10794. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10795. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10796. */
  10797. computeTransformedInformation(): boolean;
  10798. /**
  10799. * Gets the scene the light belongs to.
  10800. * @returns The scene
  10801. */
  10802. getScene(): Scene;
  10803. /**
  10804. * Callback defining a custom Projection Matrix Builder.
  10805. * This can be used to override the default projection matrix computation.
  10806. */
  10807. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10808. /**
  10809. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10810. * @param matrix The materix to updated with the projection information
  10811. * @param viewMatrix The transform matrix of the light
  10812. * @param renderList The list of mesh to render in the map
  10813. * @returns The current light
  10814. */
  10815. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10816. /**
  10817. * Gets the current depth scale used in ESM.
  10818. * @returns The scale
  10819. */
  10820. getDepthScale(): number;
  10821. /**
  10822. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10823. * @returns true if a cube texture needs to be use
  10824. */
  10825. needCube(): boolean;
  10826. /**
  10827. * Detects if the projection matrix requires to be recomputed this frame.
  10828. * @returns true if it requires to be recomputed otherwise, false.
  10829. */
  10830. needProjectionMatrixCompute(): boolean;
  10831. /**
  10832. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10833. */
  10834. forceProjectionMatrixCompute(): void;
  10835. /**
  10836. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10837. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10838. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10839. */
  10840. getShadowDirection(faceIndex?: number): Vector3;
  10841. /**
  10842. * Gets the minZ used for shadow according to both the scene and the light.
  10843. * @param activeCamera The camera we are returning the min for
  10844. * @returns the depth min z
  10845. */
  10846. getDepthMinZ(activeCamera: Camera): number;
  10847. /**
  10848. * Gets the maxZ used for shadow according to both the scene and the light.
  10849. * @param activeCamera The camera we are returning the max for
  10850. * @returns the depth max z
  10851. */
  10852. getDepthMaxZ(activeCamera: Camera): number;
  10853. }
  10854. /**
  10855. * Base implementation IShadowLight
  10856. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10857. */
  10858. abstract class ShadowLight extends Light implements IShadowLight {
  10859. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10860. protected _position: Vector3;
  10861. protected _setPosition(value: Vector3): void;
  10862. /**
  10863. * Sets the position the shadow will be casted from. Also use as the light position for both
  10864. * point and spot lights.
  10865. */
  10866. /**
  10867. * Sets the position the shadow will be casted from. Also use as the light position for both
  10868. * point and spot lights.
  10869. */
  10870. position: Vector3;
  10871. protected _direction: Vector3;
  10872. protected _setDirection(value: Vector3): void;
  10873. /**
  10874. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10875. * Also use as the light direction on spot and directional lights.
  10876. */
  10877. /**
  10878. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10879. * Also use as the light direction on spot and directional lights.
  10880. */
  10881. direction: Vector3;
  10882. private _shadowMinZ;
  10883. /**
  10884. * Gets the shadow projection clipping minimum z value.
  10885. */
  10886. /**
  10887. * Sets the shadow projection clipping minimum z value.
  10888. */
  10889. shadowMinZ: number;
  10890. private _shadowMaxZ;
  10891. /**
  10892. * Sets the shadow projection clipping maximum z value.
  10893. */
  10894. /**
  10895. * Gets the shadow projection clipping maximum z value.
  10896. */
  10897. shadowMaxZ: number;
  10898. /**
  10899. * Callback defining a custom Projection Matrix Builder.
  10900. * This can be used to override the default projection matrix computation.
  10901. */
  10902. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10903. /**
  10904. * The transformed position. Position of the light in world space taking parenting in account.
  10905. */
  10906. transformedPosition: Vector3;
  10907. /**
  10908. * The transformed direction. Direction of the light in world space taking parenting in account.
  10909. */
  10910. transformedDirection: Vector3;
  10911. private _worldMatrix;
  10912. private _needProjectionMatrixCompute;
  10913. /**
  10914. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10915. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10916. */
  10917. computeTransformedInformation(): boolean;
  10918. /**
  10919. * Return the depth scale used for the shadow map.
  10920. * @returns the depth scale.
  10921. */
  10922. getDepthScale(): number;
  10923. /**
  10924. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10925. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10926. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10927. */
  10928. getShadowDirection(faceIndex?: number): Vector3;
  10929. /**
  10930. * Returns the ShadowLight absolute position in the World.
  10931. * @returns the position vector in world space
  10932. */
  10933. getAbsolutePosition(): Vector3;
  10934. /**
  10935. * Sets the ShadowLight direction toward the passed target.
  10936. * @param target The point tot target in local space
  10937. * @returns the updated ShadowLight direction
  10938. */
  10939. setDirectionToTarget(target: Vector3): Vector3;
  10940. /**
  10941. * Returns the light rotation in euler definition.
  10942. * @returns the x y z rotation in local space.
  10943. */
  10944. getRotation(): Vector3;
  10945. /**
  10946. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10947. * @returns true if a cube texture needs to be use
  10948. */
  10949. needCube(): boolean;
  10950. /**
  10951. * Detects if the projection matrix requires to be recomputed this frame.
  10952. * @returns true if it requires to be recomputed otherwise, false.
  10953. */
  10954. needProjectionMatrixCompute(): boolean;
  10955. /**
  10956. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10957. */
  10958. forceProjectionMatrixCompute(): void;
  10959. /**
  10960. * Get the world matrix of the sahdow lights.
  10961. * @hidden Internal Use Only
  10962. */
  10963. _getWorldMatrix(): Matrix;
  10964. /**
  10965. * Gets the minZ used for shadow according to both the scene and the light.
  10966. * @param activeCamera The camera we are returning the min for
  10967. * @returns the depth min z
  10968. */
  10969. getDepthMinZ(activeCamera: Camera): number;
  10970. /**
  10971. * Gets the maxZ used for shadow according to both the scene and the light.
  10972. * @param activeCamera The camera we are returning the max for
  10973. * @returns the depth max z
  10974. */
  10975. getDepthMaxZ(activeCamera: Camera): number;
  10976. /**
  10977. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10978. * @param matrix The materix to updated with the projection information
  10979. * @param viewMatrix The transform matrix of the light
  10980. * @param renderList The list of mesh to render in the map
  10981. * @returns The current light
  10982. */
  10983. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10984. }
  10985. }
  10986. declare module BABYLON {
  10987. /**
  10988. * A spot light is defined by a position, a direction, an angle, and an exponent.
  10989. * These values define a cone of light starting from the position, emitting toward the direction.
  10990. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  10991. * and the exponent defines the speed of the decay of the light with distance (reach).
  10992. * Documentation: https://doc.babylonjs.com/babylon101/lights
  10993. */
  10994. class SpotLight extends ShadowLight {
  10995. private _angle;
  10996. /**
  10997. * Gets the cone angle of the spot light in Radians.
  10998. */
  10999. /**
  11000. * Sets the cone angle of the spot light in Radians.
  11001. */
  11002. angle: number;
  11003. private _shadowAngleScale;
  11004. /**
  11005. * Allows scaling the angle of the light for shadow generation only.
  11006. */
  11007. /**
  11008. * Allows scaling the angle of the light for shadow generation only.
  11009. */
  11010. shadowAngleScale: number;
  11011. /**
  11012. * The light decay speed with the distance from the emission spot.
  11013. */
  11014. exponent: number;
  11015. private _projectionTextureMatrix;
  11016. /**
  11017. * Allows reading the projecton texture
  11018. */
  11019. readonly projectionTextureMatrix: Matrix;
  11020. protected _projectionTextureLightNear: number;
  11021. /**
  11022. * Gets the near clip of the Spotlight for texture projection.
  11023. */
  11024. /**
  11025. * Sets the near clip of the Spotlight for texture projection.
  11026. */
  11027. projectionTextureLightNear: number;
  11028. protected _projectionTextureLightFar: number;
  11029. /**
  11030. * Gets the far clip of the Spotlight for texture projection.
  11031. */
  11032. /**
  11033. * Sets the far clip of the Spotlight for texture projection.
  11034. */
  11035. projectionTextureLightFar: number;
  11036. protected _projectionTextureUpDirection: Vector3;
  11037. /**
  11038. * Gets the Up vector of the Spotlight for texture projection.
  11039. */
  11040. /**
  11041. * Sets the Up vector of the Spotlight for texture projection.
  11042. */
  11043. projectionTextureUpDirection: Vector3;
  11044. private _projectionTexture;
  11045. /**
  11046. * Gets the projection texture of the light.
  11047. */
  11048. /**
  11049. * Sets the projection texture of the light.
  11050. */
  11051. projectionTexture: Nullable<BaseTexture>;
  11052. private _projectionTextureViewLightDirty;
  11053. private _projectionTextureProjectionLightDirty;
  11054. private _projectionTextureDirty;
  11055. private _projectionTextureViewTargetVector;
  11056. private _projectionTextureViewLightMatrix;
  11057. private _projectionTextureProjectionLightMatrix;
  11058. private _projectionTextureScalingMatrix;
  11059. /**
  11060. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  11061. * It can cast shadows.
  11062. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11063. * @param name The light friendly name
  11064. * @param position The position of the spot light in the scene
  11065. * @param direction The direction of the light in the scene
  11066. * @param angle The cone angle of the light in Radians
  11067. * @param exponent The light decay speed with the distance from the emission spot
  11068. * @param scene The scene the lights belongs to
  11069. */
  11070. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  11071. /**
  11072. * Returns the string "SpotLight".
  11073. * @returns the class name
  11074. */
  11075. getClassName(): string;
  11076. /**
  11077. * Returns the integer 2.
  11078. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11079. */
  11080. getTypeID(): number;
  11081. /**
  11082. * Overrides the direction setter to recompute the projection texture view light Matrix.
  11083. */
  11084. protected _setDirection(value: Vector3): void;
  11085. /**
  11086. * Overrides the position setter to recompute the projection texture view light Matrix.
  11087. */
  11088. protected _setPosition(value: Vector3): void;
  11089. /**
  11090. * 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.
  11091. * Returns the SpotLight.
  11092. */
  11093. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11094. protected _computeProjectionTextureViewLightMatrix(): void;
  11095. protected _computeProjectionTextureProjectionLightMatrix(): void;
  11096. /**
  11097. * Main function for light texture projection matrix computing.
  11098. */
  11099. protected _computeProjectionTextureMatrix(): void;
  11100. protected _buildUniformLayout(): void;
  11101. /**
  11102. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  11103. * @param effect The effect to update
  11104. * @param lightIndex The index of the light in the effect to update
  11105. * @returns The spot light
  11106. */
  11107. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  11108. /**
  11109. * Disposes the light and the associated resources.
  11110. */
  11111. dispose(): void;
  11112. }
  11113. }
  11114. declare module BABYLON {
  11115. /**
  11116. * Effect layer options. This helps customizing the behaviour
  11117. * of the effect layer.
  11118. */
  11119. interface IEffectLayerOptions {
  11120. /**
  11121. * Multiplication factor apply to the canvas size to compute the render target size
  11122. * used to generated the objects (the smaller the faster).
  11123. */
  11124. mainTextureRatio: number;
  11125. /**
  11126. * Enforces a fixed size texture to ensure effect stability across devices.
  11127. */
  11128. mainTextureFixedSize?: number;
  11129. /**
  11130. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  11131. */
  11132. alphaBlendingMode: number;
  11133. /**
  11134. * The camera attached to the layer.
  11135. */
  11136. camera: Nullable<Camera>;
  11137. }
  11138. /**
  11139. * The effect layer Helps adding post process effect blended with the main pass.
  11140. *
  11141. * This can be for instance use to generate glow or higlight effects on the scene.
  11142. *
  11143. * The effect layer class can not be used directly and is intented to inherited from to be
  11144. * customized per effects.
  11145. */
  11146. abstract class EffectLayer {
  11147. private _vertexBuffers;
  11148. private _indexBuffer;
  11149. private _cachedDefines;
  11150. private _effectLayerMapGenerationEffect;
  11151. private _effectLayerOptions;
  11152. private _mergeEffect;
  11153. protected _scene: Scene;
  11154. protected _engine: Engine;
  11155. protected _maxSize: number;
  11156. protected _mainTextureDesiredSize: ISize;
  11157. protected _mainTexture: RenderTargetTexture;
  11158. protected _shouldRender: boolean;
  11159. protected _postProcesses: PostProcess[];
  11160. protected _textures: BaseTexture[];
  11161. protected _emissiveTextureAndColor: {
  11162. texture: Nullable<BaseTexture>;
  11163. color: Color4;
  11164. };
  11165. /**
  11166. * The name of the layer
  11167. */
  11168. name: string;
  11169. /**
  11170. * The clear color of the texture used to generate the glow map.
  11171. */
  11172. neutralColor: Color4;
  11173. /**
  11174. * Specifies wether the highlight layer is enabled or not.
  11175. */
  11176. isEnabled: boolean;
  11177. /**
  11178. * Gets the camera attached to the layer.
  11179. */
  11180. readonly camera: Nullable<Camera>;
  11181. /**
  11182. * An event triggered when the effect layer has been disposed.
  11183. */
  11184. onDisposeObservable: Observable<EffectLayer>;
  11185. /**
  11186. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  11187. */
  11188. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  11189. /**
  11190. * An event triggered when the generated texture is being merged in the scene.
  11191. */
  11192. onBeforeComposeObservable: Observable<EffectLayer>;
  11193. /**
  11194. * An event triggered when the generated texture has been merged in the scene.
  11195. */
  11196. onAfterComposeObservable: Observable<EffectLayer>;
  11197. /**
  11198. * An event triggered when the efffect layer changes its size.
  11199. */
  11200. onSizeChangedObservable: Observable<EffectLayer>;
  11201. /**
  11202. * Instantiates a new effect Layer and references it in the scene.
  11203. * @param name The name of the layer
  11204. * @param scene The scene to use the layer in
  11205. */
  11206. constructor(
  11207. /** The Friendly of the effect in the scene */
  11208. name: string, scene: Scene);
  11209. /**
  11210. * Get the effect name of the layer.
  11211. * @return The effect name
  11212. */
  11213. abstract getEffectName(): string;
  11214. /**
  11215. * Checks for the readiness of the element composing the layer.
  11216. * @param subMesh the mesh to check for
  11217. * @param useInstances specify wether or not to use instances to render the mesh
  11218. * @return true if ready otherwise, false
  11219. */
  11220. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11221. /**
  11222. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11223. * @returns true if the effect requires stencil during the main canvas render pass.
  11224. */
  11225. abstract needStencil(): boolean;
  11226. /**
  11227. * Create the merge effect. This is the shader use to blit the information back
  11228. * to the main canvas at the end of the scene rendering.
  11229. * @returns The effect containing the shader used to merge the effect on the main canvas
  11230. */
  11231. protected abstract _createMergeEffect(): Effect;
  11232. /**
  11233. * Creates the render target textures and post processes used in the effect layer.
  11234. */
  11235. protected abstract _createTextureAndPostProcesses(): void;
  11236. /**
  11237. * Implementation specific of rendering the generating effect on the main canvas.
  11238. * @param effect The effect used to render through
  11239. */
  11240. protected abstract _internalRender(effect: Effect): void;
  11241. /**
  11242. * Sets the required values for both the emissive texture and and the main color.
  11243. */
  11244. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11245. /**
  11246. * Free any resources and references associated to a mesh.
  11247. * Internal use
  11248. * @param mesh The mesh to free.
  11249. */
  11250. abstract _disposeMesh(mesh: Mesh): void;
  11251. /**
  11252. * Serializes this layer (Glow or Highlight for example)
  11253. * @returns a serialized layer object
  11254. */
  11255. abstract serialize?(): any;
  11256. /**
  11257. * Initializes the effect layer with the required options.
  11258. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  11259. */
  11260. protected _init(options: Partial<IEffectLayerOptions>): void;
  11261. /**
  11262. * Generates the index buffer of the full screen quad blending to the main canvas.
  11263. */
  11264. private _generateIndexBuffer();
  11265. /**
  11266. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  11267. */
  11268. private _genrateVertexBuffer();
  11269. /**
  11270. * Sets the main texture desired size which is the closest power of two
  11271. * of the engine canvas size.
  11272. */
  11273. private _setMainTextureSize();
  11274. /**
  11275. * Creates the main texture for the effect layer.
  11276. */
  11277. protected _createMainTexture(): void;
  11278. /**
  11279. * Checks for the readiness of the element composing the layer.
  11280. * @param subMesh the mesh to check for
  11281. * @param useInstances specify wether or not to use instances to render the mesh
  11282. * @param emissiveTexture the associated emissive texture used to generate the glow
  11283. * @return true if ready otherwise, false
  11284. */
  11285. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  11286. /**
  11287. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  11288. */
  11289. render(): void;
  11290. /**
  11291. * Determine if a given mesh will be used in the current effect.
  11292. * @param mesh mesh to test
  11293. * @returns true if the mesh will be used
  11294. */
  11295. hasMesh(mesh: AbstractMesh): boolean;
  11296. /**
  11297. * Returns true if the layer contains information to display, otherwise false.
  11298. * @returns true if the glow layer should be rendered
  11299. */
  11300. shouldRender(): boolean;
  11301. /**
  11302. * Returns true if the mesh should render, otherwise false.
  11303. * @param mesh The mesh to render
  11304. * @returns true if it should render otherwise false
  11305. */
  11306. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11307. /**
  11308. * Returns true if the mesh should render, otherwise false.
  11309. * @param mesh The mesh to render
  11310. * @returns true if it should render otherwise false
  11311. */
  11312. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  11313. /**
  11314. * Renders the submesh passed in parameter to the generation map.
  11315. */
  11316. protected _renderSubMesh(subMesh: SubMesh): void;
  11317. /**
  11318. * Rebuild the required buffers.
  11319. * @hidden Internal use only.
  11320. */
  11321. _rebuild(): void;
  11322. /**
  11323. * Dispose only the render target textures and post process.
  11324. */
  11325. private _disposeTextureAndPostProcesses();
  11326. /**
  11327. * Dispose the highlight layer and free resources.
  11328. */
  11329. dispose(): void;
  11330. /**
  11331. * Gets the class name of the effect layer
  11332. * @returns the string with the class name of the effect layer
  11333. */
  11334. getClassName(): string;
  11335. /**
  11336. * Creates an effect layer from parsed effect layer data
  11337. * @param parsedEffectLayer defines effect layer data
  11338. * @param scene defines the current scene
  11339. * @param rootUrl defines the root URL containing the effect layer information
  11340. * @returns a parsed effect Layer
  11341. */
  11342. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  11343. }
  11344. }
  11345. declare module BABYLON {
  11346. /**
  11347. * Glow layer options. This helps customizing the behaviour
  11348. * of the glow layer.
  11349. */
  11350. interface IGlowLayerOptions {
  11351. /**
  11352. * Multiplication factor apply to the canvas size to compute the render target size
  11353. * used to generated the glowing objects (the smaller the faster).
  11354. */
  11355. mainTextureRatio: number;
  11356. /**
  11357. * Enforces a fixed size texture to ensure resize independant blur.
  11358. */
  11359. mainTextureFixedSize?: number;
  11360. /**
  11361. * How big is the kernel of the blur texture.
  11362. */
  11363. blurKernelSize: number;
  11364. /**
  11365. * The camera attached to the layer.
  11366. */
  11367. camera: Nullable<Camera>;
  11368. /**
  11369. * Enable MSAA by chosing the number of samples.
  11370. */
  11371. mainTextureSamples?: number;
  11372. }
  11373. /**
  11374. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  11375. *
  11376. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11377. * glowy meshes to your scene.
  11378. *
  11379. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  11380. */
  11381. class GlowLayer extends EffectLayer {
  11382. /**
  11383. * Effect Name of the layer.
  11384. */
  11385. static readonly EffectName: string;
  11386. /**
  11387. * The default blur kernel size used for the glow.
  11388. */
  11389. static DefaultBlurKernelSize: number;
  11390. /**
  11391. * The default texture size ratio used for the glow.
  11392. */
  11393. static DefaultTextureRatio: number;
  11394. /**
  11395. * Gets the kernel size of the blur.
  11396. */
  11397. /**
  11398. * Sets the kernel size of the blur.
  11399. */
  11400. blurKernelSize: number;
  11401. /**
  11402. * Gets the glow intensity.
  11403. */
  11404. /**
  11405. * Sets the glow intensity.
  11406. */
  11407. intensity: number;
  11408. private _options;
  11409. private _intensity;
  11410. private _horizontalBlurPostprocess1;
  11411. private _verticalBlurPostprocess1;
  11412. private _horizontalBlurPostprocess2;
  11413. private _verticalBlurPostprocess2;
  11414. private _blurTexture1;
  11415. private _blurTexture2;
  11416. private _postProcesses1;
  11417. private _postProcesses2;
  11418. private _includedOnlyMeshes;
  11419. private _excludedMeshes;
  11420. /**
  11421. * Callback used to let the user override the color selection on a per mesh basis
  11422. */
  11423. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  11424. /**
  11425. * Callback used to let the user override the texture selection on a per mesh basis
  11426. */
  11427. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  11428. /**
  11429. * Instantiates a new glow Layer and references it to the scene.
  11430. * @param name The name of the layer
  11431. * @param scene The scene to use the layer in
  11432. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  11433. */
  11434. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  11435. /**
  11436. * Get the effect name of the layer.
  11437. * @return The effect name
  11438. */
  11439. getEffectName(): string;
  11440. /**
  11441. * Create the merge effect. This is the shader use to blit the information back
  11442. * to the main canvas at the end of the scene rendering.
  11443. */
  11444. protected _createMergeEffect(): Effect;
  11445. /**
  11446. * Creates the render target textures and post processes used in the glow layer.
  11447. */
  11448. protected _createTextureAndPostProcesses(): void;
  11449. /**
  11450. * Checks for the readiness of the element composing the layer.
  11451. * @param subMesh the mesh to check for
  11452. * @param useInstances specify wether or not to use instances to render the mesh
  11453. * @param emissiveTexture the associated emissive texture used to generate the glow
  11454. * @return true if ready otherwise, false
  11455. */
  11456. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11457. /**
  11458. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11459. */
  11460. needStencil(): boolean;
  11461. /**
  11462. * Implementation specific of rendering the generating effect on the main canvas.
  11463. * @param effect The effect used to render through
  11464. */
  11465. protected _internalRender(effect: Effect): void;
  11466. /**
  11467. * Sets the required values for both the emissive texture and and the main color.
  11468. */
  11469. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11470. /**
  11471. * Returns true if the mesh should render, otherwise false.
  11472. * @param mesh The mesh to render
  11473. * @returns true if it should render otherwise false
  11474. */
  11475. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11476. /**
  11477. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  11478. * @param mesh The mesh to exclude from the glow layer
  11479. */
  11480. addExcludedMesh(mesh: Mesh): void;
  11481. /**
  11482. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  11483. * @param mesh The mesh to remove
  11484. */
  11485. removeExcludedMesh(mesh: Mesh): void;
  11486. /**
  11487. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  11488. * @param mesh The mesh to include in the glow layer
  11489. */
  11490. addIncludedOnlyMesh(mesh: Mesh): void;
  11491. /**
  11492. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  11493. * @param mesh The mesh to remove
  11494. */
  11495. removeIncludedOnlyMesh(mesh: Mesh): void;
  11496. /**
  11497. * Determine if a given mesh will be used in the glow layer
  11498. * @param mesh The mesh to test
  11499. * @returns true if the mesh will be highlighted by the current glow layer
  11500. */
  11501. hasMesh(mesh: AbstractMesh): boolean;
  11502. /**
  11503. * Free any resources and references associated to a mesh.
  11504. * Internal use
  11505. * @param mesh The mesh to free.
  11506. */
  11507. _disposeMesh(mesh: Mesh): void;
  11508. /**
  11509. * Gets the class name of the effect layer
  11510. * @returns the string with the class name of the effect layer
  11511. */
  11512. getClassName(): string;
  11513. /**
  11514. * Serializes this glow layer
  11515. * @returns a serialized glow layer object
  11516. */
  11517. serialize(): any;
  11518. /**
  11519. * Creates a Glow Layer from parsed glow layer data
  11520. * @param parsedGlowLayer defines glow layer data
  11521. * @param scene defines the current scene
  11522. * @param rootUrl defines the root URL containing the glow layer information
  11523. * @returns a parsed Glow Layer
  11524. */
  11525. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  11526. }
  11527. }
  11528. declare module BABYLON {
  11529. /**
  11530. * Highlight layer options. This helps customizing the behaviour
  11531. * of the highlight layer.
  11532. */
  11533. interface IHighlightLayerOptions {
  11534. /**
  11535. * Multiplication factor apply to the canvas size to compute the render target size
  11536. * used to generated the glowing objects (the smaller the faster).
  11537. */
  11538. mainTextureRatio: number;
  11539. /**
  11540. * Enforces a fixed size texture to ensure resize independant blur.
  11541. */
  11542. mainTextureFixedSize?: number;
  11543. /**
  11544. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  11545. * of the picture to blur (the smaller the faster).
  11546. */
  11547. blurTextureSizeRatio: number;
  11548. /**
  11549. * How big in texel of the blur texture is the vertical blur.
  11550. */
  11551. blurVerticalSize: number;
  11552. /**
  11553. * How big in texel of the blur texture is the horizontal blur.
  11554. */
  11555. blurHorizontalSize: number;
  11556. /**
  11557. * Alpha blending mode used to apply the blur. Default is combine.
  11558. */
  11559. alphaBlendingMode: number;
  11560. /**
  11561. * The camera attached to the layer.
  11562. */
  11563. camera: Nullable<Camera>;
  11564. /**
  11565. * Should we display highlight as a solid stroke?
  11566. */
  11567. isStroke?: boolean;
  11568. }
  11569. /**
  11570. * The highlight layer Helps adding a glow effect around a mesh.
  11571. *
  11572. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  11573. * glowy meshes to your scene.
  11574. *
  11575. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  11576. */
  11577. class HighlightLayer extends EffectLayer {
  11578. name: string;
  11579. /**
  11580. * Effect Name of the highlight layer.
  11581. */
  11582. static readonly EffectName: string;
  11583. /**
  11584. * The neutral color used during the preparation of the glow effect.
  11585. * This is black by default as the blend operation is a blend operation.
  11586. */
  11587. static NeutralColor: Color4;
  11588. /**
  11589. * Stencil value used for glowing meshes.
  11590. */
  11591. static GlowingMeshStencilReference: number;
  11592. /**
  11593. * Stencil value used for the other meshes in the scene.
  11594. */
  11595. static NormalMeshStencilReference: number;
  11596. /**
  11597. * Specifies whether or not the inner glow is ACTIVE in the layer.
  11598. */
  11599. innerGlow: boolean;
  11600. /**
  11601. * Specifies whether or not the outer glow is ACTIVE in the layer.
  11602. */
  11603. outerGlow: boolean;
  11604. /**
  11605. * Gets the horizontal size of the blur.
  11606. */
  11607. /**
  11608. * Specifies the horizontal size of the blur.
  11609. */
  11610. blurHorizontalSize: number;
  11611. /**
  11612. * Gets the vertical size of the blur.
  11613. */
  11614. /**
  11615. * Specifies the vertical size of the blur.
  11616. */
  11617. blurVerticalSize: number;
  11618. /**
  11619. * An event triggered when the highlight layer is being blurred.
  11620. */
  11621. onBeforeBlurObservable: Observable<HighlightLayer>;
  11622. /**
  11623. * An event triggered when the highlight layer has been blurred.
  11624. */
  11625. onAfterBlurObservable: Observable<HighlightLayer>;
  11626. private _instanceGlowingMeshStencilReference;
  11627. private _options;
  11628. private _downSamplePostprocess;
  11629. private _horizontalBlurPostprocess;
  11630. private _verticalBlurPostprocess;
  11631. private _blurTexture;
  11632. private _meshes;
  11633. private _excludedMeshes;
  11634. /**
  11635. * Instantiates a new highlight Layer and references it to the scene..
  11636. * @param name The name of the layer
  11637. * @param scene The scene to use the layer in
  11638. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  11639. */
  11640. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  11641. /**
  11642. * Get the effect name of the layer.
  11643. * @return The effect name
  11644. */
  11645. getEffectName(): string;
  11646. /**
  11647. * Create the merge effect. This is the shader use to blit the information back
  11648. * to the main canvas at the end of the scene rendering.
  11649. */
  11650. protected _createMergeEffect(): Effect;
  11651. /**
  11652. * Creates the render target textures and post processes used in the highlight layer.
  11653. */
  11654. protected _createTextureAndPostProcesses(): void;
  11655. /**
  11656. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  11657. */
  11658. needStencil(): boolean;
  11659. /**
  11660. * Checks for the readiness of the element composing the layer.
  11661. * @param subMesh the mesh to check for
  11662. * @param useInstances specify wether or not to use instances to render the mesh
  11663. * @param emissiveTexture the associated emissive texture used to generate the glow
  11664. * @return true if ready otherwise, false
  11665. */
  11666. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11667. /**
  11668. * Implementation specific of rendering the generating effect on the main canvas.
  11669. * @param effect The effect used to render through
  11670. */
  11671. protected _internalRender(effect: Effect): void;
  11672. /**
  11673. * Returns true if the layer contains information to display, otherwise false.
  11674. */
  11675. shouldRender(): boolean;
  11676. /**
  11677. * Returns true if the mesh should render, otherwise false.
  11678. * @param mesh The mesh to render
  11679. * @returns true if it should render otherwise false
  11680. */
  11681. protected _shouldRenderMesh(mesh: Mesh): boolean;
  11682. /**
  11683. * Sets the required values for both the emissive texture and and the main color.
  11684. */
  11685. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  11686. /**
  11687. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  11688. * @param mesh The mesh to exclude from the highlight layer
  11689. */
  11690. addExcludedMesh(mesh: Mesh): void;
  11691. /**
  11692. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  11693. * @param mesh The mesh to highlight
  11694. */
  11695. removeExcludedMesh(mesh: Mesh): void;
  11696. /**
  11697. * Determine if a given mesh will be highlighted by the current HighlightLayer
  11698. * @param mesh mesh to test
  11699. * @returns true if the mesh will be highlighted by the current HighlightLayer
  11700. */
  11701. hasMesh(mesh: AbstractMesh): boolean;
  11702. /**
  11703. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  11704. * @param mesh The mesh to highlight
  11705. * @param color The color of the highlight
  11706. * @param glowEmissiveOnly Extract the glow from the emissive texture
  11707. */
  11708. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  11709. /**
  11710. * Remove a mesh from the highlight layer in order to make it stop glowing.
  11711. * @param mesh The mesh to highlight
  11712. */
  11713. removeMesh(mesh: Mesh): void;
  11714. /**
  11715. * Force the stencil to the normal expected value for none glowing parts
  11716. */
  11717. private _defaultStencilReference(mesh);
  11718. /**
  11719. * Free any resources and references associated to a mesh.
  11720. * Internal use
  11721. * @param mesh The mesh to free.
  11722. */
  11723. _disposeMesh(mesh: Mesh): void;
  11724. /**
  11725. * Dispose the highlight layer and free resources.
  11726. */
  11727. dispose(): void;
  11728. /**
  11729. * Gets the class name of the effect layer
  11730. * @returns the string with the class name of the effect layer
  11731. */
  11732. getClassName(): string;
  11733. /**
  11734. * Serializes this Highlight layer
  11735. * @returns a serialized Highlight layer object
  11736. */
  11737. serialize(): any;
  11738. /**
  11739. * Creates a Highlight layer from parsed Highlight layer data
  11740. * @param parsedHightlightLayer defines the Highlight layer data
  11741. * @param scene defines the current scene
  11742. * @param rootUrl defines the root URL containing the Highlight layer information
  11743. * @returns a parsed Highlight layer
  11744. */
  11745. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  11746. }
  11747. }
  11748. declare module BABYLON {
  11749. class Layer {
  11750. name: string;
  11751. texture: Nullable<Texture>;
  11752. isBackground: boolean;
  11753. color: Color4;
  11754. scale: Vector2;
  11755. offset: Vector2;
  11756. alphaBlendingMode: number;
  11757. alphaTest: boolean;
  11758. layerMask: number;
  11759. private _scene;
  11760. private _vertexBuffers;
  11761. private _indexBuffer;
  11762. private _effect;
  11763. private _alphaTestEffect;
  11764. /**
  11765. * An event triggered when the layer is disposed.
  11766. */
  11767. onDisposeObservable: Observable<Layer>;
  11768. private _onDisposeObserver;
  11769. onDispose: () => void;
  11770. /**
  11771. * An event triggered before rendering the scene
  11772. */
  11773. onBeforeRenderObservable: Observable<Layer>;
  11774. private _onBeforeRenderObserver;
  11775. onBeforeRender: () => void;
  11776. /**
  11777. * An event triggered after rendering the scene
  11778. */
  11779. onAfterRenderObservable: Observable<Layer>;
  11780. private _onAfterRenderObserver;
  11781. onAfterRender: () => void;
  11782. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  11783. private _createIndexBuffer();
  11784. _rebuild(): void;
  11785. render(): void;
  11786. dispose(): void;
  11787. }
  11788. }
  11789. declare module BABYLON {
  11790. /**
  11791. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11792. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11793. * 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;
  11794. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11795. */
  11796. class ColorCurves {
  11797. private _dirty;
  11798. private _tempColor;
  11799. private _globalCurve;
  11800. private _highlightsCurve;
  11801. private _midtonesCurve;
  11802. private _shadowsCurve;
  11803. private _positiveCurve;
  11804. private _negativeCurve;
  11805. private _globalHue;
  11806. private _globalDensity;
  11807. private _globalSaturation;
  11808. private _globalExposure;
  11809. /**
  11810. * Gets the global Hue value.
  11811. * 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).
  11812. */
  11813. /**
  11814. * Sets the global Hue value.
  11815. * 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).
  11816. */
  11817. globalHue: number;
  11818. /**
  11819. * Gets the global Density value.
  11820. * 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.
  11821. * Values less than zero provide a filter of opposite hue.
  11822. */
  11823. /**
  11824. * Sets the global Density value.
  11825. * 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.
  11826. * Values less than zero provide a filter of opposite hue.
  11827. */
  11828. globalDensity: number;
  11829. /**
  11830. * Gets the global Saturation value.
  11831. * 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.
  11832. */
  11833. /**
  11834. * Sets the global Saturation value.
  11835. * 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.
  11836. */
  11837. globalSaturation: number;
  11838. /**
  11839. * Gets the global Exposure value.
  11840. * 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.
  11841. */
  11842. /**
  11843. * Sets the global Exposure value.
  11844. * 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.
  11845. */
  11846. globalExposure: number;
  11847. private _highlightsHue;
  11848. private _highlightsDensity;
  11849. private _highlightsSaturation;
  11850. private _highlightsExposure;
  11851. /**
  11852. * Gets the highlights Hue value.
  11853. * 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).
  11854. */
  11855. /**
  11856. * Sets the highlights Hue value.
  11857. * 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).
  11858. */
  11859. highlightsHue: number;
  11860. /**
  11861. * Gets the highlights Density value.
  11862. * 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.
  11863. * Values less than zero provide a filter of opposite hue.
  11864. */
  11865. /**
  11866. * Sets the highlights Density value.
  11867. * 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.
  11868. * Values less than zero provide a filter of opposite hue.
  11869. */
  11870. highlightsDensity: number;
  11871. /**
  11872. * Gets the highlights Saturation value.
  11873. * 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.
  11874. */
  11875. /**
  11876. * Sets the highlights Saturation value.
  11877. * 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.
  11878. */
  11879. highlightsSaturation: number;
  11880. /**
  11881. * Gets the highlights Exposure value.
  11882. * 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.
  11883. */
  11884. /**
  11885. * Sets the highlights Exposure value.
  11886. * 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.
  11887. */
  11888. highlightsExposure: number;
  11889. private _midtonesHue;
  11890. private _midtonesDensity;
  11891. private _midtonesSaturation;
  11892. private _midtonesExposure;
  11893. /**
  11894. * Gets the midtones Hue value.
  11895. * 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).
  11896. */
  11897. /**
  11898. * Sets the midtones Hue value.
  11899. * 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).
  11900. */
  11901. midtonesHue: number;
  11902. /**
  11903. * Gets the midtones Density value.
  11904. * 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.
  11905. * Values less than zero provide a filter of opposite hue.
  11906. */
  11907. /**
  11908. * Sets the midtones Density value.
  11909. * 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.
  11910. * Values less than zero provide a filter of opposite hue.
  11911. */
  11912. midtonesDensity: number;
  11913. /**
  11914. * Gets the midtones Saturation value.
  11915. * 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.
  11916. */
  11917. /**
  11918. * Sets the midtones Saturation value.
  11919. * 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.
  11920. */
  11921. midtonesSaturation: number;
  11922. /**
  11923. * Gets the midtones Exposure value.
  11924. * 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.
  11925. */
  11926. /**
  11927. * Sets the midtones Exposure value.
  11928. * 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.
  11929. */
  11930. midtonesExposure: number;
  11931. private _shadowsHue;
  11932. private _shadowsDensity;
  11933. private _shadowsSaturation;
  11934. private _shadowsExposure;
  11935. /**
  11936. * Gets the shadows Hue value.
  11937. * 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).
  11938. */
  11939. /**
  11940. * Sets the shadows Hue value.
  11941. * 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).
  11942. */
  11943. shadowsHue: number;
  11944. /**
  11945. * Gets the shadows Density value.
  11946. * 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.
  11947. * Values less than zero provide a filter of opposite hue.
  11948. */
  11949. /**
  11950. * Sets the shadows Density value.
  11951. * 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.
  11952. * Values less than zero provide a filter of opposite hue.
  11953. */
  11954. shadowsDensity: number;
  11955. /**
  11956. * Gets the shadows Saturation value.
  11957. * 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.
  11958. */
  11959. /**
  11960. * Sets the shadows Saturation value.
  11961. * 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.
  11962. */
  11963. shadowsSaturation: number;
  11964. /**
  11965. * Gets the shadows Exposure value.
  11966. * 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.
  11967. */
  11968. /**
  11969. * Sets the shadows Exposure value.
  11970. * 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.
  11971. */
  11972. shadowsExposure: number;
  11973. getClassName(): string;
  11974. /**
  11975. * Binds the color curves to the shader.
  11976. * @param colorCurves The color curve to bind
  11977. * @param effect The effect to bind to
  11978. */
  11979. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11980. /**
  11981. * Prepare the list of uniforms associated with the ColorCurves effects.
  11982. * @param uniformsList The list of uniforms used in the effect
  11983. */
  11984. static PrepareUniforms(uniformsList: string[]): void;
  11985. /**
  11986. * Returns color grading data based on a hue, density, saturation and exposure value.
  11987. * @param filterHue The hue of the color filter.
  11988. * @param filterDensity The density of the color filter.
  11989. * @param saturation The saturation.
  11990. * @param exposure The exposure.
  11991. * @param result The result data container.
  11992. */
  11993. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  11994. /**
  11995. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11996. * @param value The input slider value in range [-100,100].
  11997. * @returns Adjusted value.
  11998. */
  11999. private static applyColorGradingSliderNonlinear(value);
  12000. /**
  12001. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  12002. * @param hue The hue (H) input.
  12003. * @param saturation The saturation (S) input.
  12004. * @param brightness The brightness (B) input.
  12005. * @result An RGBA color represented as Vector4.
  12006. */
  12007. private static fromHSBToRef(hue, saturation, brightness, result);
  12008. /**
  12009. * Returns a value clamped between min and max
  12010. * @param value The value to clamp
  12011. * @param min The minimum of value
  12012. * @param max The maximum of value
  12013. * @returns The clamped value.
  12014. */
  12015. private static clamp(value, min, max);
  12016. /**
  12017. * Clones the current color curve instance.
  12018. * @return The cloned curves
  12019. */
  12020. clone(): ColorCurves;
  12021. /**
  12022. * Serializes the current color curve instance to a json representation.
  12023. * @return a JSON representation
  12024. */
  12025. serialize(): any;
  12026. /**
  12027. * Parses the color curve from a json representation.
  12028. * @param source the JSON source to parse
  12029. * @return The parsed curves
  12030. */
  12031. static Parse(source: any): ColorCurves;
  12032. }
  12033. }
  12034. declare module BABYLON {
  12035. /**
  12036. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  12037. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  12038. */
  12039. class EffectFallbacks {
  12040. private _defines;
  12041. private _currentRank;
  12042. private _maxRank;
  12043. private _mesh;
  12044. /**
  12045. * Removes the fallback from the bound mesh.
  12046. */
  12047. unBindMesh(): void;
  12048. /**
  12049. * Adds a fallback on the specified property.
  12050. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12051. * @param define The name of the define in the shader
  12052. */
  12053. addFallback(rank: number, define: string): void;
  12054. /**
  12055. * Sets the mesh to use CPU skinning when needing to fallback.
  12056. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12057. * @param mesh The mesh to use the fallbacks.
  12058. */
  12059. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  12060. /**
  12061. * Checks to see if more fallbacks are still availible.
  12062. */
  12063. readonly isMoreFallbacks: boolean;
  12064. /**
  12065. * Removes the defines that shoould be removed when falling back.
  12066. * @param currentDefines defines the current define statements for the shader.
  12067. * @param effect defines the current effect we try to compile
  12068. * @returns The resulting defines with defines of the current rank removed.
  12069. */
  12070. reduce(currentDefines: string, effect: Effect): string;
  12071. }
  12072. /**
  12073. * Options to be used when creating an effect.
  12074. */
  12075. class EffectCreationOptions {
  12076. /**
  12077. * Atrributes that will be used in the shader.
  12078. */
  12079. attributes: string[];
  12080. /**
  12081. * Uniform varible names that will be set in the shader.
  12082. */
  12083. uniformsNames: string[];
  12084. /**
  12085. * Uniform buffer varible names that will be set in the shader.
  12086. */
  12087. uniformBuffersNames: string[];
  12088. /**
  12089. * Sampler texture variable names that will be set in the shader.
  12090. */
  12091. samplers: string[];
  12092. /**
  12093. * Define statements that will be set in the shader.
  12094. */
  12095. defines: any;
  12096. /**
  12097. * Possible fallbacks for this effect to improve performance when needed.
  12098. */
  12099. fallbacks: Nullable<EffectFallbacks>;
  12100. /**
  12101. * Callback that will be called when the shader is compiled.
  12102. */
  12103. onCompiled: Nullable<(effect: Effect) => void>;
  12104. /**
  12105. * Callback that will be called if an error occurs during shader compilation.
  12106. */
  12107. onError: Nullable<(effect: Effect, errors: string) => void>;
  12108. /**
  12109. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  12110. */
  12111. indexParameters: any;
  12112. /**
  12113. * Max number of lights that can be used in the shader.
  12114. */
  12115. maxSimultaneousLights: number;
  12116. /**
  12117. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  12118. */
  12119. transformFeedbackVaryings: Nullable<string[]>;
  12120. }
  12121. /**
  12122. * Effect containing vertex and fragment shader that can be executed on an object.
  12123. */
  12124. class Effect {
  12125. /**
  12126. * Name of the effect.
  12127. */
  12128. name: any;
  12129. /**
  12130. * String container all the define statements that should be set on the shader.
  12131. */
  12132. defines: string;
  12133. /**
  12134. * Callback that will be called when the shader is compiled.
  12135. */
  12136. onCompiled: Nullable<(effect: Effect) => void>;
  12137. /**
  12138. * Callback that will be called if an error occurs during shader compilation.
  12139. */
  12140. onError: Nullable<(effect: Effect, errors: string) => void>;
  12141. /**
  12142. * Callback that will be called when effect is bound.
  12143. */
  12144. onBind: Nullable<(effect: Effect) => void>;
  12145. /**
  12146. * Unique ID of the effect.
  12147. */
  12148. uniqueId: number;
  12149. /**
  12150. * Observable that will be called when the shader is compiled.
  12151. */
  12152. onCompileObservable: Observable<Effect>;
  12153. /**
  12154. * Observable that will be called if an error occurs during shader compilation.
  12155. */
  12156. onErrorObservable: Observable<Effect>;
  12157. /**
  12158. * Observable that will be called when effect is bound.
  12159. */
  12160. onBindObservable: Observable<Effect>;
  12161. /** @hidden */
  12162. _bonesComputationForcedToCPU: boolean;
  12163. private static _uniqueIdSeed;
  12164. private _engine;
  12165. private _uniformBuffersNames;
  12166. private _uniformsNames;
  12167. private _samplers;
  12168. private _isReady;
  12169. private _compilationError;
  12170. private _attributesNames;
  12171. private _attributes;
  12172. private _uniforms;
  12173. /**
  12174. * Key for the effect.
  12175. */
  12176. _key: string;
  12177. private _indexParameters;
  12178. private _fallbacks;
  12179. private _vertexSourceCode;
  12180. private _fragmentSourceCode;
  12181. private _vertexSourceCodeOverride;
  12182. private _fragmentSourceCodeOverride;
  12183. private _transformFeedbackVaryings;
  12184. /**
  12185. * Compiled shader to webGL program.
  12186. */
  12187. _program: WebGLProgram;
  12188. private _valueCache;
  12189. private static _baseCache;
  12190. /**
  12191. * Instantiates an effect.
  12192. * An effect can be used to create/manage/execute vertex and fragment shaders.
  12193. * @param baseName Name of the effect.
  12194. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  12195. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  12196. * @param samplers List of sampler variables that will be passed to the shader.
  12197. * @param engine Engine to be used to render the effect
  12198. * @param defines Define statements to be added to the shader.
  12199. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  12200. * @param onCompiled Callback that will be called when the shader is compiled.
  12201. * @param onError Callback that will be called if an error occurs during shader compilation.
  12202. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  12203. */
  12204. 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);
  12205. /**
  12206. * Unique key for this effect
  12207. */
  12208. readonly key: string;
  12209. /**
  12210. * If the effect has been compiled and prepared.
  12211. * @returns if the effect is compiled and prepared.
  12212. */
  12213. isReady(): boolean;
  12214. /**
  12215. * The engine the effect was initialized with.
  12216. * @returns the engine.
  12217. */
  12218. getEngine(): Engine;
  12219. /**
  12220. * The compiled webGL program for the effect
  12221. * @returns the webGL program.
  12222. */
  12223. getProgram(): WebGLProgram;
  12224. /**
  12225. * The set of names of attribute variables for the shader.
  12226. * @returns An array of attribute names.
  12227. */
  12228. getAttributesNames(): string[];
  12229. /**
  12230. * Returns the attribute at the given index.
  12231. * @param index The index of the attribute.
  12232. * @returns The location of the attribute.
  12233. */
  12234. getAttributeLocation(index: number): number;
  12235. /**
  12236. * Returns the attribute based on the name of the variable.
  12237. * @param name of the attribute to look up.
  12238. * @returns the attribute location.
  12239. */
  12240. getAttributeLocationByName(name: string): number;
  12241. /**
  12242. * The number of attributes.
  12243. * @returns the numnber of attributes.
  12244. */
  12245. getAttributesCount(): number;
  12246. /**
  12247. * Gets the index of a uniform variable.
  12248. * @param uniformName of the uniform to look up.
  12249. * @returns the index.
  12250. */
  12251. getUniformIndex(uniformName: string): number;
  12252. /**
  12253. * Returns the attribute based on the name of the variable.
  12254. * @param uniformName of the uniform to look up.
  12255. * @returns the location of the uniform.
  12256. */
  12257. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  12258. /**
  12259. * Returns an array of sampler variable names
  12260. * @returns The array of sampler variable neames.
  12261. */
  12262. getSamplers(): string[];
  12263. /**
  12264. * The error from the last compilation.
  12265. * @returns the error string.
  12266. */
  12267. getCompilationError(): string;
  12268. /**
  12269. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  12270. * @param func The callback to be used.
  12271. */
  12272. executeWhenCompiled(func: (effect: Effect) => void): void;
  12273. /** @hidden */
  12274. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  12275. /** @hidden */
  12276. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  12277. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  12278. private _processShaderConversion(sourceCode, isFragment, callback);
  12279. private _processIncludes(sourceCode, callback);
  12280. private _processPrecision(source);
  12281. /**
  12282. * Recompiles the webGL program
  12283. * @param vertexSourceCode The source code for the vertex shader.
  12284. * @param fragmentSourceCode The source code for the fragment shader.
  12285. * @param onCompiled Callback called when completed.
  12286. * @param onError Callback called on error.
  12287. */
  12288. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  12289. /**
  12290. * Gets the uniform locations of the the specified variable names
  12291. * @param names THe names of the variables to lookup.
  12292. * @returns Array of locations in the same order as variable names.
  12293. */
  12294. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  12295. /**
  12296. * Prepares the effect
  12297. */
  12298. _prepareEffect(): void;
  12299. /**
  12300. * Checks if the effect is supported. (Must be called after compilation)
  12301. */
  12302. readonly isSupported: boolean;
  12303. /**
  12304. * Binds a texture to the engine to be used as output of the shader.
  12305. * @param channel Name of the output variable.
  12306. * @param texture Texture to bind.
  12307. */
  12308. _bindTexture(channel: string, texture: InternalTexture): void;
  12309. /**
  12310. * Sets a texture on the engine to be used in the shader.
  12311. * @param channel Name of the sampler variable.
  12312. * @param texture Texture to set.
  12313. */
  12314. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  12315. /**
  12316. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  12317. * @param channel Name of the sampler variable.
  12318. * @param texture Texture to set.
  12319. */
  12320. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  12321. /**
  12322. * Sets an array of textures on the engine to be used in the shader.
  12323. * @param channel Name of the variable.
  12324. * @param textures Textures to set.
  12325. */
  12326. setTextureArray(channel: string, textures: BaseTexture[]): void;
  12327. /**
  12328. * 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)
  12329. * @param channel Name of the sampler variable.
  12330. * @param postProcess Post process to get the input texture from.
  12331. */
  12332. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  12333. /**
  12334. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  12335. * 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)
  12336. * @param channel Name of the sampler variable.
  12337. * @param postProcess Post process to get the output texture from.
  12338. */
  12339. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  12340. /** @hidden */
  12341. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  12342. /** @hidden */
  12343. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  12344. /** @hidden */
  12345. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  12346. /** @hidden */
  12347. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  12348. /**
  12349. * Binds a buffer to a uniform.
  12350. * @param buffer Buffer to bind.
  12351. * @param name Name of the uniform variable to bind to.
  12352. */
  12353. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  12354. /**
  12355. * Binds block to a uniform.
  12356. * @param blockName Name of the block to bind.
  12357. * @param index Index to bind.
  12358. */
  12359. bindUniformBlock(blockName: string, index: number): void;
  12360. /**
  12361. * Sets an interger value on a uniform variable.
  12362. * @param uniformName Name of the variable.
  12363. * @param value Value to be set.
  12364. * @returns this effect.
  12365. */
  12366. setInt(uniformName: string, value: number): Effect;
  12367. /**
  12368. * Sets an int array on a uniform variable.
  12369. * @param uniformName Name of the variable.
  12370. * @param array array to be set.
  12371. * @returns this effect.
  12372. */
  12373. setIntArray(uniformName: string, array: Int32Array): Effect;
  12374. /**
  12375. * 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)
  12376. * @param uniformName Name of the variable.
  12377. * @param array array to be set.
  12378. * @returns this effect.
  12379. */
  12380. setIntArray2(uniformName: string, array: Int32Array): Effect;
  12381. /**
  12382. * 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)
  12383. * @param uniformName Name of the variable.
  12384. * @param array array to be set.
  12385. * @returns this effect.
  12386. */
  12387. setIntArray3(uniformName: string, array: Int32Array): Effect;
  12388. /**
  12389. * 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)
  12390. * @param uniformName Name of the variable.
  12391. * @param array array to be set.
  12392. * @returns this effect.
  12393. */
  12394. setIntArray4(uniformName: string, array: Int32Array): Effect;
  12395. /**
  12396. * Sets an float array on a uniform variable.
  12397. * @param uniformName Name of the variable.
  12398. * @param array array to be set.
  12399. * @returns this effect.
  12400. */
  12401. setFloatArray(uniformName: string, array: Float32Array): Effect;
  12402. /**
  12403. * 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)
  12404. * @param uniformName Name of the variable.
  12405. * @param array array to be set.
  12406. * @returns this effect.
  12407. */
  12408. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  12409. /**
  12410. * 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)
  12411. * @param uniformName Name of the variable.
  12412. * @param array array to be set.
  12413. * @returns this effect.
  12414. */
  12415. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  12416. /**
  12417. * 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)
  12418. * @param uniformName Name of the variable.
  12419. * @param array array to be set.
  12420. * @returns this effect.
  12421. */
  12422. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  12423. /**
  12424. * Sets an array on a uniform variable.
  12425. * @param uniformName Name of the variable.
  12426. * @param array array to be set.
  12427. * @returns this effect.
  12428. */
  12429. setArray(uniformName: string, array: number[]): Effect;
  12430. /**
  12431. * 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)
  12432. * @param uniformName Name of the variable.
  12433. * @param array array to be set.
  12434. * @returns this effect.
  12435. */
  12436. setArray2(uniformName: string, array: number[]): Effect;
  12437. /**
  12438. * 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)
  12439. * @param uniformName Name of the variable.
  12440. * @param array array to be set.
  12441. * @returns this effect.
  12442. */
  12443. setArray3(uniformName: string, array: number[]): Effect;
  12444. /**
  12445. * 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)
  12446. * @param uniformName Name of the variable.
  12447. * @param array array to be set.
  12448. * @returns this effect.
  12449. */
  12450. setArray4(uniformName: string, array: number[]): Effect;
  12451. /**
  12452. * Sets matrices on a uniform variable.
  12453. * @param uniformName Name of the variable.
  12454. * @param matrices matrices to be set.
  12455. * @returns this effect.
  12456. */
  12457. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  12458. /**
  12459. * Sets matrix on a uniform variable.
  12460. * @param uniformName Name of the variable.
  12461. * @param matrix matrix to be set.
  12462. * @returns this effect.
  12463. */
  12464. setMatrix(uniformName: string, matrix: Matrix): Effect;
  12465. /**
  12466. * 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)
  12467. * @param uniformName Name of the variable.
  12468. * @param matrix matrix to be set.
  12469. * @returns this effect.
  12470. */
  12471. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  12472. /**
  12473. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  12474. * @param uniformName Name of the variable.
  12475. * @param matrix matrix to be set.
  12476. * @returns this effect.
  12477. */
  12478. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  12479. /**
  12480. * Sets a float on a uniform variable.
  12481. * @param uniformName Name of the variable.
  12482. * @param value value to be set.
  12483. * @returns this effect.
  12484. */
  12485. setFloat(uniformName: string, value: number): Effect;
  12486. /**
  12487. * Sets a boolean on a uniform variable.
  12488. * @param uniformName Name of the variable.
  12489. * @param bool value to be set.
  12490. * @returns this effect.
  12491. */
  12492. setBool(uniformName: string, bool: boolean): Effect;
  12493. /**
  12494. * Sets a Vector2 on a uniform variable.
  12495. * @param uniformName Name of the variable.
  12496. * @param vector2 vector2 to be set.
  12497. * @returns this effect.
  12498. */
  12499. setVector2(uniformName: string, vector2: Vector2): Effect;
  12500. /**
  12501. * Sets a float2 on a uniform variable.
  12502. * @param uniformName Name of the variable.
  12503. * @param x First float in float2.
  12504. * @param y Second float in float2.
  12505. * @returns this effect.
  12506. */
  12507. setFloat2(uniformName: string, x: number, y: number): Effect;
  12508. /**
  12509. * Sets a Vector3 on a uniform variable.
  12510. * @param uniformName Name of the variable.
  12511. * @param vector3 Value to be set.
  12512. * @returns this effect.
  12513. */
  12514. setVector3(uniformName: string, vector3: Vector3): Effect;
  12515. /**
  12516. * Sets a float3 on a uniform variable.
  12517. * @param uniformName Name of the variable.
  12518. * @param x First float in float3.
  12519. * @param y Second float in float3.
  12520. * @param z Third float in float3.
  12521. * @returns this effect.
  12522. */
  12523. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  12524. /**
  12525. * Sets a Vector4 on a uniform variable.
  12526. * @param uniformName Name of the variable.
  12527. * @param vector4 Value to be set.
  12528. * @returns this effect.
  12529. */
  12530. setVector4(uniformName: string, vector4: Vector4): Effect;
  12531. /**
  12532. * Sets a float4 on a uniform variable.
  12533. * @param uniformName Name of the variable.
  12534. * @param x First float in float4.
  12535. * @param y Second float in float4.
  12536. * @param z Third float in float4.
  12537. * @param w Fourth float in float4.
  12538. * @returns this effect.
  12539. */
  12540. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  12541. /**
  12542. * Sets a Color3 on a uniform variable.
  12543. * @param uniformName Name of the variable.
  12544. * @param color3 Value to be set.
  12545. * @returns this effect.
  12546. */
  12547. setColor3(uniformName: string, color3: Color3): Effect;
  12548. /**
  12549. * Sets a Color4 on a uniform variable.
  12550. * @param uniformName Name of the variable.
  12551. * @param color3 Value to be set.
  12552. * @param alpha Alpha value to be set.
  12553. * @returns this effect.
  12554. */
  12555. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  12556. /**
  12557. * Sets a Color4 on a uniform variable
  12558. * @param uniformName defines the name of the variable
  12559. * @param color4 defines the value to be set
  12560. * @returns this effect.
  12561. */
  12562. setDirectColor4(uniformName: string, color4: Color4): Effect;
  12563. /**
  12564. * Store of each shader (The can be looked up using effect.key)
  12565. */
  12566. static ShadersStore: {
  12567. [key: string]: string;
  12568. };
  12569. /**
  12570. * Store of each included file for a shader (The can be looked up using effect.key)
  12571. */
  12572. static IncludesShadersStore: {
  12573. [key: string]: string;
  12574. };
  12575. /**
  12576. * Resets the cache of effects.
  12577. */
  12578. static ResetCache(): void;
  12579. }
  12580. }
  12581. declare module BABYLON {
  12582. class FresnelParameters {
  12583. private _isEnabled;
  12584. isEnabled: boolean;
  12585. leftColor: Color3;
  12586. rightColor: Color3;
  12587. bias: number;
  12588. power: number;
  12589. clone(): FresnelParameters;
  12590. serialize(): any;
  12591. static Parse(parsedFresnelParameters: any): FresnelParameters;
  12592. }
  12593. }
  12594. declare module BABYLON {
  12595. /**
  12596. * Interface to follow in your material defines to integrate easily the
  12597. * Image proccessing functions.
  12598. * @hidden
  12599. */
  12600. interface IImageProcessingConfigurationDefines {
  12601. IMAGEPROCESSING: boolean;
  12602. VIGNETTE: boolean;
  12603. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12604. VIGNETTEBLENDMODEOPAQUE: boolean;
  12605. TONEMAPPING: boolean;
  12606. CONTRAST: boolean;
  12607. EXPOSURE: boolean;
  12608. COLORCURVES: boolean;
  12609. COLORGRADING: boolean;
  12610. COLORGRADING3D: boolean;
  12611. SAMPLER3DGREENDEPTH: boolean;
  12612. SAMPLER3DBGRMAP: boolean;
  12613. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12614. }
  12615. /**
  12616. * This groups together the common properties used for image processing either in direct forward pass
  12617. * or through post processing effect depending on the use of the image processing pipeline in your scene
  12618. * or not.
  12619. */
  12620. class ImageProcessingConfiguration {
  12621. /**
  12622. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  12623. */
  12624. colorCurves: Nullable<ColorCurves>;
  12625. private _colorCurvesEnabled;
  12626. /**
  12627. * Gets wether the color curves effect is enabled.
  12628. */
  12629. /**
  12630. * Sets wether the color curves effect is enabled.
  12631. */
  12632. colorCurvesEnabled: boolean;
  12633. /**
  12634. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12635. */
  12636. colorGradingTexture: Nullable<BaseTexture>;
  12637. private _colorGradingEnabled;
  12638. /**
  12639. * Gets wether the color grading effect is enabled.
  12640. */
  12641. /**
  12642. * Sets wether the color grading effect is enabled.
  12643. */
  12644. colorGradingEnabled: boolean;
  12645. private _colorGradingWithGreenDepth;
  12646. /**
  12647. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  12648. */
  12649. /**
  12650. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  12651. */
  12652. colorGradingWithGreenDepth: boolean;
  12653. private _colorGradingBGR;
  12654. /**
  12655. * Gets wether the color grading texture contains BGR values.
  12656. */
  12657. /**
  12658. * Sets wether the color grading texture contains BGR values.
  12659. */
  12660. colorGradingBGR: boolean;
  12661. _exposure: number;
  12662. /**
  12663. * Gets the Exposure used in the effect.
  12664. */
  12665. /**
  12666. * Sets the Exposure used in the effect.
  12667. */
  12668. exposure: number;
  12669. private _toneMappingEnabled;
  12670. /**
  12671. * Gets wether the tone mapping effect is enabled.
  12672. */
  12673. /**
  12674. * Sets wether the tone mapping effect is enabled.
  12675. */
  12676. toneMappingEnabled: boolean;
  12677. protected _contrast: number;
  12678. /**
  12679. * Gets the contrast used in the effect.
  12680. */
  12681. /**
  12682. * Sets the contrast used in the effect.
  12683. */
  12684. contrast: number;
  12685. /**
  12686. * Vignette stretch size.
  12687. */
  12688. vignetteStretch: number;
  12689. /**
  12690. * Vignette centre X Offset.
  12691. */
  12692. vignetteCentreX: number;
  12693. /**
  12694. * Vignette centre Y Offset.
  12695. */
  12696. vignetteCentreY: number;
  12697. /**
  12698. * Vignette weight or intensity of the vignette effect.
  12699. */
  12700. vignetteWeight: number;
  12701. /**
  12702. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12703. * if vignetteEnabled is set to true.
  12704. */
  12705. vignetteColor: Color4;
  12706. /**
  12707. * Camera field of view used by the Vignette effect.
  12708. */
  12709. vignetteCameraFov: number;
  12710. private _vignetteBlendMode;
  12711. /**
  12712. * Gets the vignette blend mode allowing different kind of effect.
  12713. */
  12714. /**
  12715. * Sets the vignette blend mode allowing different kind of effect.
  12716. */
  12717. vignetteBlendMode: number;
  12718. private _vignetteEnabled;
  12719. /**
  12720. * Gets wether the vignette effect is enabled.
  12721. */
  12722. /**
  12723. * Sets wether the vignette effect is enabled.
  12724. */
  12725. vignetteEnabled: boolean;
  12726. private _applyByPostProcess;
  12727. /**
  12728. * Gets wether the image processing is applied through a post process or not.
  12729. */
  12730. /**
  12731. * Sets wether the image processing is applied through a post process or not.
  12732. */
  12733. applyByPostProcess: boolean;
  12734. private _isEnabled;
  12735. /**
  12736. * Gets wether the image processing is enabled or not.
  12737. */
  12738. /**
  12739. * Sets wether the image processing is enabled or not.
  12740. */
  12741. isEnabled: boolean;
  12742. /**
  12743. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12744. */
  12745. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12746. /**
  12747. * Method called each time the image processing information changes requires to recompile the effect.
  12748. */
  12749. protected _updateParameters(): void;
  12750. getClassName(): string;
  12751. /**
  12752. * Prepare the list of uniforms associated with the Image Processing effects.
  12753. * @param uniformsList The list of uniforms used in the effect
  12754. * @param defines the list of defines currently in use
  12755. */
  12756. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12757. /**
  12758. * Prepare the list of samplers associated with the Image Processing effects.
  12759. * @param uniformsList The list of uniforms used in the effect
  12760. * @param defines the list of defines currently in use
  12761. */
  12762. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12763. /**
  12764. * Prepare the list of defines associated to the shader.
  12765. * @param defines the list of defines to complete
  12766. */
  12767. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12768. /**
  12769. * Returns true if all the image processing information are ready.
  12770. */
  12771. isReady(): boolean;
  12772. /**
  12773. * Binds the image processing to the shader.
  12774. * @param effect The effect to bind to
  12775. */
  12776. bind(effect: Effect, aspectRatio?: number): void;
  12777. /**
  12778. * Clones the current image processing instance.
  12779. * @return The cloned image processing
  12780. */
  12781. clone(): ImageProcessingConfiguration;
  12782. /**
  12783. * Serializes the current image processing instance to a json representation.
  12784. * @return a JSON representation
  12785. */
  12786. serialize(): any;
  12787. /**
  12788. * Parses the image processing from a json representation.
  12789. * @param source the JSON source to parse
  12790. * @return The parsed image processing
  12791. */
  12792. static Parse(source: any): ImageProcessingConfiguration;
  12793. private static _VIGNETTEMODE_MULTIPLY;
  12794. private static _VIGNETTEMODE_OPAQUE;
  12795. /**
  12796. * Used to apply the vignette as a mix with the pixel color.
  12797. */
  12798. static readonly VIGNETTEMODE_MULTIPLY: number;
  12799. /**
  12800. * Used to apply the vignette as a replacement of the pixel color.
  12801. */
  12802. static readonly VIGNETTEMODE_OPAQUE: number;
  12803. }
  12804. }
  12805. declare module BABYLON {
  12806. /**
  12807. * Manages the defines for the Material
  12808. */
  12809. class MaterialDefines {
  12810. private _keys;
  12811. private _isDirty;
  12812. /** @hidden */
  12813. _renderId: number;
  12814. /** @hidden */
  12815. _areLightsDirty: boolean;
  12816. /** @hidden */
  12817. _areAttributesDirty: boolean;
  12818. /** @hidden */
  12819. _areTexturesDirty: boolean;
  12820. /** @hidden */
  12821. _areFresnelDirty: boolean;
  12822. /** @hidden */
  12823. _areMiscDirty: boolean;
  12824. /** @hidden */
  12825. _areImageProcessingDirty: boolean;
  12826. /** @hidden */
  12827. _normals: boolean;
  12828. /** @hidden */
  12829. _uvs: boolean;
  12830. /** @hidden */
  12831. _needNormals: boolean;
  12832. /** @hidden */
  12833. _needUVs: boolean;
  12834. /**
  12835. * Specifies if the material needs to be re-calculated
  12836. */
  12837. readonly isDirty: boolean;
  12838. /**
  12839. * Marks the material to indicate that it has been re-calculated
  12840. */
  12841. markAsProcessed(): void;
  12842. /**
  12843. * Marks the material to indicate that it needs to be re-calculated
  12844. */
  12845. markAsUnprocessed(): void;
  12846. /**
  12847. * Marks the material to indicate all of its defines need to be re-calculated
  12848. */
  12849. markAllAsDirty(): void;
  12850. /**
  12851. * Marks the material to indicate that image processing needs to be re-calculated
  12852. */
  12853. markAsImageProcessingDirty(): void;
  12854. /**
  12855. * Marks the material to indicate the lights need to be re-calculated
  12856. */
  12857. markAsLightDirty(): void;
  12858. /**
  12859. * Marks the attribute state as changed
  12860. */
  12861. markAsAttributesDirty(): void;
  12862. /**
  12863. * Marks the texture state as changed
  12864. */
  12865. markAsTexturesDirty(): void;
  12866. /**
  12867. * Marks the fresnel state as changed
  12868. */
  12869. markAsFresnelDirty(): void;
  12870. /**
  12871. * Marks the misc state as changed
  12872. */
  12873. markAsMiscDirty(): void;
  12874. /**
  12875. * Rebuilds the material defines
  12876. */
  12877. rebuild(): void;
  12878. /**
  12879. * Specifies if two material defines are equal
  12880. * @param other - A material define instance to compare to
  12881. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  12882. */
  12883. isEqual(other: MaterialDefines): boolean;
  12884. /**
  12885. * Clones this instance's defines to another instance
  12886. * @param other - material defines to clone values to
  12887. */
  12888. cloneTo(other: MaterialDefines): void;
  12889. /**
  12890. * Resets the material define values
  12891. */
  12892. reset(): void;
  12893. /**
  12894. * Converts the material define values to a string
  12895. * @returns - String of material define information
  12896. */
  12897. toString(): string;
  12898. }
  12899. /**
  12900. * Base class for the main features of a material in Babylon.js
  12901. */
  12902. class Material implements IAnimatable {
  12903. private static _TriangleFillMode;
  12904. private static _WireFrameFillMode;
  12905. private static _PointFillMode;
  12906. private static _PointListDrawMode;
  12907. private static _LineListDrawMode;
  12908. private static _LineLoopDrawMode;
  12909. private static _LineStripDrawMode;
  12910. private static _TriangleStripDrawMode;
  12911. private static _TriangleFanDrawMode;
  12912. /**
  12913. * Returns the triangle fill mode
  12914. */
  12915. static readonly TriangleFillMode: number;
  12916. /**
  12917. * Returns the wireframe mode
  12918. */
  12919. static readonly WireFrameFillMode: number;
  12920. /**
  12921. * Returns the point fill mode
  12922. */
  12923. static readonly PointFillMode: number;
  12924. /**
  12925. * Returns the point list draw mode
  12926. */
  12927. static readonly PointListDrawMode: number;
  12928. /**
  12929. * Returns the line list draw mode
  12930. */
  12931. static readonly LineListDrawMode: number;
  12932. /**
  12933. * Returns the line loop draw mode
  12934. */
  12935. static readonly LineLoopDrawMode: number;
  12936. /**
  12937. * Returns the line strip draw mode
  12938. */
  12939. static readonly LineStripDrawMode: number;
  12940. /**
  12941. * Returns the triangle strip draw mode
  12942. */
  12943. static readonly TriangleStripDrawMode: number;
  12944. /**
  12945. * Returns the triangle fan draw mode
  12946. */
  12947. static readonly TriangleFanDrawMode: number;
  12948. /**
  12949. * Stores the clock-wise side orientation
  12950. */
  12951. private static _ClockWiseSideOrientation;
  12952. /**
  12953. * Stores the counter clock-wise side orientation
  12954. */
  12955. private static _CounterClockWiseSideOrientation;
  12956. /**
  12957. * Returns the clock-wise side orientation
  12958. */
  12959. static readonly ClockWiseSideOrientation: number;
  12960. /**
  12961. * Returns the counter clock-wise side orientation
  12962. */
  12963. static readonly CounterClockWiseSideOrientation: number;
  12964. /**
  12965. * The dirty texture flag value
  12966. */
  12967. private static _TextureDirtyFlag;
  12968. /**
  12969. * The dirty light flag value
  12970. */
  12971. private static _LightDirtyFlag;
  12972. /**
  12973. * The dirty fresnel flag value
  12974. */
  12975. private static _FresnelDirtyFlag;
  12976. /**
  12977. * The dirty attribute flag value
  12978. */
  12979. private static _AttributesDirtyFlag;
  12980. /**
  12981. * The dirty misc flag value
  12982. */
  12983. private static _MiscDirtyFlag;
  12984. /**
  12985. * Returns the dirty texture flag value
  12986. */
  12987. static readonly TextureDirtyFlag: number;
  12988. /**
  12989. * Returns the dirty light flag value
  12990. */
  12991. static readonly LightDirtyFlag: number;
  12992. /**
  12993. * Returns the dirty fresnel flag value
  12994. */
  12995. static readonly FresnelDirtyFlag: number;
  12996. /**
  12997. * Returns the dirty attributes flag value
  12998. */
  12999. static readonly AttributesDirtyFlag: number;
  13000. /**
  13001. * Returns the dirty misc flag value
  13002. */
  13003. static readonly MiscDirtyFlag: number;
  13004. /**
  13005. * The ID of the material
  13006. */
  13007. id: string;
  13008. /**
  13009. * The name of the material
  13010. */
  13011. name: string;
  13012. /**
  13013. * Specifies if the ready state should be checked on each call
  13014. */
  13015. checkReadyOnEveryCall: boolean;
  13016. /**
  13017. * Specifies if the ready state should be checked once
  13018. */
  13019. checkReadyOnlyOnce: boolean;
  13020. /**
  13021. * The state of the material
  13022. */
  13023. state: string;
  13024. /**
  13025. * The alpha value of the material
  13026. */
  13027. protected _alpha: number;
  13028. /**
  13029. * Gets the alpha value of the material
  13030. */
  13031. /**
  13032. * Sets the alpha value of the material
  13033. */
  13034. alpha: number;
  13035. /**
  13036. * Specifies if back face culling is enabled
  13037. */
  13038. protected _backFaceCulling: boolean;
  13039. /**
  13040. * Gets the back-face culling state
  13041. */
  13042. /**
  13043. * Sets the back-face culling state
  13044. */
  13045. backFaceCulling: boolean;
  13046. /**
  13047. * Stores the value for side orientation
  13048. */
  13049. sideOrientation: number;
  13050. /**
  13051. * Callback triggered when the material is compiled
  13052. */
  13053. onCompiled: (effect: Effect) => void;
  13054. /**
  13055. * Callback triggered when an error occurs
  13056. */
  13057. onError: (effect: Effect, errors: string) => void;
  13058. /**
  13059. * Callback triggered to get the render target textures
  13060. */
  13061. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  13062. /**
  13063. * Specifies if the material should be serialized
  13064. */
  13065. doNotSerialize: boolean;
  13066. /**
  13067. * Specifies if the effect should be stored on sub meshes
  13068. */
  13069. storeEffectOnSubMeshes: boolean;
  13070. /**
  13071. * Stores the animations for the material
  13072. */
  13073. animations: Array<Animation>;
  13074. /**
  13075. * An event triggered when the material is disposed
  13076. */
  13077. onDisposeObservable: Observable<Material>;
  13078. /**
  13079. * An observer which watches for dispose events
  13080. */
  13081. private _onDisposeObserver;
  13082. /**
  13083. * Called during a dispose event
  13084. */
  13085. onDispose: () => void;
  13086. /**
  13087. * An event triggered when the material is bound
  13088. */
  13089. onBindObservable: Observable<AbstractMesh>;
  13090. /**
  13091. * An observer which watches for bind events
  13092. */
  13093. private _onBindObserver;
  13094. /**
  13095. * Called during a bind event
  13096. */
  13097. onBind: (Mesh: AbstractMesh) => void;
  13098. /**
  13099. * An event triggered when the material is unbound
  13100. */
  13101. onUnBindObservable: Observable<Material>;
  13102. /**
  13103. * Stores the value of the alpha mode
  13104. */
  13105. private _alphaMode;
  13106. /**
  13107. * Gets the value of the alpha mode
  13108. */
  13109. /**
  13110. * Sets the value of the alpha mode.
  13111. *
  13112. * | Value | Type | Description |
  13113. * | --- | --- | --- |
  13114. * | 0 | ALPHA_DISABLE | |
  13115. * | 1 | ALPHA_ADD | |
  13116. * | 2 | ALPHA_COMBINE | |
  13117. * | 3 | ALPHA_SUBTRACT | |
  13118. * | 4 | ALPHA_MULTIPLY | |
  13119. * | 5 | ALPHA_MAXIMIZED | |
  13120. * | 6 | ALPHA_ONEONE | |
  13121. * | 7 | ALPHA_PREMULTIPLIED | |
  13122. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  13123. * | 9 | ALPHA_INTERPOLATE | |
  13124. * | 10 | ALPHA_SCREENMODE | |
  13125. *
  13126. */
  13127. alphaMode: number;
  13128. /**
  13129. * Stores the state of the need depth pre-pass value
  13130. */
  13131. private _needDepthPrePass;
  13132. /**
  13133. * Gets the depth pre-pass value
  13134. */
  13135. /**
  13136. * Sets the need depth pre-pass value
  13137. */
  13138. needDepthPrePass: boolean;
  13139. /**
  13140. * Specifies if depth writing should be disabled
  13141. */
  13142. disableDepthWrite: boolean;
  13143. /**
  13144. * Specifies if depth writing should be forced
  13145. */
  13146. forceDepthWrite: boolean;
  13147. /**
  13148. * Specifies if there should be a separate pass for culling
  13149. */
  13150. separateCullingPass: boolean;
  13151. /**
  13152. * Stores the state specifing if fog should be enabled
  13153. */
  13154. private _fogEnabled;
  13155. /**
  13156. * Gets the value of the fog enabled state
  13157. */
  13158. /**
  13159. * Sets the state for enabling fog
  13160. */
  13161. fogEnabled: boolean;
  13162. /**
  13163. * Stores the size of points
  13164. */
  13165. pointSize: number;
  13166. /**
  13167. * Stores the z offset value
  13168. */
  13169. zOffset: number;
  13170. /**
  13171. * Gets a value specifying if wireframe mode is enabled
  13172. */
  13173. /**
  13174. * Sets the state of wireframe mode
  13175. */
  13176. wireframe: boolean;
  13177. /**
  13178. * Gets the value specifying if point clouds are enabled
  13179. */
  13180. /**
  13181. * Sets the state of point cloud mode
  13182. */
  13183. pointsCloud: boolean;
  13184. /**
  13185. * Gets the material fill mode
  13186. */
  13187. /**
  13188. * Sets the material fill mode
  13189. */
  13190. fillMode: number;
  13191. /**
  13192. * Stores the effects for the material
  13193. */
  13194. _effect: Nullable<Effect>;
  13195. /**
  13196. * Specifies if the material was previously ready
  13197. */
  13198. _wasPreviouslyReady: boolean;
  13199. /**
  13200. * Specifies if uniform buffers should be used
  13201. */
  13202. private _useUBO;
  13203. /**
  13204. * Stores a reference to the scene
  13205. */
  13206. private _scene;
  13207. /**
  13208. * Stores the fill mode state
  13209. */
  13210. private _fillMode;
  13211. /**
  13212. * Specifies if the depth write state should be cached
  13213. */
  13214. private _cachedDepthWriteState;
  13215. /**
  13216. * Stores the uniform buffer
  13217. */
  13218. protected _uniformBuffer: UniformBuffer;
  13219. /**
  13220. * Creates a material instance
  13221. * @param name defines the name of the material
  13222. * @param scene defines the scene to reference
  13223. * @param doNotAdd specifies if the material should be added to the scene
  13224. */
  13225. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  13226. /**
  13227. * Returns a string representation of the current material
  13228. * @param fullDetails defines a boolean indicating which levels of logging is desired
  13229. * @returns a string with material information
  13230. */
  13231. toString(fullDetails?: boolean): string;
  13232. /**
  13233. * Gets the class name of the material
  13234. * @returns a string with the class name of the material
  13235. */
  13236. getClassName(): string;
  13237. /**
  13238. * Specifies if updates for the material been locked
  13239. */
  13240. readonly isFrozen: boolean;
  13241. /**
  13242. * Locks updates for the material
  13243. */
  13244. freeze(): void;
  13245. /**
  13246. * Unlocks updates for the material
  13247. */
  13248. unfreeze(): void;
  13249. /**
  13250. * Specifies if the material is ready to be used
  13251. * @param mesh defines the mesh to check
  13252. * @param useInstances specifies if instances should be used
  13253. * @returns a boolean indicating if the material is ready to be used
  13254. */
  13255. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13256. /**
  13257. * Specifies that the submesh is ready to be used
  13258. * @param mesh defines the mesh to check
  13259. * @param subMesh defines which submesh to check
  13260. * @param useInstances specifies that instances should be used
  13261. * @returns a boolean indicating that the submesh is ready or not
  13262. */
  13263. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  13264. /**
  13265. * Returns the material effect
  13266. * @returns the effect associated with the material
  13267. */
  13268. getEffect(): Nullable<Effect>;
  13269. /**
  13270. * Returns the current scene
  13271. * @returns a Scene
  13272. */
  13273. getScene(): Scene;
  13274. /**
  13275. * Specifies if the material will require alpha blending
  13276. * @returns a boolean specifying if alpha blending is needed
  13277. */
  13278. needAlphaBlending(): boolean;
  13279. /**
  13280. * Specifies if the mesh will require alpha blending
  13281. * @param mesh defines the mesh to check
  13282. * @returns a boolean specifying if alpha blending is needed for the mesh
  13283. */
  13284. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  13285. /**
  13286. * Specifies if this material should be rendered in alpha test mode
  13287. * @returns a boolean specifying if an alpha test is needed.
  13288. */
  13289. needAlphaTesting(): boolean;
  13290. /**
  13291. * Gets the texture used for the alpha test
  13292. * @returns the texture to use for alpha testing
  13293. */
  13294. getAlphaTestTexture(): Nullable<BaseTexture>;
  13295. /**
  13296. * Marks the material to indicate that it needs to be re-calculated
  13297. */
  13298. markDirty(): void;
  13299. /** @hidden */
  13300. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  13301. /**
  13302. * Binds the material to the mesh
  13303. * @param world defines the world transformation matrix
  13304. * @param mesh defines the mesh to bind the material to
  13305. */
  13306. bind(world: Matrix, mesh?: Mesh): void;
  13307. /**
  13308. * Binds the submesh to the material
  13309. * @param world defines the world transformation matrix
  13310. * @param mesh defines the mesh containing the submesh
  13311. * @param subMesh defines the submesh to bind the material to
  13312. */
  13313. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  13314. /**
  13315. * Binds the world matrix to the material
  13316. * @param world defines the world transformation matrix
  13317. */
  13318. bindOnlyWorldMatrix(world: Matrix): void;
  13319. /**
  13320. * Binds the scene's uniform buffer to the effect.
  13321. * @param effect defines the effect to bind to the scene uniform buffer
  13322. * @param sceneUbo defines the uniform buffer storing scene data
  13323. */
  13324. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  13325. /**
  13326. * Binds the view matrix to the effect
  13327. * @param effect defines the effect to bind the view matrix to
  13328. */
  13329. bindView(effect: Effect): void;
  13330. /**
  13331. * Binds the view projection matrix to the effect
  13332. * @param effect defines the effect to bind the view projection matrix to
  13333. */
  13334. bindViewProjection(effect: Effect): void;
  13335. /**
  13336. * Specifies if material alpha testing should be turned on for the mesh
  13337. * @param mesh defines the mesh to check
  13338. */
  13339. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  13340. /**
  13341. * Processes to execute after binding the material to a mesh
  13342. * @param mesh defines the rendered mesh
  13343. */
  13344. protected _afterBind(mesh?: Mesh): void;
  13345. /**
  13346. * Unbinds the material from the mesh
  13347. */
  13348. unbind(): void;
  13349. /**
  13350. * Gets the active textures from the material
  13351. * @returns an array of textures
  13352. */
  13353. getActiveTextures(): BaseTexture[];
  13354. /**
  13355. * Specifies if the material uses a texture
  13356. * @param texture defines the texture to check against the material
  13357. * @returns a boolean specifying if the material uses the texture
  13358. */
  13359. hasTexture(texture: BaseTexture): boolean;
  13360. /**
  13361. * Makes a duplicate of the material, and gives it a new name
  13362. * @param name defines the new name for the duplicated material
  13363. * @returns the cloned material
  13364. */
  13365. clone(name: string): Nullable<Material>;
  13366. /**
  13367. * Gets the meshes bound to the material
  13368. * @returns an array of meshes bound to the material
  13369. */
  13370. getBindedMeshes(): AbstractMesh[];
  13371. /**
  13372. * Force shader compilation
  13373. * @param mesh defines the mesh associated with this material
  13374. * @param onCompiled defines a function to execute once the material is compiled
  13375. * @param options defines the options to configure the compilation
  13376. */
  13377. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  13378. clipPlane: boolean;
  13379. }>): void;
  13380. /**
  13381. * Force shader compilation
  13382. * @param mesh defines the mesh that will use this material
  13383. * @param options defines additional options for compiling the shaders
  13384. * @returns a promise that resolves when the compilation completes
  13385. */
  13386. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  13387. clipPlane: boolean;
  13388. }>): Promise<void>;
  13389. /**
  13390. * Marks a define in the material to indicate that it needs to be re-computed
  13391. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  13392. */
  13393. markAsDirty(flag: number): void;
  13394. /**
  13395. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  13396. * @param func defines a function which checks material defines against the submeshes
  13397. */
  13398. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  13399. /**
  13400. * Indicates that image processing needs to be re-calculated for all submeshes
  13401. */
  13402. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  13403. /**
  13404. * Indicates that textures need to be re-calculated for all submeshes
  13405. */
  13406. protected _markAllSubMeshesAsTexturesDirty(): void;
  13407. /**
  13408. * Indicates that fresnel needs to be re-calculated for all submeshes
  13409. */
  13410. protected _markAllSubMeshesAsFresnelDirty(): void;
  13411. /**
  13412. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  13413. */
  13414. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  13415. /**
  13416. * Indicates that lights need to be re-calculated for all submeshes
  13417. */
  13418. protected _markAllSubMeshesAsLightsDirty(): void;
  13419. /**
  13420. * Indicates that attributes need to be re-calculated for all submeshes
  13421. */
  13422. protected _markAllSubMeshesAsAttributesDirty(): void;
  13423. /**
  13424. * Indicates that misc needs to be re-calculated for all submeshes
  13425. */
  13426. protected _markAllSubMeshesAsMiscDirty(): void;
  13427. /**
  13428. * Indicates that textures and misc need to be re-calculated for all submeshes
  13429. */
  13430. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  13431. /**
  13432. * Disposes the material
  13433. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  13434. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  13435. */
  13436. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13437. /**
  13438. * Serializes this material
  13439. * @returns the serialized material object
  13440. */
  13441. serialize(): any;
  13442. /**
  13443. * Creates a MultiMaterial from parsed MultiMaterial data.
  13444. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  13445. * @param scene defines the hosting scene
  13446. * @returns a new MultiMaterial
  13447. */
  13448. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  13449. /**
  13450. * Creates a material from parsed material data
  13451. * @param parsedMaterial defines parsed material data
  13452. * @param scene defines the hosting scene
  13453. * @param rootUrl defines the root URL to use to load textures
  13454. * @returns a new material
  13455. */
  13456. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  13457. }
  13458. }
  13459. declare module BABYLON {
  13460. /**
  13461. * "Static Class" containing the most commonly used helper while dealing with material for
  13462. * rendering purpose.
  13463. *
  13464. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  13465. *
  13466. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  13467. */
  13468. class MaterialHelper {
  13469. /**
  13470. * Bind the current view position to an effect.
  13471. * @param effect The effect to be bound
  13472. * @param scene The scene the eyes position is used from
  13473. */
  13474. static BindEyePosition(effect: Effect, scene: Scene): void;
  13475. /**
  13476. * Helps preparing the defines values about the UVs in used in the effect.
  13477. * UVs are shared as much as we can accross chanels in the shaders.
  13478. * @param texture The texture we are preparing the UVs for
  13479. * @param defines The defines to update
  13480. * @param key The chanel key "diffuse", "specular"... used in the shader
  13481. */
  13482. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  13483. /**
  13484. * Binds a texture matrix value to its corrsponding uniform
  13485. * @param texture The texture to bind the matrix for
  13486. * @param uniformBuffer The uniform buffer receivin the data
  13487. * @param key The chanel key "diffuse", "specular"... used in the shader
  13488. */
  13489. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  13490. /**
  13491. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  13492. * @param mesh defines the current mesh
  13493. * @param scene defines the current scene
  13494. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  13495. * @param pointsCloud defines if point cloud rendering has to be turned on
  13496. * @param fogEnabled defines if fog has to be turned on
  13497. * @param alphaTest defines if alpha testing has to be turned on
  13498. * @param defines defines the current list of defines
  13499. */
  13500. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  13501. /**
  13502. * Helper used to prepare the list of defines associated with frame values for shader compilation
  13503. * @param scene defines the current scene
  13504. * @param engine defines the current engine
  13505. * @param defines specifies the list of active defines
  13506. * @param useInstances defines if instances have to be turned on
  13507. * @param useClipPlane defines if clip plane have to be turned on
  13508. */
  13509. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  13510. /**
  13511. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  13512. * @param mesh The mesh containing the geometry data we will draw
  13513. * @param defines The defines to update
  13514. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  13515. * @param useBones Precise whether bones should be used or not (override mesh info)
  13516. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  13517. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  13518. * @returns false if defines are considered not dirty and have not been checked
  13519. */
  13520. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  13521. /**
  13522. * Prepares the defines related to the light information passed in parameter
  13523. * @param scene The scene we are intending to draw
  13524. * @param mesh The mesh the effect is compiling for
  13525. * @param defines The defines to update
  13526. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  13527. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  13528. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  13529. * @returns true if normals will be required for the rest of the effect
  13530. */
  13531. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  13532. /**
  13533. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  13534. * that won t be acctive due to defines being turned off.
  13535. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  13536. * @param samplersList The samplers list
  13537. * @param defines The defines helping in the list generation
  13538. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  13539. */
  13540. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  13541. /**
  13542. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  13543. * @param defines The defines to update while falling back
  13544. * @param fallbacks The authorized effect fallbacks
  13545. * @param maxSimultaneousLights The maximum number of lights allowed
  13546. * @param rank the current rank of the Effect
  13547. * @returns The newly affected rank
  13548. */
  13549. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  13550. /**
  13551. * Prepares the list of attributes required for morph targets according to the effect defines.
  13552. * @param attribs The current list of supported attribs
  13553. * @param mesh The mesh to prepare the morph targets attributes for
  13554. * @param defines The current Defines of the effect
  13555. */
  13556. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  13557. /**
  13558. * Prepares the list of attributes required for bones according to the effect defines.
  13559. * @param attribs The current list of supported attribs
  13560. * @param mesh The mesh to prepare the bones attributes for
  13561. * @param defines The current Defines of the effect
  13562. * @param fallbacks The current efffect fallback strategy
  13563. */
  13564. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  13565. /**
  13566. * Prepares the list of attributes required for instances according to the effect defines.
  13567. * @param attribs The current list of supported attribs
  13568. * @param defines The current Defines of the effect
  13569. */
  13570. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  13571. /**
  13572. * Binds the light shadow information to the effect for the given mesh.
  13573. * @param light The light containing the generator
  13574. * @param scene The scene the lights belongs to
  13575. * @param mesh The mesh we are binding the information to render
  13576. * @param lightIndex The light index in the effect used to render the mesh
  13577. * @param effect The effect we are binding the data to
  13578. */
  13579. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  13580. /**
  13581. * Binds the light information to the effect.
  13582. * @param light The light containing the generator
  13583. * @param effect The effect we are binding the data to
  13584. * @param lightIndex The light index in the effect used to render
  13585. */
  13586. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  13587. /**
  13588. * Binds the lights information from the scene to the effect for the given mesh.
  13589. * @param scene The scene the lights belongs to
  13590. * @param mesh The mesh we are binding the information to render
  13591. * @param effect The effect we are binding the data to
  13592. * @param defines The generated defines for the effect
  13593. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  13594. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  13595. */
  13596. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  13597. /**
  13598. * Binds the fog information from the scene to the effect for the given mesh.
  13599. * @param scene The scene the lights belongs to
  13600. * @param mesh The mesh we are binding the information to render
  13601. * @param effect The effect we are binding the data to
  13602. */
  13603. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  13604. /**
  13605. * Binds the bones information from the mesh to the effect.
  13606. * @param mesh The mesh we are binding the information to render
  13607. * @param effect The effect we are binding the data to
  13608. */
  13609. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  13610. /**
  13611. * Binds the morph targets information from the mesh to the effect.
  13612. * @param abstractMesh The mesh we are binding the information to render
  13613. * @param effect The effect we are binding the data to
  13614. */
  13615. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  13616. /**
  13617. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  13618. * @param defines The generated defines used in the effect
  13619. * @param effect The effect we are binding the data to
  13620. * @param scene The scene we are willing to render with logarithmic scale for
  13621. */
  13622. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  13623. /**
  13624. * Binds the clip plane information from the scene to the effect.
  13625. * @param scene The scene the clip plane information are extracted from
  13626. * @param effect The effect we are binding the data to
  13627. */
  13628. static BindClipPlane(effect: Effect, scene: Scene): void;
  13629. }
  13630. }
  13631. declare module BABYLON {
  13632. class MultiMaterial extends Material {
  13633. private _subMaterials;
  13634. subMaterials: Nullable<Material>[];
  13635. constructor(name: string, scene: Scene);
  13636. private _hookArray(array);
  13637. getSubMaterial(index: number): Nullable<Material>;
  13638. getActiveTextures(): BaseTexture[];
  13639. getClassName(): string;
  13640. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  13641. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  13642. serialize(): any;
  13643. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13644. }
  13645. }
  13646. declare module BABYLON {
  13647. class PushMaterial extends Material {
  13648. protected _activeEffect: Effect;
  13649. protected _normalMatrix: Matrix;
  13650. constructor(name: string, scene: Scene);
  13651. getEffect(): Effect;
  13652. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13653. /**
  13654. * Binds the given world matrix to the active effect
  13655. *
  13656. * @param world the matrix to bind
  13657. */
  13658. bindOnlyWorldMatrix(world: Matrix): void;
  13659. /**
  13660. * Binds the given normal matrix to the active effect
  13661. *
  13662. * @param normalMatrix the matrix to bind
  13663. */
  13664. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13665. bind(world: Matrix, mesh?: Mesh): void;
  13666. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13667. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13668. }
  13669. }
  13670. declare module BABYLON {
  13671. class ShaderMaterial extends Material {
  13672. private _shaderPath;
  13673. private _options;
  13674. private _textures;
  13675. private _textureArrays;
  13676. private _floats;
  13677. private _ints;
  13678. private _floatsArrays;
  13679. private _colors3;
  13680. private _colors3Arrays;
  13681. private _colors4;
  13682. private _vectors2;
  13683. private _vectors3;
  13684. private _vectors4;
  13685. private _matrices;
  13686. private _matrices3x3;
  13687. private _matrices2x2;
  13688. private _vectors2Arrays;
  13689. private _vectors3Arrays;
  13690. private _cachedWorldViewMatrix;
  13691. private _renderId;
  13692. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  13693. getClassName(): string;
  13694. needAlphaBlending(): boolean;
  13695. needAlphaTesting(): boolean;
  13696. private _checkUniform(uniformName);
  13697. setTexture(name: string, texture: Texture): ShaderMaterial;
  13698. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  13699. setFloat(name: string, value: number): ShaderMaterial;
  13700. setInt(name: string, value: number): ShaderMaterial;
  13701. setFloats(name: string, value: number[]): ShaderMaterial;
  13702. setColor3(name: string, value: Color3): ShaderMaterial;
  13703. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  13704. setColor4(name: string, value: Color4): ShaderMaterial;
  13705. setVector2(name: string, value: Vector2): ShaderMaterial;
  13706. setVector3(name: string, value: Vector3): ShaderMaterial;
  13707. setVector4(name: string, value: Vector4): ShaderMaterial;
  13708. setMatrix(name: string, value: Matrix): ShaderMaterial;
  13709. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  13710. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  13711. setArray2(name: string, value: number[]): ShaderMaterial;
  13712. setArray3(name: string, value: number[]): ShaderMaterial;
  13713. private _checkCache(scene, mesh?, useInstances?);
  13714. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13715. bindOnlyWorldMatrix(world: Matrix): void;
  13716. bind(world: Matrix, mesh?: Mesh): void;
  13717. getActiveTextures(): BaseTexture[];
  13718. hasTexture(texture: BaseTexture): boolean;
  13719. clone(name: string): ShaderMaterial;
  13720. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13721. serialize(): any;
  13722. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  13723. }
  13724. }
  13725. declare module BABYLON {
  13726. /** @hidden */
  13727. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  13728. MAINUV1: boolean;
  13729. MAINUV2: boolean;
  13730. DIFFUSE: boolean;
  13731. DIFFUSEDIRECTUV: number;
  13732. AMBIENT: boolean;
  13733. AMBIENTDIRECTUV: number;
  13734. OPACITY: boolean;
  13735. OPACITYDIRECTUV: number;
  13736. OPACITYRGB: boolean;
  13737. REFLECTION: boolean;
  13738. EMISSIVE: boolean;
  13739. EMISSIVEDIRECTUV: number;
  13740. SPECULAR: boolean;
  13741. SPECULARDIRECTUV: number;
  13742. BUMP: boolean;
  13743. BUMPDIRECTUV: number;
  13744. PARALLAX: boolean;
  13745. PARALLAXOCCLUSION: boolean;
  13746. SPECULAROVERALPHA: boolean;
  13747. CLIPPLANE: boolean;
  13748. ALPHATEST: boolean;
  13749. DEPTHPREPASS: boolean;
  13750. ALPHAFROMDIFFUSE: boolean;
  13751. POINTSIZE: boolean;
  13752. FOG: boolean;
  13753. SPECULARTERM: boolean;
  13754. DIFFUSEFRESNEL: boolean;
  13755. OPACITYFRESNEL: boolean;
  13756. REFLECTIONFRESNEL: boolean;
  13757. REFRACTIONFRESNEL: boolean;
  13758. EMISSIVEFRESNEL: boolean;
  13759. FRESNEL: boolean;
  13760. NORMAL: boolean;
  13761. UV1: boolean;
  13762. UV2: boolean;
  13763. VERTEXCOLOR: boolean;
  13764. VERTEXALPHA: boolean;
  13765. NUM_BONE_INFLUENCERS: number;
  13766. BonesPerMesh: number;
  13767. INSTANCES: boolean;
  13768. GLOSSINESS: boolean;
  13769. ROUGHNESS: boolean;
  13770. EMISSIVEASILLUMINATION: boolean;
  13771. LINKEMISSIVEWITHDIFFUSE: boolean;
  13772. REFLECTIONFRESNELFROMSPECULAR: boolean;
  13773. LIGHTMAP: boolean;
  13774. LIGHTMAPDIRECTUV: number;
  13775. OBJECTSPACE_NORMALMAP: boolean;
  13776. USELIGHTMAPASSHADOWMAP: boolean;
  13777. REFLECTIONMAP_3D: boolean;
  13778. REFLECTIONMAP_SPHERICAL: boolean;
  13779. REFLECTIONMAP_PLANAR: boolean;
  13780. REFLECTIONMAP_CUBIC: boolean;
  13781. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  13782. REFLECTIONMAP_PROJECTION: boolean;
  13783. REFLECTIONMAP_SKYBOX: boolean;
  13784. REFLECTIONMAP_EXPLICIT: boolean;
  13785. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  13786. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  13787. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  13788. INVERTCUBICMAP: boolean;
  13789. LOGARITHMICDEPTH: boolean;
  13790. REFRACTION: boolean;
  13791. REFRACTIONMAP_3D: boolean;
  13792. REFLECTIONOVERALPHA: boolean;
  13793. TWOSIDEDLIGHTING: boolean;
  13794. SHADOWFLOAT: boolean;
  13795. MORPHTARGETS: boolean;
  13796. MORPHTARGETS_NORMAL: boolean;
  13797. MORPHTARGETS_TANGENT: boolean;
  13798. NUM_MORPH_INFLUENCERS: number;
  13799. NONUNIFORMSCALING: boolean;
  13800. PREMULTIPLYALPHA: boolean;
  13801. IMAGEPROCESSING: boolean;
  13802. VIGNETTE: boolean;
  13803. VIGNETTEBLENDMODEMULTIPLY: boolean;
  13804. VIGNETTEBLENDMODEOPAQUE: boolean;
  13805. TONEMAPPING: boolean;
  13806. CONTRAST: boolean;
  13807. COLORCURVES: boolean;
  13808. COLORGRADING: boolean;
  13809. COLORGRADING3D: boolean;
  13810. SAMPLER3DGREENDEPTH: boolean;
  13811. SAMPLER3DBGRMAP: boolean;
  13812. IMAGEPROCESSINGPOSTPROCESS: boolean;
  13813. /**
  13814. * If the reflection texture on this material is in linear color space
  13815. * @hidden
  13816. */
  13817. IS_REFLECTION_LINEAR: boolean;
  13818. /**
  13819. * If the refraction texture on this material is in linear color space
  13820. * @hidden
  13821. */
  13822. IS_REFRACTION_LINEAR: boolean;
  13823. EXPOSURE: boolean;
  13824. constructor();
  13825. setReflectionMode(modeToEnable: string): void;
  13826. }
  13827. class StandardMaterial extends PushMaterial {
  13828. private _diffuseTexture;
  13829. diffuseTexture: Nullable<BaseTexture>;
  13830. private _ambientTexture;
  13831. ambientTexture: Nullable<BaseTexture>;
  13832. private _opacityTexture;
  13833. opacityTexture: Nullable<BaseTexture>;
  13834. private _reflectionTexture;
  13835. reflectionTexture: Nullable<BaseTexture>;
  13836. private _emissiveTexture;
  13837. emissiveTexture: Nullable<BaseTexture>;
  13838. private _specularTexture;
  13839. specularTexture: Nullable<BaseTexture>;
  13840. private _bumpTexture;
  13841. bumpTexture: Nullable<BaseTexture>;
  13842. private _lightmapTexture;
  13843. lightmapTexture: Nullable<BaseTexture>;
  13844. private _refractionTexture;
  13845. refractionTexture: Nullable<BaseTexture>;
  13846. ambientColor: Color3;
  13847. diffuseColor: Color3;
  13848. specularColor: Color3;
  13849. emissiveColor: Color3;
  13850. specularPower: number;
  13851. private _useAlphaFromDiffuseTexture;
  13852. useAlphaFromDiffuseTexture: boolean;
  13853. private _useEmissiveAsIllumination;
  13854. useEmissiveAsIllumination: boolean;
  13855. private _linkEmissiveWithDiffuse;
  13856. linkEmissiveWithDiffuse: boolean;
  13857. private _useSpecularOverAlpha;
  13858. useSpecularOverAlpha: boolean;
  13859. private _useReflectionOverAlpha;
  13860. useReflectionOverAlpha: boolean;
  13861. private _disableLighting;
  13862. disableLighting: boolean;
  13863. private _useObjectSpaceNormalMap;
  13864. /**
  13865. * Allows using an object space normal map (instead of tangent space).
  13866. */
  13867. useObjectSpaceNormalMap: boolean;
  13868. private _useParallax;
  13869. useParallax: boolean;
  13870. private _useParallaxOcclusion;
  13871. useParallaxOcclusion: boolean;
  13872. parallaxScaleBias: number;
  13873. private _roughness;
  13874. roughness: number;
  13875. indexOfRefraction: number;
  13876. invertRefractionY: boolean;
  13877. /**
  13878. * Defines the alpha limits in alpha test mode
  13879. */
  13880. alphaCutOff: number;
  13881. private _useLightmapAsShadowmap;
  13882. useLightmapAsShadowmap: boolean;
  13883. private _diffuseFresnelParameters;
  13884. diffuseFresnelParameters: FresnelParameters;
  13885. private _opacityFresnelParameters;
  13886. opacityFresnelParameters: FresnelParameters;
  13887. private _reflectionFresnelParameters;
  13888. reflectionFresnelParameters: FresnelParameters;
  13889. private _refractionFresnelParameters;
  13890. refractionFresnelParameters: FresnelParameters;
  13891. private _emissiveFresnelParameters;
  13892. emissiveFresnelParameters: FresnelParameters;
  13893. private _useReflectionFresnelFromSpecular;
  13894. useReflectionFresnelFromSpecular: boolean;
  13895. private _useGlossinessFromSpecularMapAlpha;
  13896. useGlossinessFromSpecularMapAlpha: boolean;
  13897. private _maxSimultaneousLights;
  13898. maxSimultaneousLights: number;
  13899. /**
  13900. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  13901. */
  13902. private _invertNormalMapX;
  13903. invertNormalMapX: boolean;
  13904. /**
  13905. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  13906. */
  13907. private _invertNormalMapY;
  13908. invertNormalMapY: boolean;
  13909. /**
  13910. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  13911. */
  13912. private _twoSidedLighting;
  13913. twoSidedLighting: boolean;
  13914. /**
  13915. * Default configuration related to image processing available in the standard Material.
  13916. */
  13917. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  13918. /**
  13919. * Gets the image processing configuration used either in this material.
  13920. */
  13921. /**
  13922. * Sets the Default image processing configuration used either in the this material.
  13923. *
  13924. * If sets to null, the scene one is in use.
  13925. */
  13926. imageProcessingConfiguration: ImageProcessingConfiguration;
  13927. /**
  13928. * Keep track of the image processing observer to allow dispose and replace.
  13929. */
  13930. private _imageProcessingObserver;
  13931. /**
  13932. * Attaches a new image processing configuration to the Standard Material.
  13933. * @param configuration
  13934. */
  13935. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  13936. /**
  13937. * Gets wether the color curves effect is enabled.
  13938. */
  13939. /**
  13940. * Sets wether the color curves effect is enabled.
  13941. */
  13942. cameraColorCurvesEnabled: boolean;
  13943. /**
  13944. * Gets wether the color grading effect is enabled.
  13945. */
  13946. /**
  13947. * Gets wether the color grading effect is enabled.
  13948. */
  13949. cameraColorGradingEnabled: boolean;
  13950. /**
  13951. * Gets wether tonemapping is enabled or not.
  13952. */
  13953. /**
  13954. * Sets wether tonemapping is enabled or not
  13955. */
  13956. cameraToneMappingEnabled: boolean;
  13957. /**
  13958. * The camera exposure used on this material.
  13959. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  13960. * This corresponds to a photographic exposure.
  13961. */
  13962. /**
  13963. * The camera exposure used on this material.
  13964. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  13965. * This corresponds to a photographic exposure.
  13966. */
  13967. cameraExposure: number;
  13968. /**
  13969. * Gets The camera contrast used on this material.
  13970. */
  13971. /**
  13972. * Sets The camera contrast used on this material.
  13973. */
  13974. cameraContrast: number;
  13975. /**
  13976. * Gets the Color Grading 2D Lookup Texture.
  13977. */
  13978. /**
  13979. * Sets the Color Grading 2D Lookup Texture.
  13980. */
  13981. cameraColorGradingTexture: Nullable<BaseTexture>;
  13982. /**
  13983. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  13984. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  13985. * 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;
  13986. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  13987. */
  13988. /**
  13989. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  13990. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  13991. * 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;
  13992. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  13993. */
  13994. cameraColorCurves: Nullable<ColorCurves>;
  13995. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  13996. protected _renderTargets: SmartArray<RenderTargetTexture>;
  13997. protected _worldViewProjectionMatrix: Matrix;
  13998. protected _globalAmbientColor: Color3;
  13999. protected _useLogarithmicDepth: boolean;
  14000. constructor(name: string, scene: Scene);
  14001. getClassName(): string;
  14002. useLogarithmicDepth: boolean;
  14003. needAlphaBlending(): boolean;
  14004. needAlphaTesting(): boolean;
  14005. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  14006. getAlphaTestTexture(): Nullable<BaseTexture>;
  14007. /**
  14008. * Child classes can use it to update shaders
  14009. */
  14010. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  14011. buildUniformLayout(): void;
  14012. unbind(): void;
  14013. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14014. getAnimatables(): IAnimatable[];
  14015. getActiveTextures(): BaseTexture[];
  14016. hasTexture(texture: BaseTexture): boolean;
  14017. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14018. clone(name: string): StandardMaterial;
  14019. serialize(): any;
  14020. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  14021. static _DiffuseTextureEnabled: boolean;
  14022. static DiffuseTextureEnabled: boolean;
  14023. static _AmbientTextureEnabled: boolean;
  14024. static AmbientTextureEnabled: boolean;
  14025. static _OpacityTextureEnabled: boolean;
  14026. static OpacityTextureEnabled: boolean;
  14027. static _ReflectionTextureEnabled: boolean;
  14028. static ReflectionTextureEnabled: boolean;
  14029. static _EmissiveTextureEnabled: boolean;
  14030. static EmissiveTextureEnabled: boolean;
  14031. static _SpecularTextureEnabled: boolean;
  14032. static SpecularTextureEnabled: boolean;
  14033. static _BumpTextureEnabled: boolean;
  14034. static BumpTextureEnabled: boolean;
  14035. static _LightmapTextureEnabled: boolean;
  14036. static LightmapTextureEnabled: boolean;
  14037. static _RefractionTextureEnabled: boolean;
  14038. static RefractionTextureEnabled: boolean;
  14039. static _ColorGradingTextureEnabled: boolean;
  14040. static ColorGradingTextureEnabled: boolean;
  14041. static _FresnelEnabled: boolean;
  14042. static FresnelEnabled: boolean;
  14043. }
  14044. }
  14045. declare module BABYLON {
  14046. class UniformBuffer {
  14047. private _engine;
  14048. private _buffer;
  14049. private _data;
  14050. private _bufferData;
  14051. private _dynamic?;
  14052. private _uniformLocations;
  14053. private _uniformSizes;
  14054. private _uniformLocationPointer;
  14055. private _needSync;
  14056. private _noUBO;
  14057. private _currentEffect;
  14058. private static _MAX_UNIFORM_SIZE;
  14059. private static _tempBuffer;
  14060. /**
  14061. * Wrapper for updateUniform.
  14062. * @method updateMatrix3x3
  14063. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14064. * @param {Float32Array} matrix
  14065. */
  14066. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  14067. /**
  14068. * Wrapper for updateUniform.
  14069. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14070. * @param {Float32Array} matrix
  14071. */
  14072. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  14073. /**
  14074. * Wrapper for updateUniform.
  14075. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14076. * @param {number} x
  14077. */
  14078. updateFloat: (name: string, x: number) => void;
  14079. /**
  14080. * Wrapper for updateUniform.
  14081. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14082. * @param {number} x
  14083. * @param {number} y
  14084. * @param {string} [suffix] Suffix to add to the uniform name.
  14085. */
  14086. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  14087. /**
  14088. * Wrapper for updateUniform.
  14089. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14090. * @param {number} x
  14091. * @param {number} y
  14092. * @param {number} z
  14093. * @param {string} [suffix] Suffix to add to the uniform name.
  14094. */
  14095. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  14096. /**
  14097. * Wrapper for updateUniform.
  14098. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14099. * @param {number} x
  14100. * @param {number} y
  14101. * @param {number} z
  14102. * @param {number} w
  14103. * @param {string} [suffix] Suffix to add to the uniform name.
  14104. */
  14105. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  14106. /**
  14107. * Wrapper for updateUniform.
  14108. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14109. * @param {Matrix} A 4x4 matrix.
  14110. */
  14111. updateMatrix: (name: string, mat: Matrix) => void;
  14112. /**
  14113. * Wrapper for updateUniform.
  14114. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14115. * @param {Vector3} vector
  14116. */
  14117. updateVector3: (name: string, vector: Vector3) => void;
  14118. /**
  14119. * Wrapper for updateUniform.
  14120. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14121. * @param {Vector4} vector
  14122. */
  14123. updateVector4: (name: string, vector: Vector4) => void;
  14124. /**
  14125. * Wrapper for updateUniform.
  14126. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14127. * @param {Color3} color
  14128. * @param {string} [suffix] Suffix to add to the uniform name.
  14129. */
  14130. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  14131. /**
  14132. * Wrapper for updateUniform.
  14133. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14134. * @param {Color3} color
  14135. * @param {number} alpha
  14136. * @param {string} [suffix] Suffix to add to the uniform name.
  14137. */
  14138. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  14139. /**
  14140. * Uniform buffer objects.
  14141. *
  14142. * Handles blocks of uniform on the GPU.
  14143. *
  14144. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  14145. *
  14146. * For more information, please refer to :
  14147. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  14148. */
  14149. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  14150. /**
  14151. * Indicates if the buffer is using the WebGL2 UBO implementation,
  14152. * or just falling back on setUniformXXX calls.
  14153. */
  14154. readonly useUbo: boolean;
  14155. /**
  14156. * Indicates if the WebGL underlying uniform buffer is in sync
  14157. * with the javascript cache data.
  14158. */
  14159. readonly isSync: boolean;
  14160. /**
  14161. * Indicates if the WebGL underlying uniform buffer is dynamic.
  14162. * Also, a dynamic UniformBuffer will disable cache verification and always
  14163. * update the underlying WebGL uniform buffer to the GPU.
  14164. */
  14165. isDynamic(): boolean;
  14166. /**
  14167. * The data cache on JS side.
  14168. */
  14169. getData(): Float32Array;
  14170. /**
  14171. * The underlying WebGL Uniform buffer.
  14172. */
  14173. getBuffer(): Nullable<WebGLBuffer>;
  14174. /**
  14175. * std140 layout specifies how to align data within an UBO structure.
  14176. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  14177. * for specs.
  14178. */
  14179. private _fillAlignment(size);
  14180. /**
  14181. * Adds an uniform in the buffer.
  14182. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  14183. * for the layout to be correct !
  14184. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14185. * @param {number|number[]} size Data size, or data directly.
  14186. */
  14187. addUniform(name: string, size: number | 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 {Matrix} mat A 4x4 matrix.
  14192. */
  14193. addMatrix(name: string, mat: Matrix): 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 {number} x
  14198. * @param {number} y
  14199. */
  14200. addFloat2(name: string, x: number, y: 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 {number} x
  14205. * @param {number} y
  14206. * @param {number} z
  14207. */
  14208. addFloat3(name: string, x: number, y: number, z: number): void;
  14209. /**
  14210. * Wrapper for addUniform.
  14211. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14212. * @param {Color3} color
  14213. */
  14214. addColor3(name: string, color: Color3): void;
  14215. /**
  14216. * Wrapper for addUniform.
  14217. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14218. * @param {Color3} color
  14219. * @param {number} alpha
  14220. */
  14221. addColor4(name: string, color: Color3, alpha: number): void;
  14222. /**
  14223. * Wrapper for addUniform.
  14224. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14225. * @param {Vector3} vector
  14226. */
  14227. addVector3(name: string, vector: Vector3): void;
  14228. /**
  14229. * Wrapper for addUniform.
  14230. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14231. */
  14232. addMatrix3x3(name: string): void;
  14233. /**
  14234. * Wrapper for addUniform.
  14235. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14236. */
  14237. addMatrix2x2(name: string): void;
  14238. /**
  14239. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  14240. */
  14241. create(): void;
  14242. _rebuild(): void;
  14243. /**
  14244. * Updates the WebGL Uniform Buffer on the GPU.
  14245. * If the `dynamic` flag is set to true, no cache comparison is done.
  14246. * Otherwise, the buffer will be updated only if the cache differs.
  14247. */
  14248. update(): void;
  14249. /**
  14250. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  14251. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  14252. * @param {number[]|Float32Array} data Flattened data
  14253. * @param {number} size Size of the data.
  14254. */
  14255. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  14256. private _updateMatrix3x3ForUniform(name, matrix);
  14257. private _updateMatrix3x3ForEffect(name, matrix);
  14258. private _updateMatrix2x2ForEffect(name, matrix);
  14259. private _updateMatrix2x2ForUniform(name, matrix);
  14260. private _updateFloatForEffect(name, x);
  14261. private _updateFloatForUniform(name, x);
  14262. private _updateFloat2ForEffect(name, x, y, suffix?);
  14263. private _updateFloat2ForUniform(name, x, y, suffix?);
  14264. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  14265. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  14266. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  14267. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  14268. private _updateMatrixForEffect(name, mat);
  14269. private _updateMatrixForUniform(name, mat);
  14270. private _updateVector3ForEffect(name, vector);
  14271. private _updateVector3ForUniform(name, vector);
  14272. private _updateVector4ForEffect(name, vector);
  14273. private _updateVector4ForUniform(name, vector);
  14274. private _updateColor3ForEffect(name, color, suffix?);
  14275. private _updateColor3ForUniform(name, color, suffix?);
  14276. private _updateColor4ForEffect(name, color, alpha, suffix?);
  14277. private _updateColor4ForUniform(name, color, alpha, suffix?);
  14278. /**
  14279. * Sets a sampler uniform on the effect.
  14280. * @param {string} name Name of the sampler.
  14281. * @param {Texture} texture
  14282. */
  14283. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  14284. /**
  14285. * Directly updates the value of the uniform in the cache AND on the GPU.
  14286. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  14287. * @param {number[]|Float32Array} data Flattened data
  14288. */
  14289. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  14290. /**
  14291. * Binds this uniform buffer to an effect.
  14292. * @param {Effect} effect
  14293. * @param {string} name Name of the uniform block in the shader.
  14294. */
  14295. bindToEffect(effect: Effect, name: string): void;
  14296. /**
  14297. * Disposes the uniform buffer.
  14298. */
  14299. dispose(): void;
  14300. }
  14301. }
  14302. declare module BABYLON {
  14303. class Scalar {
  14304. /**
  14305. * Two pi constants convenient for computation.
  14306. */
  14307. static TwoPi: number;
  14308. /**
  14309. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  14310. */
  14311. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  14312. /**
  14313. * Returns a string : the upper case translation of the number i to hexadecimal.
  14314. */
  14315. static ToHex(i: number): string;
  14316. /**
  14317. * Returns -1 if value is negative and +1 is value is positive.
  14318. * Returns the value itself if it's equal to zero.
  14319. */
  14320. static Sign(value: number): number;
  14321. /**
  14322. * Returns the value itself if it's between min and max.
  14323. * Returns min if the value is lower than min.
  14324. * Returns max if the value is greater than max.
  14325. */
  14326. static Clamp(value: number, min?: number, max?: number): number;
  14327. /**
  14328. * Returns the log2 of value.
  14329. */
  14330. static Log2(value: number): number;
  14331. /**
  14332. * Loops the value, so that it is never larger than length and never smaller than 0.
  14333. *
  14334. * This is similar to the modulo operator but it works with floating point numbers.
  14335. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  14336. * With t = 5 and length = 2.5, the result would be 0.0.
  14337. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  14338. */
  14339. static Repeat(value: number, length: number): number;
  14340. /**
  14341. * Normalize the value between 0.0 and 1.0 using min and max values
  14342. */
  14343. static Normalize(value: number, min: number, max: number): number;
  14344. /**
  14345. * Denormalize the value from 0.0 and 1.0 using min and max values
  14346. */
  14347. static Denormalize(normalized: number, min: number, max: number): number;
  14348. /**
  14349. * Calculates the shortest difference between two given angles given in degrees.
  14350. */
  14351. static DeltaAngle(current: number, target: number): number;
  14352. /**
  14353. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  14354. *
  14355. * The returned value will move back and forth between 0 and length
  14356. */
  14357. static PingPong(tx: number, length: number): number;
  14358. /**
  14359. * Interpolates between min and max with smoothing at the limits.
  14360. *
  14361. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  14362. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  14363. */
  14364. static SmoothStep(from: number, to: number, tx: number): number;
  14365. /**
  14366. * Moves a value current towards target.
  14367. *
  14368. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  14369. * Negative values of maxDelta pushes the value away from target.
  14370. */
  14371. static MoveTowards(current: number, target: number, maxDelta: number): number;
  14372. /**
  14373. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  14374. *
  14375. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  14376. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  14377. */
  14378. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  14379. /**
  14380. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  14381. */
  14382. static Lerp(start: number, end: number, amount: number): number;
  14383. /**
  14384. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  14385. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  14386. */
  14387. static LerpAngle(start: number, end: number, amount: number): number;
  14388. /**
  14389. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  14390. */
  14391. static InverseLerp(a: number, b: number, value: number): number;
  14392. /**
  14393. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  14394. */
  14395. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  14396. /**
  14397. * Returns a random float number between and min and max values
  14398. */
  14399. static RandomRange(min: number, max: number): number;
  14400. /**
  14401. * This function returns percentage of a number in a given range.
  14402. *
  14403. * RangeToPercent(40,20,60) will return 0.5 (50%)
  14404. * RangeToPercent(34,0,100) will return 0.34 (34%)
  14405. */
  14406. static RangeToPercent(number: number, min: number, max: number): number;
  14407. /**
  14408. * This function returns number that corresponds to the percentage in a given range.
  14409. *
  14410. * PercentToRange(0.34,0,100) will return 34.
  14411. */
  14412. static PercentToRange(percent: number, min: number, max: number): number;
  14413. /**
  14414. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  14415. * @param angle The angle to normalize in radian.
  14416. * @return The converted angle.
  14417. */
  14418. static NormalizeRadians(angle: number): number;
  14419. }
  14420. }
  14421. declare module BABYLON {
  14422. const ToGammaSpace: number;
  14423. const ToLinearSpace = 2.2;
  14424. const Epsilon = 0.001;
  14425. /**
  14426. * Class used to hold a RBG color
  14427. */
  14428. class Color3 {
  14429. /**
  14430. * Defines the red component (between 0 and 1, default is 0)
  14431. */
  14432. r: number;
  14433. /**
  14434. * Defines the green component (between 0 and 1, default is 0)
  14435. */
  14436. g: number;
  14437. /**
  14438. * Defines the blue component (between 0 and 1, default is 0)
  14439. */
  14440. b: number;
  14441. /**
  14442. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  14443. * @param r defines the red component (between 0 and 1, default is 0)
  14444. * @param g defines the green component (between 0 and 1, default is 0)
  14445. * @param b defines the blue component (between 0 and 1, default is 0)
  14446. */
  14447. constructor(
  14448. /**
  14449. * Defines the red component (between 0 and 1, default is 0)
  14450. */
  14451. r?: number,
  14452. /**
  14453. * Defines the green component (between 0 and 1, default is 0)
  14454. */
  14455. g?: number,
  14456. /**
  14457. * Defines the blue component (between 0 and 1, default is 0)
  14458. */
  14459. b?: number);
  14460. /**
  14461. * Creates a string with the Color3 current values
  14462. * @returns the string representation of the Color3 object
  14463. */
  14464. toString(): string;
  14465. /**
  14466. * Returns the string "Color3"
  14467. * @returns "Color3"
  14468. */
  14469. getClassName(): string;
  14470. /**
  14471. * Compute the Color3 hash code
  14472. * @returns an unique number that can be used to hash Color3 objects
  14473. */
  14474. getHashCode(): number;
  14475. /**
  14476. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  14477. * @param array defines the array where to store the r,g,b components
  14478. * @param index defines an optional index in the target array to define where to start storing values
  14479. * @returns the current Color3 object
  14480. */
  14481. toArray(array: FloatArray, index?: number): Color3;
  14482. /**
  14483. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  14484. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  14485. * @returns a new {BABYLON.Color4} object
  14486. */
  14487. toColor4(alpha?: number): Color4;
  14488. /**
  14489. * Returns a new array populated with 3 numeric elements : red, green and blue values
  14490. * @returns the new array
  14491. */
  14492. asArray(): number[];
  14493. /**
  14494. * Returns the luminance value
  14495. * @returns a float value
  14496. */
  14497. toLuminance(): number;
  14498. /**
  14499. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  14500. * @param otherColor defines the second operand
  14501. * @returns the new Color3 object
  14502. */
  14503. multiply(otherColor: Color3): Color3;
  14504. /**
  14505. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  14506. * @param otherColor defines the second operand
  14507. * @param result defines the Color3 object where to store the result
  14508. * @returns the current Color3
  14509. */
  14510. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  14511. /**
  14512. * Determines equality between Color3 objects
  14513. * @param otherColor defines the second operand
  14514. * @returns true if the rgb values are equal to the given ones
  14515. */
  14516. equals(otherColor: Color3): boolean;
  14517. /**
  14518. * Determines equality between the current Color3 object and a set of r,b,g values
  14519. * @param r defines the red component to check
  14520. * @param g defines the green component to check
  14521. * @param b defines the blue component to check
  14522. * @returns true if the rgb values are equal to the given ones
  14523. */
  14524. equalsFloats(r: number, g: number, b: number): boolean;
  14525. /**
  14526. * Multiplies in place each rgb value by scale
  14527. * @param scale defines the scaling factor
  14528. * @returns the updated Color3
  14529. */
  14530. scale(scale: number): Color3;
  14531. /**
  14532. * Multiplies the rgb values by scale and stores the result into "result"
  14533. * @param scale defines the scaling factor
  14534. * @param result defines the Color3 object where to store the result
  14535. * @returns the unmodified current Color3
  14536. */
  14537. scaleToRef(scale: number, result: Color3): Color3;
  14538. /**
  14539. * Scale the current Color3 values by a factor and add the result to a given Color3
  14540. * @param scale defines the scale factor
  14541. * @param result defines color to store the result into
  14542. * @returns the unmodified current Color3
  14543. */
  14544. scaleAndAddToRef(scale: number, result: Color3): Color3;
  14545. /**
  14546. * Clamps the rgb values by the min and max values and stores the result into "result"
  14547. * @param min defines minimum clamping value (default is 0)
  14548. * @param max defines maximum clamping value (default is 1)
  14549. * @param result defines color to store the result into
  14550. * @returns the original Color3
  14551. */
  14552. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  14553. /**
  14554. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  14555. * @param otherColor defines the second operand
  14556. * @returns the new Color3
  14557. */
  14558. add(otherColor: Color3): Color3;
  14559. /**
  14560. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  14561. * @param otherColor defines the second operand
  14562. * @param result defines Color3 object to store the result into
  14563. * @returns the unmodified current Color3
  14564. */
  14565. addToRef(otherColor: Color3, result: Color3): Color3;
  14566. /**
  14567. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  14568. * @param otherColor defines the second operand
  14569. * @returns the new Color3
  14570. */
  14571. subtract(otherColor: Color3): Color3;
  14572. /**
  14573. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  14574. * @param otherColor defines the second operand
  14575. * @param result defines Color3 object to store the result into
  14576. * @returns the unmodified current Color3
  14577. */
  14578. subtractToRef(otherColor: Color3, result: Color3): Color3;
  14579. /**
  14580. * Copy the current object
  14581. * @returns a new Color3 copied the current one
  14582. */
  14583. clone(): Color3;
  14584. /**
  14585. * Copies the rgb values from the source in the current Color3
  14586. * @param source defines the source Color3 object
  14587. * @returns the updated Color3 object
  14588. */
  14589. copyFrom(source: Color3): Color3;
  14590. /**
  14591. * Updates the Color3 rgb values from the given floats
  14592. * @param r defines the red component to read from
  14593. * @param g defines the green component to read from
  14594. * @param b defines the blue component to read from
  14595. * @returns the current Color3 object
  14596. */
  14597. copyFromFloats(r: number, g: number, b: number): Color3;
  14598. /**
  14599. * Updates the Color3 rgb values from the given floats
  14600. * @param r defines the red component to read from
  14601. * @param g defines the green component to read from
  14602. * @param b defines the blue component to read from
  14603. * @returns the current Color3 object
  14604. */
  14605. set(r: number, g: number, b: number): Color3;
  14606. /**
  14607. * Compute the Color3 hexadecimal code as a string
  14608. * @returns a string containing the hexadecimal representation of the Color3 object
  14609. */
  14610. toHexString(): string;
  14611. /**
  14612. * Computes a new Color3 converted from the current one to linear space
  14613. * @returns a new Color3 object
  14614. */
  14615. toLinearSpace(): Color3;
  14616. /**
  14617. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  14618. * @param convertedColor defines the Color3 object where to store the linear space version
  14619. * @returns the unmodified Color3
  14620. */
  14621. toLinearSpaceToRef(convertedColor: Color3): Color3;
  14622. /**
  14623. * Computes a new Color3 converted from the current one to gamma space
  14624. * @returns a new Color3 object
  14625. */
  14626. toGammaSpace(): Color3;
  14627. /**
  14628. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  14629. * @param convertedColor defines the Color3 object where to store the gamma space version
  14630. * @returns the unmodified Color3
  14631. */
  14632. toGammaSpaceToRef(convertedColor: Color3): Color3;
  14633. /**
  14634. * Creates a new Color3 from the string containing valid hexadecimal values
  14635. * @param hex defines a string containing valid hexadecimal values
  14636. * @returns a new Color3 object
  14637. */
  14638. static FromHexString(hex: string): Color3;
  14639. /**
  14640. * Creates a new Vector3 from the starting index of the given array
  14641. * @param array defines the source array
  14642. * @param offset defines an offset in the source array
  14643. * @returns a new Color3 object
  14644. */
  14645. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  14646. /**
  14647. * Creates a new Color3 from integer values (< 256)
  14648. * @param r defines the red component to read from (value between 0 and 255)
  14649. * @param g defines the green component to read from (value between 0 and 255)
  14650. * @param b defines the blue component to read from (value between 0 and 255)
  14651. * @returns a new Color3 object
  14652. */
  14653. static FromInts(r: number, g: number, b: number): Color3;
  14654. /**
  14655. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  14656. * @param start defines the start Color3 value
  14657. * @param end defines the end Color3 value
  14658. * @param amount defines the gradient value between start and end
  14659. * @returns a new Color3 object
  14660. */
  14661. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  14662. /**
  14663. * Returns a Color3 value containing a red color
  14664. * @returns a new Color3 object
  14665. */
  14666. static Red(): Color3;
  14667. /**
  14668. * Returns a Color3 value containing a green color
  14669. * @returns a new Color3 object
  14670. */
  14671. static Green(): Color3;
  14672. /**
  14673. * Returns a Color3 value containing a blue color
  14674. * @returns a new Color3 object
  14675. */
  14676. static Blue(): Color3;
  14677. /**
  14678. * Returns a Color3 value containing a black color
  14679. * @returns a new Color3 object
  14680. */
  14681. static Black(): Color3;
  14682. /**
  14683. * Returns a Color3 value containing a white color
  14684. * @returns a new Color3 object
  14685. */
  14686. static White(): Color3;
  14687. /**
  14688. * Returns a Color3 value containing a purple color
  14689. * @returns a new Color3 object
  14690. */
  14691. static Purple(): Color3;
  14692. /**
  14693. * Returns a Color3 value containing a magenta color
  14694. * @returns a new Color3 object
  14695. */
  14696. static Magenta(): Color3;
  14697. /**
  14698. * Returns a Color3 value containing a yellow color
  14699. * @returns a new Color3 object
  14700. */
  14701. static Yellow(): Color3;
  14702. /**
  14703. * Returns a Color3 value containing a gray color
  14704. * @returns a new Color3 object
  14705. */
  14706. static Gray(): Color3;
  14707. /**
  14708. * Returns a Color3 value containing a teal color
  14709. * @returns a new Color3 object
  14710. */
  14711. static Teal(): Color3;
  14712. /**
  14713. * Returns a Color3 value containing a random color
  14714. * @returns a new Color3 object
  14715. */
  14716. static Random(): Color3;
  14717. }
  14718. /**
  14719. * Class used to hold a RBGA color
  14720. */
  14721. class Color4 {
  14722. /**
  14723. * Defines the red component (between 0 and 1, default is 0)
  14724. */
  14725. r: number;
  14726. /**
  14727. * Defines the green component (between 0 and 1, default is 0)
  14728. */
  14729. g: number;
  14730. /**
  14731. * Defines the blue component (between 0 and 1, default is 0)
  14732. */
  14733. b: number;
  14734. /**
  14735. * Defines the alpha component (between 0 and 1, default is 1)
  14736. */
  14737. a: number;
  14738. /**
  14739. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  14740. * @param r defines the red component (between 0 and 1, default is 0)
  14741. * @param g defines the green component (between 0 and 1, default is 0)
  14742. * @param b defines the blue component (between 0 and 1, default is 0)
  14743. * @param a defines the alpha component (between 0 and 1, default is 1)
  14744. */
  14745. constructor(
  14746. /**
  14747. * Defines the red component (between 0 and 1, default is 0)
  14748. */
  14749. r?: number,
  14750. /**
  14751. * Defines the green component (between 0 and 1, default is 0)
  14752. */
  14753. g?: number,
  14754. /**
  14755. * Defines the blue component (between 0 and 1, default is 0)
  14756. */
  14757. b?: number,
  14758. /**
  14759. * Defines the alpha component (between 0 and 1, default is 1)
  14760. */
  14761. a?: number);
  14762. /**
  14763. * Adds in place the given Color4 values to the current Color4 object
  14764. * @param right defines the second operand
  14765. * @returns the current updated Color4 object
  14766. */
  14767. addInPlace(right: Color4): Color4;
  14768. /**
  14769. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  14770. * @returns the new array
  14771. */
  14772. asArray(): number[];
  14773. /**
  14774. * Stores from the starting index in the given array the Color4 successive values
  14775. * @param array defines the array where to store the r,g,b components
  14776. * @param index defines an optional index in the target array to define where to start storing values
  14777. * @returns the current Color4 object
  14778. */
  14779. toArray(array: number[], index?: number): Color4;
  14780. /**
  14781. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  14782. * @param right defines the second operand
  14783. * @returns a new Color4 object
  14784. */
  14785. add(right: Color4): Color4;
  14786. /**
  14787. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  14788. * @param right defines the second operand
  14789. * @returns a new Color4 object
  14790. */
  14791. subtract(right: Color4): Color4;
  14792. /**
  14793. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  14794. * @param right defines the second operand
  14795. * @param result defines the Color4 object where to store the result
  14796. * @returns the current Color4 object
  14797. */
  14798. subtractToRef(right: Color4, result: Color4): Color4;
  14799. /**
  14800. * Creates a new Color4 with the current Color4 values multiplied by scale
  14801. * @param scale defines the scaling factor to apply
  14802. * @returns a new Color4 object
  14803. */
  14804. scale(scale: number): Color4;
  14805. /**
  14806. * Multiplies the current Color4 values by scale and stores the result in "result"
  14807. * @param scale defines the scaling factor to apply
  14808. * @param result defines the Color4 object where to store the result
  14809. * @returns the current unmodified Color4
  14810. */
  14811. scaleToRef(scale: number, result: Color4): Color4;
  14812. /**
  14813. * Scale the current Color4 values by a factor and add the result to a given Color4
  14814. * @param scale defines the scale factor
  14815. * @param result defines the Color4 object where to store the result
  14816. * @returns the unmodified current Color4
  14817. */
  14818. scaleAndAddToRef(scale: number, result: Color4): Color4;
  14819. /**
  14820. * Clamps the rgb values by the min and max values and stores the result into "result"
  14821. * @param min defines minimum clamping value (default is 0)
  14822. * @param max defines maximum clamping value (default is 1)
  14823. * @param result defines color to store the result into.
  14824. * @returns the cuurent Color4
  14825. */
  14826. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  14827. /**
  14828. * Multipy an Color4 value by another and return a new Color4 object
  14829. * @param color defines the Color4 value to multiply by
  14830. * @returns a new Color4 object
  14831. */
  14832. multiply(color: Color4): Color4;
  14833. /**
  14834. * Multipy a Color4 value by another and push the result in a reference value
  14835. * @param color defines the Color4 value to multiply by
  14836. * @param result defines the Color4 to fill the result in
  14837. * @returns the result Color4
  14838. */
  14839. multiplyToRef(color: Color4, result: Color4): Color4;
  14840. /**
  14841. * Creates a string with the Color4 current values
  14842. * @returns the string representation of the Color4 object
  14843. */
  14844. toString(): string;
  14845. /**
  14846. * Returns the string "Color4"
  14847. * @returns "Color4"
  14848. */
  14849. getClassName(): string;
  14850. /**
  14851. * Compute the Color4 hash code
  14852. * @returns an unique number that can be used to hash Color4 objects
  14853. */
  14854. getHashCode(): number;
  14855. /**
  14856. * Creates a new Color4 copied from the current one
  14857. * @returns a new Color4 object
  14858. */
  14859. clone(): Color4;
  14860. /**
  14861. * Copies the given Color4 values into the current one
  14862. * @param source defines the source Color4 object
  14863. * @returns the current updated Color4 object
  14864. */
  14865. copyFrom(source: Color4): Color4;
  14866. /**
  14867. * Copies the given float values into the current one
  14868. * @param r defines the red component to read from
  14869. * @param g defines the green component to read from
  14870. * @param b defines the blue component to read from
  14871. * @param a defines the alpha component to read from
  14872. * @returns the current updated Color4 object
  14873. */
  14874. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  14875. /**
  14876. * Copies the given float values into the current one
  14877. * @param r defines the red component to read from
  14878. * @param g defines the green component to read from
  14879. * @param b defines the blue component to read from
  14880. * @param a defines the alpha component to read from
  14881. * @returns the current updated Color4 object
  14882. */
  14883. set(r: number, g: number, b: number, a: number): Color4;
  14884. /**
  14885. * Compute the Color4 hexadecimal code as a string
  14886. * @returns a string containing the hexadecimal representation of the Color4 object
  14887. */
  14888. toHexString(): string;
  14889. /**
  14890. * Computes a new Color4 converted from the current one to linear space
  14891. * @returns a new Color4 object
  14892. */
  14893. toLinearSpace(): Color4;
  14894. /**
  14895. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  14896. * @param convertedColor defines the Color4 object where to store the linear space version
  14897. * @returns the unmodified Color4
  14898. */
  14899. toLinearSpaceToRef(convertedColor: Color4): Color4;
  14900. /**
  14901. * Computes a new Color4 converted from the current one to gamma space
  14902. * @returns a new Color4 object
  14903. */
  14904. toGammaSpace(): Color4;
  14905. /**
  14906. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  14907. * @param convertedColor defines the Color4 object where to store the gamma space version
  14908. * @returns the unmodified Color4
  14909. */
  14910. toGammaSpaceToRef(convertedColor: Color4): Color4;
  14911. /**
  14912. * Creates a new Color4 from the string containing valid hexadecimal values
  14913. * @param hex defines a string containing valid hexadecimal values
  14914. * @returns a new Color4 object
  14915. */
  14916. static FromHexString(hex: string): Color4;
  14917. /**
  14918. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  14919. * @param left defines the start value
  14920. * @param right defines the end value
  14921. * @param amount defines the gradient factor
  14922. * @returns a new Color4 object
  14923. */
  14924. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  14925. /**
  14926. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  14927. * @param left defines the start value
  14928. * @param right defines the end value
  14929. * @param amount defines the gradient factor
  14930. * @param result defines the Color4 object where to store data
  14931. */
  14932. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  14933. /**
  14934. * Creates a new Color4 from the starting index element of the given array
  14935. * @param array defines the source array to read from
  14936. * @param offset defines the offset in the source array
  14937. * @returns a new Color4 object
  14938. */
  14939. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  14940. /**
  14941. * Creates a new Color3 from integer values (< 256)
  14942. * @param r defines the red component to read from (value between 0 and 255)
  14943. * @param g defines the green component to read from (value between 0 and 255)
  14944. * @param b defines the blue component to read from (value between 0 and 255)
  14945. * @param a defines the alpha component to read from (value between 0 and 255)
  14946. * @returns a new Color3 object
  14947. */
  14948. static FromInts(r: number, g: number, b: number, a: number): Color4;
  14949. /**
  14950. * Check the content of a given array and convert it to an array containing RGBA data
  14951. * If the original array was already containing count * 4 values then it is returned directly
  14952. * @param colors defines the array to check
  14953. * @param count defines the number of RGBA data to expect
  14954. * @returns an array containing count * 4 values (RGBA)
  14955. */
  14956. static CheckColors4(colors: number[], count: number): number[];
  14957. }
  14958. /**
  14959. * Class representing a vector containing 2 coordinates
  14960. */
  14961. class Vector2 {
  14962. /** defines the first coordinate */
  14963. x: number;
  14964. /** defines the second coordinate */
  14965. y: number;
  14966. /**
  14967. * Creates a new Vector2 from the given x and y coordinates
  14968. * @param x defines the first coordinate
  14969. * @param y defines the second coordinate
  14970. */
  14971. constructor(
  14972. /** defines the first coordinate */
  14973. x: number,
  14974. /** defines the second coordinate */
  14975. y: number);
  14976. /**
  14977. * Gets a string with the Vector2 coordinates
  14978. * @returns a string with the Vector2 coordinates
  14979. */
  14980. toString(): string;
  14981. /**
  14982. * Gets class name
  14983. * @returns the string "Vector2"
  14984. */
  14985. getClassName(): string;
  14986. /**
  14987. * Gets current vector hash code
  14988. * @returns the Vector2 hash code as a number
  14989. */
  14990. getHashCode(): number;
  14991. /**
  14992. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  14993. * @param array defines the source array
  14994. * @param index defines the offset in source array
  14995. * @returns the current Vector2
  14996. */
  14997. toArray(array: FloatArray, index?: number): Vector2;
  14998. /**
  14999. * Copy the current vector to an array
  15000. * @returns a new array with 2 elements: the Vector2 coordinates.
  15001. */
  15002. asArray(): number[];
  15003. /**
  15004. * Sets the Vector2 coordinates with the given Vector2 coordinates
  15005. * @param source defines the source Vector2
  15006. * @returns the current updated Vector2
  15007. */
  15008. copyFrom(source: Vector2): Vector2;
  15009. /**
  15010. * Sets the Vector2 coordinates with the given floats
  15011. * @param x defines the first coordinate
  15012. * @param y defines the second coordinate
  15013. * @returns the current updated Vector2
  15014. */
  15015. copyFromFloats(x: number, y: number): Vector2;
  15016. /**
  15017. * Sets the Vector2 coordinates with the given floats
  15018. * @param x defines the first coordinate
  15019. * @param y defines the second coordinate
  15020. * @returns the current updated Vector2
  15021. */
  15022. set(x: number, y: number): Vector2;
  15023. /**
  15024. * Add another vector with the current one
  15025. * @param otherVector defines the other vector
  15026. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  15027. */
  15028. add(otherVector: Vector2): Vector2;
  15029. /**
  15030. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  15031. * @param otherVector defines the other vector
  15032. * @param result defines the target vector
  15033. * @returns the unmodified current Vector2
  15034. */
  15035. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  15036. /**
  15037. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  15038. * @param otherVector defines the other vector
  15039. * @returns the current updated Vector2
  15040. */
  15041. addInPlace(otherVector: Vector2): Vector2;
  15042. /**
  15043. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  15044. * @param otherVector defines the other vector
  15045. * @returns a new Vector2
  15046. */
  15047. addVector3(otherVector: Vector3): Vector2;
  15048. /**
  15049. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  15050. * @param otherVector defines the other vector
  15051. * @returns a new Vector2
  15052. */
  15053. subtract(otherVector: Vector2): Vector2;
  15054. /**
  15055. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  15056. * @param otherVector defines the other vector
  15057. * @param result defines the target vector
  15058. * @returns the unmodified current Vector2
  15059. */
  15060. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  15061. /**
  15062. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  15063. * @param otherVector defines the other vector
  15064. * @returns the current updated Vector2
  15065. */
  15066. subtractInPlace(otherVector: Vector2): Vector2;
  15067. /**
  15068. * Multiplies in place the current Vector2 coordinates by the given ones
  15069. * @param otherVector defines the other vector
  15070. * @returns the current updated Vector2
  15071. */
  15072. multiplyInPlace(otherVector: Vector2): Vector2;
  15073. /**
  15074. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  15075. * @param otherVector defines the other vector
  15076. * @returns a new Vector2
  15077. */
  15078. multiply(otherVector: Vector2): Vector2;
  15079. /**
  15080. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  15081. * @param otherVector defines the other vector
  15082. * @param result defines the target vector
  15083. * @returns the unmodified current Vector2
  15084. */
  15085. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  15086. /**
  15087. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  15088. * @param x defines the first coordinate
  15089. * @param y defines the second coordinate
  15090. * @returns a new Vector2
  15091. */
  15092. multiplyByFloats(x: number, y: number): Vector2;
  15093. /**
  15094. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  15095. * @param otherVector defines the other vector
  15096. * @returns a new Vector2
  15097. */
  15098. divide(otherVector: Vector2): Vector2;
  15099. /**
  15100. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  15101. * @param otherVector defines the other vector
  15102. * @param result defines the target vector
  15103. * @returns the unmodified current Vector2
  15104. */
  15105. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  15106. /**
  15107. * Divides the current Vector3 coordinates by the given ones
  15108. * @param otherVector defines the other vector
  15109. * @returns the current updated Vector2
  15110. */
  15111. divideInPlace(otherVector: Vector2): Vector2;
  15112. /**
  15113. * Gets a new Vector2 with current Vector2 negated coordinates
  15114. * @returns a new Vector2
  15115. */
  15116. negate(): Vector2;
  15117. /**
  15118. * Multiply the Vector2 coordinates by scale
  15119. * @param scale defines the scaling factor
  15120. * @returns the current updated Vector2
  15121. */
  15122. scaleInPlace(scale: number): Vector2;
  15123. /**
  15124. * Returns a new Vector2 scaled by "scale" from the current Vector2
  15125. * @param scale defines the scaling factor
  15126. * @returns a new Vector2
  15127. */
  15128. scale(scale: number): Vector2;
  15129. /**
  15130. * Scale the current Vector2 values by a factor to a given Vector2
  15131. * @param scale defines the scale factor
  15132. * @param result defines the Vector2 object where to store the result
  15133. * @returns the unmodified current Vector2
  15134. */
  15135. scaleToRef(scale: number, result: Vector2): Vector2;
  15136. /**
  15137. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  15138. * @param scale defines the scale factor
  15139. * @param result defines the Vector2 object where to store the result
  15140. * @returns the unmodified current Vector2
  15141. */
  15142. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  15143. /**
  15144. * Gets a boolean if two vectors are equals
  15145. * @param otherVector defines the other vector
  15146. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  15147. */
  15148. equals(otherVector: Vector2): boolean;
  15149. /**
  15150. * Gets a boolean if two vectors are equals (using an epsilon value)
  15151. * @param otherVector defines the other vector
  15152. * @param epsilon defines the minimal distance to consider equality
  15153. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  15154. */
  15155. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  15156. /**
  15157. * Gets the length of the vector
  15158. * @returns the vector length (float)
  15159. */
  15160. length(): number;
  15161. /**
  15162. * Gets the vector squared length
  15163. * @returns the vector squared length (float)
  15164. */
  15165. lengthSquared(): number;
  15166. /**
  15167. * Normalize the vector
  15168. * @returns the current updated Vector2
  15169. */
  15170. normalize(): Vector2;
  15171. /**
  15172. * Gets a new Vector2 copied from the Vector2
  15173. * @returns a new Vector2
  15174. */
  15175. clone(): Vector2;
  15176. /**
  15177. * Gets a new Vector2(0, 0)
  15178. * @returns a new Vector2
  15179. */
  15180. static Zero(): Vector2;
  15181. /**
  15182. * Gets a new Vector2(1, 1)
  15183. * @returns a new Vector2
  15184. */
  15185. static One(): Vector2;
  15186. /**
  15187. * Gets a new Vector2 set from the given index element of the given array
  15188. * @param array defines the data source
  15189. * @param offset defines the offset in the data source
  15190. * @returns a new Vector2
  15191. */
  15192. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  15193. /**
  15194. * Sets "result" from the given index element of the given array
  15195. * @param array defines the data source
  15196. * @param offset defines the offset in the data source
  15197. * @param result defines the target vector
  15198. */
  15199. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  15200. /**
  15201. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  15202. * @param value1 defines 1st point of control
  15203. * @param value2 defines 2nd point of control
  15204. * @param value3 defines 3rd point of control
  15205. * @param value4 defines 4th point of control
  15206. * @param amount defines the interpolation factor
  15207. * @returns a new Vector2
  15208. */
  15209. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  15210. /**
  15211. * 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".
  15212. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  15213. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  15214. * @param value defines the value to clamp
  15215. * @param min defines the lower limit
  15216. * @param max defines the upper limit
  15217. * @returns a new Vector2
  15218. */
  15219. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  15220. /**
  15221. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  15222. * @param value1 defines the 1st control point
  15223. * @param tangent1 defines the outgoing tangent
  15224. * @param value2 defines the 2nd control point
  15225. * @param tangent2 defines the incoming tangent
  15226. * @param amount defines the interpolation factor
  15227. * @returns a new Vector2
  15228. */
  15229. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  15230. /**
  15231. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  15232. * @param start defines the start vector
  15233. * @param end defines the end vector
  15234. * @param amount defines the interpolation factor
  15235. * @returns a new Vector2
  15236. */
  15237. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  15238. /**
  15239. * Gets the dot product of the vector "left" and the vector "right"
  15240. * @param left defines first vector
  15241. * @param right defines second vector
  15242. * @returns the dot product (float)
  15243. */
  15244. static Dot(left: Vector2, right: Vector2): number;
  15245. /**
  15246. * Returns a new Vector2 equal to the normalized given vector
  15247. * @param vector defines the vector to normalize
  15248. * @returns a new Vector2
  15249. */
  15250. static Normalize(vector: Vector2): Vector2;
  15251. /**
  15252. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  15253. * @param left defines 1st vector
  15254. * @param right defines 2nd vector
  15255. * @returns a new Vector2
  15256. */
  15257. static Minimize(left: Vector2, right: Vector2): Vector2;
  15258. /**
  15259. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  15260. * @param left defines 1st vector
  15261. * @param right defines 2nd vector
  15262. * @returns a new Vector2
  15263. */
  15264. static Maximize(left: Vector2, right: Vector2): Vector2;
  15265. /**
  15266. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  15267. * @param vector defines the vector to transform
  15268. * @param transformation defines the matrix to apply
  15269. * @returns a new Vector2
  15270. */
  15271. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  15272. /**
  15273. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  15274. * @param vector defines the vector to transform
  15275. * @param transformation defines the matrix to apply
  15276. * @param result defines the target vector
  15277. */
  15278. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  15279. /**
  15280. * Determines if a given vector is included in a triangle
  15281. * @param p defines the vector to test
  15282. * @param p0 defines 1st triangle point
  15283. * @param p1 defines 2nd triangle point
  15284. * @param p2 defines 3rd triangle point
  15285. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  15286. */
  15287. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  15288. /**
  15289. * Gets the distance between the vectors "value1" and "value2"
  15290. * @param value1 defines first vector
  15291. * @param value2 defines second vector
  15292. * @returns the distance between vectors
  15293. */
  15294. static Distance(value1: Vector2, value2: Vector2): number;
  15295. /**
  15296. * Returns the squared distance between the vectors "value1" and "value2"
  15297. * @param value1 defines first vector
  15298. * @param value2 defines second vector
  15299. * @returns the squared distance between vectors
  15300. */
  15301. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  15302. /**
  15303. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  15304. * @param value1 defines first vector
  15305. * @param value2 defines second vector
  15306. * @returns a new Vector2
  15307. */
  15308. static Center(value1: Vector2, value2: Vector2): Vector2;
  15309. /**
  15310. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  15311. * @param p defines the middle point
  15312. * @param segA defines one point of the segment
  15313. * @param segB defines the other point of the segment
  15314. * @returns the shortest distance
  15315. */
  15316. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  15317. }
  15318. /**
  15319. * Classed used to store (x,y,z) vector representation
  15320. * A Vector3 is the main object used in 3D geometry
  15321. * It can represent etiher the coordinates of a point the space, either a direction
  15322. * Reminder: Babylon.js uses a left handed forward facing system
  15323. */
  15324. class Vector3 {
  15325. /**
  15326. * Defines the first coordinates (on X axis)
  15327. */
  15328. x: number;
  15329. /**
  15330. * Defines the second coordinates (on Y axis)
  15331. */
  15332. y: number;
  15333. /**
  15334. * Defines the third coordinates (on Z axis)
  15335. */
  15336. z: number;
  15337. /**
  15338. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  15339. * @param x defines the first coordinates (on X axis)
  15340. * @param y defines the second coordinates (on Y axis)
  15341. * @param z defines the third coordinates (on Z axis)
  15342. */
  15343. constructor(
  15344. /**
  15345. * Defines the first coordinates (on X axis)
  15346. */
  15347. x: number,
  15348. /**
  15349. * Defines the second coordinates (on Y axis)
  15350. */
  15351. y: number,
  15352. /**
  15353. * Defines the third coordinates (on Z axis)
  15354. */
  15355. z: number);
  15356. /**
  15357. * Creates a string representation of the Vector3
  15358. * @returns a string with the Vector3 coordinates.
  15359. */
  15360. toString(): string;
  15361. /**
  15362. * Gets the class name
  15363. * @returns the string "Vector3"
  15364. */
  15365. getClassName(): string;
  15366. /**
  15367. * Creates the Vector3 hash code
  15368. * @returns a number which tends to be unique between Vector3 instances
  15369. */
  15370. getHashCode(): number;
  15371. /**
  15372. * Creates an array containing three elements : the coordinates of the Vector3
  15373. * @returns a new array of numbers
  15374. */
  15375. asArray(): number[];
  15376. /**
  15377. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  15378. * @param array defines the destination array
  15379. * @param index defines the offset in the destination array
  15380. * @returns the current Vector3
  15381. */
  15382. toArray(array: FloatArray, index?: number): Vector3;
  15383. /**
  15384. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  15385. * @returns a new Quaternion object, computed from the Vector3 coordinates
  15386. */
  15387. toQuaternion(): Quaternion;
  15388. /**
  15389. * Adds the given vector to the current Vector3
  15390. * @param otherVector defines the second operand
  15391. * @returns the current updated Vector3
  15392. */
  15393. addInPlace(otherVector: Vector3): Vector3;
  15394. /**
  15395. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  15396. * @param otherVector defines the second operand
  15397. * @returns the resulting Vector3
  15398. */
  15399. add(otherVector: Vector3): Vector3;
  15400. /**
  15401. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  15402. * @param otherVector defines the second operand
  15403. * @param result defines the Vector3 object where to store the result
  15404. * @returns the current Vector3
  15405. */
  15406. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  15407. /**
  15408. * Subtract the given vector from the current Vector3
  15409. * @param otherVector defines the second operand
  15410. * @returns the current updated Vector3
  15411. */
  15412. subtractInPlace(otherVector: Vector3): Vector3;
  15413. /**
  15414. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  15415. * @param otherVector defines the second operand
  15416. * @returns the resulting Vector3
  15417. */
  15418. subtract(otherVector: Vector3): Vector3;
  15419. /**
  15420. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  15421. * @param otherVector defines the second operand
  15422. * @param result defines the Vector3 object where to store the result
  15423. * @returns the current Vector3
  15424. */
  15425. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  15426. /**
  15427. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  15428. * @param x defines the x coordinate of the operand
  15429. * @param y defines the y coordinate of the operand
  15430. * @param z defines the z coordinate of the operand
  15431. * @returns the resulting Vector3
  15432. */
  15433. subtractFromFloats(x: number, y: number, z: number): Vector3;
  15434. /**
  15435. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  15436. * @param x defines the x coordinate of the operand
  15437. * @param y defines the y coordinate of the operand
  15438. * @param z defines the z coordinate of the operand
  15439. * @param result defines the Vector3 object where to store the result
  15440. * @returns the current Vector3
  15441. */
  15442. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  15443. /**
  15444. * Gets a new Vector3 set with the current Vector3 negated coordinates
  15445. * @returns a new Vector3
  15446. */
  15447. negate(): Vector3;
  15448. /**
  15449. * Multiplies the Vector3 coordinates by the float "scale"
  15450. * @param scale defines the multiplier factor
  15451. * @returns the current updated Vector3
  15452. */
  15453. scaleInPlace(scale: number): Vector3;
  15454. /**
  15455. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  15456. * @param scale defines the multiplier factor
  15457. * @returns a new Vector3
  15458. */
  15459. scale(scale: number): Vector3;
  15460. /**
  15461. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  15462. * @param scale defines the multiplier factor
  15463. * @param result defines the Vector3 object where to store the result
  15464. * @returns the current Vector3
  15465. */
  15466. scaleToRef(scale: number, result: Vector3): Vector3;
  15467. /**
  15468. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  15469. * @param scale defines the scale factor
  15470. * @param result defines the Vector3 object where to store the result
  15471. * @returns the unmodified current Vector3
  15472. */
  15473. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  15474. /**
  15475. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  15476. * @param otherVector defines the second operand
  15477. * @returns true if both vectors are equals
  15478. */
  15479. equals(otherVector: Vector3): boolean;
  15480. /**
  15481. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  15482. * @param otherVector defines the second operand
  15483. * @param epsilon defines the minimal distance to define values as equals
  15484. * @returns true if both vectors are distant less than epsilon
  15485. */
  15486. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  15487. /**
  15488. * Returns true if the current Vector3 coordinates equals the given floats
  15489. * @param x defines the x coordinate of the operand
  15490. * @param y defines the y coordinate of the operand
  15491. * @param z defines the z coordinate of the operand
  15492. * @returns true if both vectors are equals
  15493. */
  15494. equalsToFloats(x: number, y: number, z: number): boolean;
  15495. /**
  15496. * Multiplies the current Vector3 coordinates by the given ones
  15497. * @param otherVector defines the second operand
  15498. * @returns the current updated Vector3
  15499. */
  15500. multiplyInPlace(otherVector: Vector3): Vector3;
  15501. /**
  15502. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  15503. * @param otherVector defines the second operand
  15504. * @returns the new Vector3
  15505. */
  15506. multiply(otherVector: Vector3): Vector3;
  15507. /**
  15508. * Multiplies the current Vector3 by the given one 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. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  15514. /**
  15515. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  15516. * @param x defines the x coordinate of the operand
  15517. * @param y defines the y coordinate of the operand
  15518. * @param z defines the z coordinate of the operand
  15519. * @returns the new Vector3
  15520. */
  15521. multiplyByFloats(x: number, y: number, z: number): Vector3;
  15522. /**
  15523. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  15524. * @param otherVector defines the second operand
  15525. * @returns the new Vector3
  15526. */
  15527. divide(otherVector: Vector3): Vector3;
  15528. /**
  15529. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  15530. * @param otherVector defines the second operand
  15531. * @param result defines the Vector3 object where to store the result
  15532. * @returns the current Vector3
  15533. */
  15534. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  15535. /**
  15536. * Divides the current Vector3 coordinates by the given ones.
  15537. * @param otherVector defines the second operand
  15538. * @returns the current updated Vector3
  15539. */
  15540. divideInPlace(otherVector: Vector3): Vector3;
  15541. /**
  15542. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  15543. * @param other defines the second operand
  15544. * @returns the current updated Vector3
  15545. */
  15546. minimizeInPlace(other: Vector3): Vector3;
  15547. /**
  15548. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  15549. * @param other defines the second operand
  15550. * @returns the current updated Vector3
  15551. */
  15552. maximizeInPlace(other: Vector3): Vector3;
  15553. /**
  15554. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  15555. */
  15556. readonly isNonUniform: boolean;
  15557. /**
  15558. * Gets the length of the Vector3
  15559. * @returns the length of the Vecto3
  15560. */
  15561. length(): number;
  15562. /**
  15563. * Gets the squared length of the Vector3
  15564. * @returns squared length of the Vector3
  15565. */
  15566. lengthSquared(): number;
  15567. /**
  15568. * Normalize the current Vector3.
  15569. * Please note that this is an in place operation.
  15570. * @returns the current updated Vector3
  15571. */
  15572. normalize(): Vector3;
  15573. /**
  15574. * Normalize the current Vector3 to a new vector
  15575. * @returns the new Vector3
  15576. */
  15577. normalizeToNew(): Vector3;
  15578. /**
  15579. * Normalize the current Vector3 to the reference
  15580. * @param reference define the Vector3 to update
  15581. * @returns the updated Vector3
  15582. */
  15583. normalizeToRef(reference: Vector3): Vector3;
  15584. /**
  15585. * Creates a new Vector3 copied from the current Vector3
  15586. * @returns the new Vector3
  15587. */
  15588. clone(): Vector3;
  15589. /**
  15590. * Copies the given vector coordinates to the current Vector3 ones
  15591. * @param source defines the source Vector3
  15592. * @returns the current updated Vector3
  15593. */
  15594. copyFrom(source: Vector3): Vector3;
  15595. /**
  15596. * Copies the given floats to the current Vector3 coordinates
  15597. * @param x defines the x coordinate of the operand
  15598. * @param y defines the y coordinate of the operand
  15599. * @param z defines the z coordinate of the operand
  15600. * @returns the current updated Vector3
  15601. */
  15602. copyFromFloats(x: number, y: number, z: number): Vector3;
  15603. /**
  15604. * Copies the given floats to the current Vector3 coordinates
  15605. * @param x defines the x coordinate of the operand
  15606. * @param y defines the y coordinate of the operand
  15607. * @param z defines the z coordinate of the operand
  15608. * @returns the current updated Vector3
  15609. */
  15610. set(x: number, y: number, z: number): Vector3;
  15611. /**
  15612. * Get the clip factor between two vectors
  15613. * @param vector0 defines the first operand
  15614. * @param vector1 defines the second operand
  15615. * @param axis defines the axis to use
  15616. * @param size defines the size along the axis
  15617. * @returns the clip factor
  15618. */
  15619. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  15620. /**
  15621. * Get angle between two vectors
  15622. * @param vector0 angle between vector0 and vector1
  15623. * @param vector1 angle between vector0 and vector1
  15624. * @param normal direction of the normal
  15625. * @return the angle between vector0 and vector1
  15626. */
  15627. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  15628. /**
  15629. * Returns a new Vector3 set from the index "offset" of the given array
  15630. * @param array defines the source array
  15631. * @param offset defines the offset in the source array
  15632. * @returns the new Vector3
  15633. */
  15634. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  15635. /**
  15636. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  15637. * This function is deprecated. Use FromArray instead
  15638. * @param array defines the source array
  15639. * @param offset defines the offset in the source array
  15640. * @returns the new Vector3
  15641. */
  15642. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  15643. /**
  15644. * Sets the given vector "result" with the element values from the index "offset" of the given array
  15645. * @param array defines the source array
  15646. * @param offset defines the offset in the source array
  15647. * @param result defines the Vector3 where to store the result
  15648. */
  15649. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  15650. /**
  15651. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  15652. * This function is deprecated. Use FromArrayToRef instead.
  15653. * @param array defines the source array
  15654. * @param offset defines the offset in the source array
  15655. * @param result defines the Vector3 where to store the result
  15656. */
  15657. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  15658. /**
  15659. * Sets the given vector "result" with the given floats.
  15660. * @param x defines the x coordinate of the source
  15661. * @param y defines the y coordinate of the source
  15662. * @param z defines the z coordinate of the source
  15663. * @param result defines the Vector3 where to store the result
  15664. */
  15665. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  15666. /**
  15667. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  15668. * @returns a new empty Vector3
  15669. */
  15670. static Zero(): Vector3;
  15671. /**
  15672. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  15673. * @returns a new unit Vector3
  15674. */
  15675. static One(): Vector3;
  15676. /**
  15677. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  15678. * @returns a new up Vector3
  15679. */
  15680. static Up(): Vector3;
  15681. /**
  15682. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  15683. * @returns a new forward Vector3
  15684. */
  15685. static Forward(): Vector3;
  15686. /**
  15687. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  15688. * @returns a new right Vector3
  15689. */
  15690. static Right(): Vector3;
  15691. /**
  15692. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  15693. * @returns a new left Vector3
  15694. */
  15695. static Left(): Vector3;
  15696. /**
  15697. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  15698. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  15699. * @param vector defines the Vector3 to transform
  15700. * @param transformation defines the transformation matrix
  15701. * @returns the transformed Vector3
  15702. */
  15703. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  15704. /**
  15705. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  15706. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  15707. * @param vector defines the Vector3 to transform
  15708. * @param transformation defines the transformation matrix
  15709. * @param result defines the Vector3 where to store the result
  15710. */
  15711. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  15712. /**
  15713. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  15714. * This method computes tranformed coordinates only, not transformed direction vectors
  15715. * @param x define the x coordinate of the source vector
  15716. * @param y define the y coordinate of the source vector
  15717. * @param z define the z coordinate of the source vector
  15718. * @param transformation defines the transformation matrix
  15719. * @param result defines the Vector3 where to store the result
  15720. */
  15721. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  15722. /**
  15723. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  15724. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  15725. * @param vector defines the Vector3 to transform
  15726. * @param transformation defines the transformation matrix
  15727. * @returns the new Vector3
  15728. */
  15729. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  15730. /**
  15731. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  15732. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  15733. * @param vector defines the Vector3 to transform
  15734. * @param transformation defines the transformation matrix
  15735. * @param result defines the Vector3 where to store the result
  15736. */
  15737. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  15738. /**
  15739. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  15740. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  15741. * @param x define the x coordinate of the source vector
  15742. * @param y define the y coordinate of the source vector
  15743. * @param z define the z coordinate of the source vector
  15744. * @param transformation defines the transformation matrix
  15745. * @param result defines the Vector3 where to store the result
  15746. */
  15747. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  15748. /**
  15749. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  15750. * @param value1 defines the first control point
  15751. * @param value2 defines the second control point
  15752. * @param value3 defines the third control point
  15753. * @param value4 defines the fourth control point
  15754. * @param amount defines the amount on the spline to use
  15755. * @returns the new Vector3
  15756. */
  15757. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  15758. /**
  15759. * 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"
  15760. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  15761. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  15762. * @param value defines the current value
  15763. * @param min defines the lower range value
  15764. * @param max defines the upper range value
  15765. * @returns the new Vector3
  15766. */
  15767. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  15768. /**
  15769. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  15770. * @param value1 defines the first control point
  15771. * @param tangent1 defines the first tangent vector
  15772. * @param value2 defines the second control point
  15773. * @param tangent2 defines the second tangent vector
  15774. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  15775. * @returns the new Vector3
  15776. */
  15777. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  15778. /**
  15779. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  15780. * @param start defines the start value
  15781. * @param end defines the end value
  15782. * @param amount max defines amount between both (between 0 and 1)
  15783. * @returns the new Vector3
  15784. */
  15785. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  15786. /**
  15787. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  15788. * @param start defines the start value
  15789. * @param end defines the end value
  15790. * @param amount max defines amount between both (between 0 and 1)
  15791. * @param result defines the Vector3 where to store the result
  15792. */
  15793. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  15794. /**
  15795. * Returns the dot product (float) between the vectors "left" and "right"
  15796. * @param left defines the left operand
  15797. * @param right defines the right operand
  15798. * @returns the dot product
  15799. */
  15800. static Dot(left: Vector3, right: Vector3): number;
  15801. /**
  15802. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  15803. * The cross product is then orthogonal to both "left" and "right"
  15804. * @param left defines the left operand
  15805. * @param right defines the right operand
  15806. * @returns the cross product
  15807. */
  15808. static Cross(left: Vector3, right: Vector3): Vector3;
  15809. /**
  15810. * Sets the given vector "result" with the cross product of "left" and "right"
  15811. * The cross product is then orthogonal to both "left" and "right"
  15812. * @param left defines the left operand
  15813. * @param right defines the right operand
  15814. * @param result defines the Vector3 where to store the result
  15815. */
  15816. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  15817. /**
  15818. * Returns a new Vector3 as the normalization of the given vector
  15819. * @param vector defines the Vector3 to normalize
  15820. * @returns the new Vector3
  15821. */
  15822. static Normalize(vector: Vector3): Vector3;
  15823. /**
  15824. * Sets the given vector "result" with the normalization of the given first vector
  15825. * @param vector defines the Vector3 to normalize
  15826. * @param result defines the Vector3 where to store the result
  15827. */
  15828. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  15829. private static _viewportMatrixCache;
  15830. /**
  15831. * Project a Vector3 onto screen space
  15832. * @param vector defines the Vector3 to project
  15833. * @param world defines the world matrix to use
  15834. * @param transform defines the transform (view x projection) matrix to use
  15835. * @param viewport defines the screen viewport to use
  15836. * @returns the new Vector3
  15837. */
  15838. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): 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 transform defines the transform (view x projection) matrix to use
  15846. * @returns the new Vector3
  15847. */
  15848. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  15849. /**
  15850. * Unproject from screen space to object space
  15851. * @param source defines the screen space Vector3 to use
  15852. * @param viewportWidth defines the current width of the viewport
  15853. * @param viewportHeight defines the current height of the viewport
  15854. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  15855. * @param view defines the view matrix to use
  15856. * @param projection defines the projection matrix to use
  15857. * @returns the new Vector3
  15858. */
  15859. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  15860. /**
  15861. * Unproject from screen space to object space
  15862. * @param source defines the screen space Vector3 to use
  15863. * @param viewportWidth defines the current width of the viewport
  15864. * @param viewportHeight defines the current height of the viewport
  15865. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  15866. * @param view defines the view matrix to use
  15867. * @param projection defines the projection matrix to use
  15868. * @param result defines the Vector3 where to store the result
  15869. */
  15870. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  15871. /**
  15872. * Unproject from screen space to object space
  15873. * @param sourceX defines the screen space x coordinate to use
  15874. * @param sourceY defines the screen space y coordinate to use
  15875. * @param sourceZ defines the screen space z coordinate to use
  15876. * @param viewportWidth defines the current width of the viewport
  15877. * @param viewportHeight defines the current height of the viewport
  15878. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  15879. * @param view defines the view matrix to use
  15880. * @param projection defines the projection matrix to use
  15881. * @param result defines the Vector3 where to store the result
  15882. */
  15883. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  15884. /**
  15885. * Gets the minimal coordinate values between two Vector3
  15886. * @param left defines the first operand
  15887. * @param right defines the second operand
  15888. * @returns the new Vector3
  15889. */
  15890. static Minimize(left: Vector3, right: Vector3): Vector3;
  15891. /**
  15892. * Gets the maximal coordinate values between two Vector3
  15893. * @param left defines the first operand
  15894. * @param right defines the second operand
  15895. * @returns the new Vector3
  15896. */
  15897. static Maximize(left: Vector3, right: Vector3): Vector3;
  15898. /**
  15899. * Returns the distance between the vectors "value1" and "value2"
  15900. * @param value1 defines the first operand
  15901. * @param value2 defines the second operand
  15902. * @returns the distance
  15903. */
  15904. static Distance(value1: Vector3, value2: Vector3): number;
  15905. /**
  15906. * Returns the squared distance between the vectors "value1" and "value2"
  15907. * @param value1 defines the first operand
  15908. * @param value2 defines the second operand
  15909. * @returns the squared distance
  15910. */
  15911. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  15912. /**
  15913. * Returns a new Vector3 located at the center between "value1" and "value2"
  15914. * @param value1 defines the first operand
  15915. * @param value2 defines the second operand
  15916. * @returns the new Vector3
  15917. */
  15918. static Center(value1: Vector3, value2: Vector3): Vector3;
  15919. /**
  15920. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  15921. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  15922. * to something in order to rotate it from its local system to the given target system
  15923. * Note: axis1, axis2 and axis3 are normalized during this operation
  15924. * @param axis1 defines the first axis
  15925. * @param axis2 defines the second axis
  15926. * @param axis3 defines the third axis
  15927. * @returns a new Vector3
  15928. */
  15929. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  15930. /**
  15931. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  15932. * @param axis1 defines the first axis
  15933. * @param axis2 defines the second axis
  15934. * @param axis3 defines the third axis
  15935. * @param ref defines the Vector3 where to store the result
  15936. */
  15937. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  15938. }
  15939. class Vector4 {
  15940. x: number;
  15941. y: number;
  15942. z: number;
  15943. w: number;
  15944. /**
  15945. * Creates a Vector4 object from the given floats.
  15946. */
  15947. constructor(x: number, y: number, z: number, w: number);
  15948. /**
  15949. * Returns the string with the Vector4 coordinates.
  15950. */
  15951. toString(): string;
  15952. /**
  15953. * Returns the string "Vector4".
  15954. */
  15955. getClassName(): string;
  15956. /**
  15957. * Returns the Vector4 hash code.
  15958. */
  15959. getHashCode(): number;
  15960. /**
  15961. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  15962. */
  15963. asArray(): number[];
  15964. /**
  15965. * Populates the given array from the given index with the Vector4 coordinates.
  15966. * Returns the Vector4.
  15967. */
  15968. toArray(array: FloatArray, index?: number): Vector4;
  15969. /**
  15970. * Adds the given vector to the current Vector4.
  15971. * Returns the updated Vector4.
  15972. */
  15973. addInPlace(otherVector: Vector4): Vector4;
  15974. /**
  15975. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  15976. */
  15977. add(otherVector: Vector4): Vector4;
  15978. /**
  15979. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  15980. * Returns the current Vector4.
  15981. */
  15982. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  15983. /**
  15984. * Subtract in place the given vector from the current Vector4.
  15985. * Returns the updated Vector4.
  15986. */
  15987. subtractInPlace(otherVector: Vector4): Vector4;
  15988. /**
  15989. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  15990. */
  15991. subtract(otherVector: Vector4): Vector4;
  15992. /**
  15993. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  15994. * Returns the current Vector4.
  15995. */
  15996. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  15997. /**
  15998. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  15999. */
  16000. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16001. /**
  16002. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  16003. * Returns the current Vector4.
  16004. */
  16005. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  16006. /**
  16007. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  16008. */
  16009. negate(): Vector4;
  16010. /**
  16011. * Multiplies the current Vector4 coordinates by scale (float).
  16012. * Returns the updated Vector4.
  16013. */
  16014. scaleInPlace(scale: number): Vector4;
  16015. /**
  16016. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  16017. */
  16018. scale(scale: number): Vector4;
  16019. /**
  16020. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  16021. * Returns the current Vector4.
  16022. */
  16023. scaleToRef(scale: number, result: Vector4): Vector4;
  16024. /**
  16025. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  16026. * @param scale defines the scale factor
  16027. * @param result defines the Vector4 object where to store the result
  16028. * @returns the unmodified current Vector4
  16029. */
  16030. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  16031. /**
  16032. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  16033. */
  16034. equals(otherVector: Vector4): boolean;
  16035. /**
  16036. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  16037. */
  16038. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  16039. /**
  16040. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  16041. */
  16042. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  16043. /**
  16044. * Multiplies in place the current Vector4 by the given one.
  16045. * Returns the updated Vector4.
  16046. */
  16047. multiplyInPlace(otherVector: Vector4): Vector4;
  16048. /**
  16049. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  16050. */
  16051. multiply(otherVector: Vector4): Vector4;
  16052. /**
  16053. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  16054. * Returns the current Vector4.
  16055. */
  16056. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  16057. /**
  16058. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  16059. */
  16060. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  16061. /**
  16062. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  16063. */
  16064. divide(otherVector: Vector4): Vector4;
  16065. /**
  16066. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  16067. * Returns the current Vector4.
  16068. */
  16069. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  16070. /**
  16071. * Divides the current Vector3 coordinates by the given ones.
  16072. * @returns the updated Vector3.
  16073. */
  16074. divideInPlace(otherVector: Vector4): Vector4;
  16075. /**
  16076. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  16077. * @param other defines the second operand
  16078. * @returns the current updated Vector4
  16079. */
  16080. minimizeInPlace(other: Vector4): Vector4;
  16081. /**
  16082. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  16083. * @param other defines the second operand
  16084. * @returns the current updated Vector4
  16085. */
  16086. maximizeInPlace(other: Vector4): Vector4;
  16087. /**
  16088. * Returns the Vector4 length (float).
  16089. */
  16090. length(): number;
  16091. /**
  16092. * Returns the Vector4 squared length (float).
  16093. */
  16094. lengthSquared(): number;
  16095. /**
  16096. * Normalizes in place the Vector4.
  16097. * Returns the updated Vector4.
  16098. */
  16099. normalize(): Vector4;
  16100. /**
  16101. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  16102. */
  16103. toVector3(): Vector3;
  16104. /**
  16105. * Returns a new Vector4 copied from the current one.
  16106. */
  16107. clone(): Vector4;
  16108. /**
  16109. * Updates the current Vector4 with the given one coordinates.
  16110. * Returns the updated Vector4.
  16111. */
  16112. copyFrom(source: Vector4): Vector4;
  16113. /**
  16114. * Updates the current Vector4 coordinates with the given floats.
  16115. * Returns the updated Vector4.
  16116. */
  16117. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16118. /**
  16119. * Updates the current Vector4 coordinates with the given floats.
  16120. * Returns the updated Vector4.
  16121. */
  16122. set(x: number, y: number, z: number, w: number): Vector4;
  16123. /**
  16124. * Returns a new Vector4 set from the starting index of the given array.
  16125. */
  16126. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  16127. /**
  16128. * Updates the given vector "result" from the starting index of the given array.
  16129. */
  16130. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  16131. /**
  16132. * Updates the given vector "result" from the starting index of the given Float32Array.
  16133. */
  16134. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  16135. /**
  16136. * Updates the given vector "result" coordinates from the given floats.
  16137. */
  16138. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  16139. /**
  16140. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  16141. */
  16142. static Zero(): Vector4;
  16143. /**
  16144. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  16145. */
  16146. static One(): Vector4;
  16147. /**
  16148. * Returns a new normalized Vector4 from the given one.
  16149. */
  16150. static Normalize(vector: Vector4): Vector4;
  16151. /**
  16152. * Updates the given vector "result" from the normalization of the given one.
  16153. */
  16154. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  16155. static Minimize(left: Vector4, right: Vector4): Vector4;
  16156. static Maximize(left: Vector4, right: Vector4): Vector4;
  16157. /**
  16158. * Returns the distance (float) between the vectors "value1" and "value2".
  16159. */
  16160. static Distance(value1: Vector4, value2: Vector4): number;
  16161. /**
  16162. * Returns the squared distance (float) between the vectors "value1" and "value2".
  16163. */
  16164. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  16165. /**
  16166. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  16167. */
  16168. static Center(value1: Vector4, value2: Vector4): Vector4;
  16169. /**
  16170. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  16171. * This methods computes transformed normalized direction vectors only.
  16172. */
  16173. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  16174. /**
  16175. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  16176. * This methods computes transformed normalized direction vectors only.
  16177. */
  16178. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  16179. /**
  16180. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  16181. * This methods computes transformed normalized direction vectors only.
  16182. */
  16183. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  16184. }
  16185. interface ISize {
  16186. width: number;
  16187. height: number;
  16188. }
  16189. class Size implements ISize {
  16190. width: number;
  16191. height: number;
  16192. /**
  16193. * Creates a Size object from the given width and height (floats).
  16194. */
  16195. constructor(width: number, height: number);
  16196. toString(): string;
  16197. /**
  16198. * Returns the string "Size"
  16199. */
  16200. getClassName(): string;
  16201. /**
  16202. * Returns the Size hash code.
  16203. */
  16204. getHashCode(): number;
  16205. /**
  16206. * Updates the current size from the given one.
  16207. * Returns the updated Size.
  16208. */
  16209. copyFrom(src: Size): void;
  16210. /**
  16211. * Updates in place the current Size from the given floats.
  16212. * Returns the updated Size.
  16213. */
  16214. copyFromFloats(width: number, height: number): Size;
  16215. /**
  16216. * Updates in place the current Size from the given floats.
  16217. * Returns the updated Size.
  16218. */
  16219. set(width: number, height: number): Size;
  16220. /**
  16221. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  16222. */
  16223. multiplyByFloats(w: number, h: number): Size;
  16224. /**
  16225. * Returns a new Size copied from the given one.
  16226. */
  16227. clone(): Size;
  16228. /**
  16229. * Boolean : True if the current Size and the given one width and height are strictly equal.
  16230. */
  16231. equals(other: Size): boolean;
  16232. /**
  16233. * Returns the surface of the Size : width * height (float).
  16234. */
  16235. readonly surface: number;
  16236. /**
  16237. * Returns a new Size set to (0.0, 0.0)
  16238. */
  16239. static Zero(): Size;
  16240. /**
  16241. * Returns a new Size set as the addition result of the current Size and the given one.
  16242. */
  16243. add(otherSize: Size): Size;
  16244. /**
  16245. * Returns a new Size set as the subtraction result of the given one from the current Size.
  16246. */
  16247. subtract(otherSize: Size): Size;
  16248. /**
  16249. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  16250. */
  16251. static Lerp(start: Size, end: Size, amount: number): Size;
  16252. }
  16253. /**
  16254. * Class used to store quaternion data
  16255. * @see https://en.wikipedia.org/wiki/Quaternion
  16256. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  16257. */
  16258. class Quaternion {
  16259. /** defines the first component (0 by default) */
  16260. x: number;
  16261. /** defines the second component (0 by default) */
  16262. y: number;
  16263. /** defines the third component (0 by default) */
  16264. z: number;
  16265. /** defines the fourth component (1.0 by default) */
  16266. w: number;
  16267. /**
  16268. * Creates a new Quaternion from the given floats
  16269. * @param x defines the first component (0 by default)
  16270. * @param y defines the second component (0 by default)
  16271. * @param z defines the third component (0 by default)
  16272. * @param w defines the fourth component (1.0 by default)
  16273. */
  16274. constructor(
  16275. /** defines the first component (0 by default) */
  16276. x?: number,
  16277. /** defines the second component (0 by default) */
  16278. y?: number,
  16279. /** defines the third component (0 by default) */
  16280. z?: number,
  16281. /** defines the fourth component (1.0 by default) */
  16282. w?: number);
  16283. /**
  16284. * Gets a string representation for the current quaternion
  16285. * @returns a string with the Quaternion coordinates
  16286. */
  16287. toString(): string;
  16288. /**
  16289. * Gets the class name of the quaternion
  16290. * @returns the string "Quaternion"
  16291. */
  16292. getClassName(): string;
  16293. /**
  16294. * Gets a hash code for this quaternion
  16295. * @returns the quaternion hash code
  16296. */
  16297. getHashCode(): number;
  16298. /**
  16299. * Copy the quaternion to an array
  16300. * @returns a new array populated with 4 elements from the quaternion coordinates
  16301. */
  16302. asArray(): number[];
  16303. /**
  16304. * Check if two quaternions are equals
  16305. * @param otherQuaternion defines the second operand
  16306. * @return true if the current quaternion and the given one coordinates are strictly equals
  16307. */
  16308. equals(otherQuaternion: Quaternion): boolean;
  16309. /**
  16310. * Clone the current quaternion
  16311. * @returns a new quaternion copied from the current one
  16312. */
  16313. clone(): Quaternion;
  16314. /**
  16315. * Copy a quaternion to the current one
  16316. * @param other defines the other quaternion
  16317. * @returns the updated current quaternion
  16318. */
  16319. copyFrom(other: Quaternion): Quaternion;
  16320. /**
  16321. * Updates the current quaternion with the given float coordinates
  16322. * @param x defines the x coordinate
  16323. * @param y defines the y coordinate
  16324. * @param z defines the z coordinate
  16325. * @param w defines the w coordinate
  16326. * @returns the updated current quaternion
  16327. */
  16328. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  16329. /**
  16330. * Updates the current quaternion from the given float coordinates
  16331. * @param x defines the x coordinate
  16332. * @param y defines the y coordinate
  16333. * @param z defines the z coordinate
  16334. * @param w defines the w coordinate
  16335. * @returns the updated current quaternion
  16336. */
  16337. set(x: number, y: number, z: number, w: number): Quaternion;
  16338. /**
  16339. * Adds two quaternions
  16340. * @param other defines the second operand
  16341. * @returns a new quaternion as the addition result of the given one and the current quaternion
  16342. */
  16343. add(other: Quaternion): Quaternion;
  16344. /**
  16345. * Add a quaternion to the current one
  16346. * @param other defines the quaternion to add
  16347. * @returns the current quaternion
  16348. */
  16349. addInPlace(other: Quaternion): Quaternion;
  16350. /**
  16351. * Subtract two quaternions
  16352. * @param other defines the second operand
  16353. * @returns a new quaternion as the subtraction result of the given one from the current one
  16354. */
  16355. subtract(other: Quaternion): Quaternion;
  16356. /**
  16357. * Multiplies the current quaternion by a scale factor
  16358. * @param value defines the scale factor
  16359. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  16360. */
  16361. scale(value: number): Quaternion;
  16362. /**
  16363. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  16364. * @param scale defines the scale factor
  16365. * @param result defines the Quaternion object where to store the result
  16366. * @returns the unmodified current quaternion
  16367. */
  16368. scaleToRef(scale: number, result: Quaternion): Quaternion;
  16369. /**
  16370. * Multiplies in place the current quaternion by a scale factor
  16371. * @param value defines the scale factor
  16372. * @returns the current modified quaternion
  16373. */
  16374. scaleInPlace(value: number): Quaternion;
  16375. /**
  16376. * Scale the current quaternion values by a factor and add the result to a given quaternion
  16377. * @param scale defines the scale factor
  16378. * @param result defines the Quaternion object where to store the result
  16379. * @returns the unmodified current quaternion
  16380. */
  16381. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  16382. /**
  16383. * Multiplies two quaternions
  16384. * @param q1 defines the second operand
  16385. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  16386. */
  16387. multiply(q1: Quaternion): Quaternion;
  16388. /**
  16389. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  16390. * @param q1 defines the second operand
  16391. * @param result defines the target quaternion
  16392. * @returns the current quaternion
  16393. */
  16394. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  16395. /**
  16396. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  16397. * @param q1 defines the second operand
  16398. * @returns the currentupdated quaternion
  16399. */
  16400. multiplyInPlace(q1: Quaternion): Quaternion;
  16401. /**
  16402. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  16403. * @param ref defines the target quaternion
  16404. * @returns the current quaternion
  16405. */
  16406. conjugateToRef(ref: Quaternion): Quaternion;
  16407. /**
  16408. * Conjugates in place (1-q) the current quaternion
  16409. * @returns the current updated quaternion
  16410. */
  16411. conjugateInPlace(): Quaternion;
  16412. /**
  16413. * Conjugates in place (1-q) the current quaternion
  16414. * @returns a new quaternion
  16415. */
  16416. conjugate(): Quaternion;
  16417. /**
  16418. * Gets length of current quaternion
  16419. * @returns the quaternion length (float)
  16420. */
  16421. length(): number;
  16422. /**
  16423. * Normalize in place the current quaternion
  16424. * @returns the current updated quaternion
  16425. */
  16426. normalize(): Quaternion;
  16427. /**
  16428. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  16429. * @param order is a reserved parameter and is ignore for now
  16430. * @returns a new Vector3 containing the Euler angles
  16431. */
  16432. toEulerAngles(order?: string): Vector3;
  16433. /**
  16434. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  16435. * @param result defines the vector which will be filled with the Euler angles
  16436. * @param order is a reserved parameter and is ignore for now
  16437. * @returns the current unchanged quaternion
  16438. */
  16439. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  16440. /**
  16441. * Updates the given rotation matrix with the current quaternion values
  16442. * @param result defines the target matrix
  16443. * @returns the current unchanged quaternion
  16444. */
  16445. toRotationMatrix(result: Matrix): Quaternion;
  16446. /**
  16447. * Updates the current quaternion from the given rotation matrix values
  16448. * @param matrix defines the source matrix
  16449. * @returns the current updated quaternion
  16450. */
  16451. fromRotationMatrix(matrix: Matrix): Quaternion;
  16452. /**
  16453. * Creates a new quaternion from a rotation matrix
  16454. * @param matrix defines the source matrix
  16455. * @returns a new quaternion created from the given rotation matrix values
  16456. */
  16457. static FromRotationMatrix(matrix: Matrix): Quaternion;
  16458. /**
  16459. * Updates the given quaternion with the given rotation matrix values
  16460. * @param matrix defines the source matrix
  16461. * @param result defines the target quaternion
  16462. */
  16463. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  16464. /**
  16465. * Returns the dot product (float) between the quaternions "left" and "right"
  16466. * @param left defines the left operand
  16467. * @param right defines the right operand
  16468. * @returns the dot product
  16469. */
  16470. static Dot(left: Quaternion, right: Quaternion): number;
  16471. /**
  16472. * Checks if the two quaternions are close to each other
  16473. * @param quat0 defines the first quaternion to check
  16474. * @param quat1 defines the second quaternion to check
  16475. * @returns true if the two quaternions are close to each other
  16476. */
  16477. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  16478. /**
  16479. * Creates an empty quaternion
  16480. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  16481. */
  16482. static Zero(): Quaternion;
  16483. /**
  16484. * Inverse a given quaternion
  16485. * @param q defines the source quaternion
  16486. * @returns a new quaternion as the inverted current quaternion
  16487. */
  16488. static Inverse(q: Quaternion): Quaternion;
  16489. /**
  16490. * Creates an identity quaternion
  16491. * @returns the identity quaternion
  16492. */
  16493. static Identity(): Quaternion;
  16494. /**
  16495. * Gets a boolean indicating if the given quaternion is identity
  16496. * @param quaternion defines the quaternion to check
  16497. * @returns true if the quaternion is identity
  16498. */
  16499. static IsIdentity(quaternion: Quaternion): boolean;
  16500. /**
  16501. * Creates a quaternion from a rotation around an axis
  16502. * @param axis defines the axis to use
  16503. * @param angle defines the angle to use
  16504. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  16505. */
  16506. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  16507. /**
  16508. * Creates a rotation around an axis and stores it into the given quaternion
  16509. * @param axis defines the axis to use
  16510. * @param angle defines the angle to use
  16511. * @param result defines the target quaternion
  16512. * @returns the target quaternion
  16513. */
  16514. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  16515. /**
  16516. * Creates a new quaternion from data stored into an array
  16517. * @param array defines the data source
  16518. * @param offset defines the offset in the source array where the data starts
  16519. * @returns a new quaternion
  16520. */
  16521. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  16522. /**
  16523. * Creates a new quaternion from the given Euler float angles (y, x, z)
  16524. * @param yaw defines the rotation around Y axis
  16525. * @param pitch defines the rotation around X axis
  16526. * @param roll defines the rotation around Z axis
  16527. * @returns the new quaternion
  16528. */
  16529. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  16530. /**
  16531. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  16532. * @param yaw defines the rotation around Y axis
  16533. * @param pitch defines the rotation around X axis
  16534. * @param roll defines the rotation around Z axis
  16535. * @param result defines the target quaternion
  16536. */
  16537. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  16538. /**
  16539. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  16540. * @param alpha defines the rotation around first axis
  16541. * @param beta defines the rotation around second axis
  16542. * @param gamma defines the rotation around third axis
  16543. * @returns the new quaternion
  16544. */
  16545. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  16546. /**
  16547. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  16548. * @param alpha defines the rotation around first axis
  16549. * @param beta defines the rotation around second axis
  16550. * @param gamma defines the rotation around third axis
  16551. * @param result defines the target quaternion
  16552. */
  16553. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  16554. /**
  16555. * 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)
  16556. * @param axis1 defines the first axis
  16557. * @param axis2 defines the second axis
  16558. * @param axis3 defines the third axis
  16559. * @returns the new quaternion
  16560. */
  16561. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  16562. /**
  16563. * 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
  16564. * @param axis1 defines the first axis
  16565. * @param axis2 defines the second axis
  16566. * @param axis3 defines the third axis
  16567. * @param ref defines the target quaternion
  16568. */
  16569. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  16570. /**
  16571. * Interpolates between two quaternions
  16572. * @param left defines first quaternion
  16573. * @param right defines second quaternion
  16574. * @param amount defines the gradient to use
  16575. * @returns the new interpolated quaternion
  16576. */
  16577. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  16578. /**
  16579. * Interpolates between two quaternions and stores it into a target quaternion
  16580. * @param left defines first quaternion
  16581. * @param right defines second quaternion
  16582. * @param amount defines the gradient to use
  16583. * @param result defines the target quaternion
  16584. */
  16585. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  16586. /**
  16587. * Interpolate between two quaternions using Hermite interpolation
  16588. * @param value1 defines first quaternion
  16589. * @param tangent1 defines the incoming tangent
  16590. * @param value2 defines second quaternion
  16591. * @param tangent2 defines the outgoing tangent
  16592. * @param amount defines the target quaternion
  16593. * @returns the new interpolated quaternion
  16594. */
  16595. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  16596. }
  16597. /**
  16598. * Class used to store matrix data (4x4)
  16599. */
  16600. class Matrix {
  16601. private static _tempQuaternion;
  16602. private static _xAxis;
  16603. private static _yAxis;
  16604. private static _zAxis;
  16605. private static _updateFlagSeed;
  16606. private static _identityReadOnly;
  16607. private _isIdentity;
  16608. private _isIdentityDirty;
  16609. /**
  16610. * Gets the update flag of the matrix which is an unique number for the matrix.
  16611. * It will be incremented every time the matrix data change.
  16612. * You can use it to speed the comparison between two versions of the same matrix.
  16613. */
  16614. updateFlag: number;
  16615. /**
  16616. * Gets or sets the internal data of the matrix
  16617. */
  16618. m: Float32Array;
  16619. /** @hidden */
  16620. _markAsUpdated(): void;
  16621. /**
  16622. * Creates an empty matrix (filled with zeros)
  16623. */
  16624. constructor();
  16625. /**
  16626. * Check if the current matrix is indentity
  16627. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  16628. * @returns true is the matrix is the identity matrix
  16629. */
  16630. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  16631. /**
  16632. * Gets the determinant of the matrix
  16633. * @returns the matrix determinant
  16634. */
  16635. determinant(): number;
  16636. /**
  16637. * Returns the matrix as a Float32Array
  16638. * @returns the matrix underlying array
  16639. */
  16640. toArray(): Float32Array;
  16641. /**
  16642. * Returns the matrix as a Float32Array
  16643. * @returns the matrix underlying array.
  16644. */
  16645. asArray(): Float32Array;
  16646. /**
  16647. * Inverts the current matrix in place
  16648. * @returns the current inverted matrix
  16649. */
  16650. invert(): Matrix;
  16651. /**
  16652. * Sets all the matrix elements to zero
  16653. * @returns the current matrix
  16654. */
  16655. reset(): Matrix;
  16656. /**
  16657. * Adds the current matrix with a second one
  16658. * @param other defines the matrix to add
  16659. * @returns a new matrix as the addition of the current matrix and the given one
  16660. */
  16661. add(other: Matrix): Matrix;
  16662. /**
  16663. * Sets the given matrix "result" to the addition of the current matrix and the given one
  16664. * @param other defines the matrix to add
  16665. * @param result defines the target matrix
  16666. * @returns the current matrix
  16667. */
  16668. addToRef(other: Matrix, result: Matrix): Matrix;
  16669. /**
  16670. * Adds in place the given matrix to the current matrix
  16671. * @param other defines the second operand
  16672. * @returns the current updated matrix
  16673. */
  16674. addToSelf(other: Matrix): Matrix;
  16675. /**
  16676. * Sets the given matrix to the current inverted Matrix
  16677. * @param other defines the target matrix
  16678. * @returns the unmodified current matrix
  16679. */
  16680. invertToRef(other: Matrix): Matrix;
  16681. /**
  16682. * Inserts the translation vector (using 3 floats) in the current matrix
  16683. * @param x defines the 1st component of the translation
  16684. * @param y defines the 2nd component of the translation
  16685. * @param z defines the 3rd component of the translation
  16686. * @returns the current updated matrix
  16687. */
  16688. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  16689. /**
  16690. * Inserts the translation vector in the current matrix
  16691. * @param vector3 defines the translation to insert
  16692. * @returns the current updated matrix
  16693. */
  16694. setTranslation(vector3: Vector3): Matrix;
  16695. /**
  16696. * Gets the translation value of the current matrix
  16697. * @returns a new Vector3 as the extracted translation from the matrix
  16698. */
  16699. getTranslation(): Vector3;
  16700. /**
  16701. * Fill a Vector3 with the extracted translation from the matrix
  16702. * @param result defines the Vector3 where to store the translation
  16703. * @returns the current matrix
  16704. */
  16705. getTranslationToRef(result: Vector3): Matrix;
  16706. /**
  16707. * Remove rotation and scaling part from the matrix
  16708. * @returns the updated matrix
  16709. */
  16710. removeRotationAndScaling(): Matrix;
  16711. /**
  16712. * Multiply two matrices
  16713. * @param other defines the second operand
  16714. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  16715. */
  16716. multiply(other: Matrix): Matrix;
  16717. /**
  16718. * Copy the current matrix from the given one
  16719. * @param other defines the source matrix
  16720. * @returns the current updated matrix
  16721. */
  16722. copyFrom(other: Matrix): Matrix;
  16723. /**
  16724. * Populates the given array from the starting index with the current matrix values
  16725. * @param array defines the target array
  16726. * @param offset defines the offset in the target array where to start storing values
  16727. * @returns the current matrix
  16728. */
  16729. copyToArray(array: Float32Array, offset?: number): Matrix;
  16730. /**
  16731. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  16732. * @param other defines the second operand
  16733. * @param result defines the matrix where to store the multiplication
  16734. * @returns the current matrix
  16735. */
  16736. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  16737. /**
  16738. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  16739. * @param other defines the second operand
  16740. * @param result defines the array where to store the multiplication
  16741. * @param offset defines the offset in the target array where to start storing values
  16742. * @returns the current matrix
  16743. */
  16744. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  16745. /**
  16746. * Check equality between this matrix and a second one
  16747. * @param value defines the second matrix to compare
  16748. * @returns true is the current matrix and the given one values are strictly equal
  16749. */
  16750. equals(value: Matrix): boolean;
  16751. /**
  16752. * Clone the current matrix
  16753. * @returns a new matrix from the current matrix
  16754. */
  16755. clone(): Matrix;
  16756. /**
  16757. * Returns the name of the current matrix class
  16758. * @returns the string "Matrix"
  16759. */
  16760. getClassName(): string;
  16761. /**
  16762. * Gets the hash code of the current matrix
  16763. * @returns the hash code
  16764. */
  16765. getHashCode(): number;
  16766. /**
  16767. * Decomposes the current Matrix into a translation, rotation and scaling components
  16768. * @param scale defines the scale vector3 given as a reference to update
  16769. * @param rotation defines the rotation quaternion given as a reference to update
  16770. * @param translation defines the translation vector3 given as a reference to update
  16771. * @returns true if operation was successful
  16772. */
  16773. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  16774. /**
  16775. * Gets specific row of the matrix
  16776. * @param index defines the number of the row to get
  16777. * @returns the index-th row of the current matrix as a new Vector4
  16778. */
  16779. getRow(index: number): Nullable<Vector4>;
  16780. /**
  16781. * Sets the index-th row of the current matrix to the vector4 values
  16782. * @param index defines the number of the row to set
  16783. * @param row defines the target vector4
  16784. * @returns the updated current matrix
  16785. */
  16786. setRow(index: number, row: Vector4): Matrix;
  16787. /**
  16788. * Compute the transpose of the matrix
  16789. * @returns the new transposed matrix
  16790. */
  16791. transpose(): Matrix;
  16792. /**
  16793. * Compute the transpose of the matrix and store it in a given matrix
  16794. * @param result defines the target matrix
  16795. * @returns the current matrix
  16796. */
  16797. transposeToRef(result: Matrix): Matrix;
  16798. /**
  16799. * Sets the index-th row of the current matrix with the given 4 x float values
  16800. * @param index defines the row index
  16801. * @param x defines the x component to set
  16802. * @param y defines the y component to set
  16803. * @param z defines the z component to set
  16804. * @param w defines the w component to set
  16805. * @returns the updated current matrix
  16806. */
  16807. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  16808. /**
  16809. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  16810. * @param scale defines the scale factor
  16811. * @returns a new matrix
  16812. */
  16813. scale(scale: number): Matrix;
  16814. /**
  16815. * Scale the current matrix values by a factor to a given result matrix
  16816. * @param scale defines the scale factor
  16817. * @param result defines the matrix to store the result
  16818. * @returns the current matrix
  16819. */
  16820. scaleToRef(scale: number, result: Matrix): Matrix;
  16821. /**
  16822. * Scale the current matrix values by a factor and add the result to a given matrix
  16823. * @param scale defines the scale factor
  16824. * @param result defines the Matrix to store the result
  16825. * @returns the current matrix
  16826. */
  16827. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  16828. /**
  16829. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  16830. * @param ref matrix to store the result
  16831. */
  16832. toNormalMatrix(ref: Matrix): void;
  16833. /**
  16834. * Gets only rotation part of the current matrix
  16835. * @returns a new matrix sets to the extracted rotation matrix from the current one
  16836. */
  16837. getRotationMatrix(): Matrix;
  16838. /**
  16839. * Extracts the rotation matrix from the current one and sets it as the given "result"
  16840. * @param result defines the target matrix to store data to
  16841. * @returns the current matrix
  16842. */
  16843. getRotationMatrixToRef(result: Matrix): Matrix;
  16844. /**
  16845. * Creates a matrix from an array
  16846. * @param array defines the source array
  16847. * @param offset defines an offset in the source array
  16848. * @returns a new Matrix set from the starting index of the given array
  16849. */
  16850. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  16851. /**
  16852. * Copy the content of an array into a given matrix
  16853. * @param array defines the source array
  16854. * @param offset defines an offset in the source array
  16855. * @param result defines the target matrix
  16856. */
  16857. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  16858. /**
  16859. * Stores an array into a matrix after having multiplied each component by a given factor
  16860. * @param array defines the source array
  16861. * @param offset defines the offset in the source array
  16862. * @param scale defines the scaling factor
  16863. * @param result defines the target matrix
  16864. */
  16865. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  16866. /**
  16867. * Stores a list of values (16) inside a given matrix
  16868. * @param initialM11 defines 1st value of 1st row
  16869. * @param initialM12 defines 2nd value of 1st row
  16870. * @param initialM13 defines 3rd value of 1st row
  16871. * @param initialM14 defines 4th value of 1st row
  16872. * @param initialM21 defines 1st value of 2nd row
  16873. * @param initialM22 defines 2nd value of 2nd row
  16874. * @param initialM23 defines 3rd value of 2nd row
  16875. * @param initialM24 defines 4th value of 2nd row
  16876. * @param initialM31 defines 1st value of 3rd row
  16877. * @param initialM32 defines 2nd value of 3rd row
  16878. * @param initialM33 defines 3rd value of 3rd row
  16879. * @param initialM34 defines 4th value of 3rd row
  16880. * @param initialM41 defines 1st value of 4th row
  16881. * @param initialM42 defines 2nd value of 4th row
  16882. * @param initialM43 defines 3rd value of 4th row
  16883. * @param initialM44 defines 4th value of 4th row
  16884. * @param result defines the target matrix
  16885. */
  16886. 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;
  16887. /**
  16888. * Gets an identity matrix that must not be updated
  16889. */
  16890. static readonly IdentityReadOnly: Matrix;
  16891. /**
  16892. * Creates new matrix from a list of values (16)
  16893. * @param initialM11 defines 1st value of 1st row
  16894. * @param initialM12 defines 2nd value of 1st row
  16895. * @param initialM13 defines 3rd value of 1st row
  16896. * @param initialM14 defines 4th value of 1st row
  16897. * @param initialM21 defines 1st value of 2nd row
  16898. * @param initialM22 defines 2nd value of 2nd row
  16899. * @param initialM23 defines 3rd value of 2nd row
  16900. * @param initialM24 defines 4th value of 2nd row
  16901. * @param initialM31 defines 1st value of 3rd row
  16902. * @param initialM32 defines 2nd value of 3rd row
  16903. * @param initialM33 defines 3rd value of 3rd row
  16904. * @param initialM34 defines 4th value of 3rd row
  16905. * @param initialM41 defines 1st value of 4th row
  16906. * @param initialM42 defines 2nd value of 4th row
  16907. * @param initialM43 defines 3rd value of 4th row
  16908. * @param initialM44 defines 4th value of 4th row
  16909. * @returns the new matrix
  16910. */
  16911. 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;
  16912. /**
  16913. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  16914. * @param scale defines the scale vector3
  16915. * @param rotation defines the rotation quaternion
  16916. * @param translation defines the translation vector3
  16917. * @returns a new matrix
  16918. */
  16919. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  16920. /**
  16921. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  16922. * @param scale defines the scale vector3
  16923. * @param rotation defines the rotation quaternion
  16924. * @param translation defines the translation vector3
  16925. * @param result defines the target matrix
  16926. */
  16927. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  16928. /**
  16929. * Creates a new identity matrix
  16930. * @returns a new identity matrix
  16931. */
  16932. static Identity(): Matrix;
  16933. /**
  16934. * Creates a new identity matrix and stores the result in a given matrix
  16935. * @param result defines the target matrix
  16936. */
  16937. static IdentityToRef(result: Matrix): void;
  16938. /**
  16939. * Creates a new zero matrix
  16940. * @returns a new zero matrix
  16941. */
  16942. static Zero(): Matrix;
  16943. /**
  16944. * Creates a new rotation matrix for "angle" radians around the X axis
  16945. * @param angle defines the angle (in radians) to use
  16946. * @return the new matrix
  16947. */
  16948. static RotationX(angle: number): Matrix;
  16949. /**
  16950. * Creates a new matrix as the invert of a given matrix
  16951. * @param source defines the source matrix
  16952. * @returns the new matrix
  16953. */
  16954. static Invert(source: Matrix): Matrix;
  16955. /**
  16956. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  16957. * @param angle defines the angle (in radians) to use
  16958. * @param result defines the target matrix
  16959. */
  16960. static RotationXToRef(angle: number, result: Matrix): void;
  16961. /**
  16962. * Creates a new rotation matrix for "angle" radians around the Y axis
  16963. * @param angle defines the angle (in radians) to use
  16964. * @return the new matrix
  16965. */
  16966. static RotationY(angle: number): Matrix;
  16967. /**
  16968. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  16969. * @param angle defines the angle (in radians) to use
  16970. * @param result defines the target matrix
  16971. */
  16972. static RotationYToRef(angle: number, result: Matrix): void;
  16973. /**
  16974. * Creates a new rotation matrix for "angle" radians around the Z axis
  16975. * @param angle defines the angle (in radians) to use
  16976. * @return the new matrix
  16977. */
  16978. static RotationZ(angle: number): Matrix;
  16979. /**
  16980. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  16981. * @param angle defines the angle (in radians) to use
  16982. * @param result defines the target matrix
  16983. */
  16984. static RotationZToRef(angle: number, result: Matrix): void;
  16985. /**
  16986. * Creates a new rotation matrix for "angle" radians around the given axis
  16987. * @param axis defines the axis to use
  16988. * @param angle defines the angle (in radians) to use
  16989. * @return the new matrix
  16990. */
  16991. static RotationAxis(axis: Vector3, angle: number): Matrix;
  16992. /**
  16993. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  16994. * @param axis defines the axis to use
  16995. * @param angle defines the angle (in radians) to use
  16996. * @param result defines the target matrix
  16997. */
  16998. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  16999. /**
  17000. * Creates a rotation matrix
  17001. * @param yaw defines the yaw angle in radians (Y axis)
  17002. * @param pitch defines the pitch angle in radians (X axis)
  17003. * @param roll defines the roll angle in radians (X axis)
  17004. * @returns the new rotation matrix
  17005. */
  17006. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  17007. /**
  17008. * Creates a rotation matrix and stores it in a given matrix
  17009. * @param yaw defines the yaw angle in radians (Y axis)
  17010. * @param pitch defines the pitch angle in radians (X axis)
  17011. * @param roll defines the roll angle in radians (X axis)
  17012. * @param result defines the target matrix
  17013. */
  17014. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  17015. /**
  17016. * Creates a scaling matrix
  17017. * @param x defines the scale factor on X axis
  17018. * @param y defines the scale factor on Y axis
  17019. * @param z defines the scale factor on Z axis
  17020. * @returns the new matrix
  17021. */
  17022. static Scaling(x: number, y: number, z: number): Matrix;
  17023. /**
  17024. * Creates a scaling matrix and stores it in a given matrix
  17025. * @param x defines the scale factor on X axis
  17026. * @param y defines the scale factor on Y axis
  17027. * @param z defines the scale factor on Z axis
  17028. * @param result defines the target matrix
  17029. */
  17030. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  17031. /**
  17032. * Creates a translation matrix
  17033. * @param x defines the translation on X axis
  17034. * @param y defines the translation on Y axis
  17035. * @param z defines the translationon Z axis
  17036. * @returns the new matrix
  17037. */
  17038. static Translation(x: number, y: number, z: number): Matrix;
  17039. /**
  17040. * Creates a translation matrix and stores it in a given matrix
  17041. * @param x defines the translation on X axis
  17042. * @param y defines the translation on Y axis
  17043. * @param z defines the translationon Z axis
  17044. * @param result defines the target matrix
  17045. */
  17046. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  17047. /**
  17048. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17049. * @param startValue defines the start value
  17050. * @param endValue defines the end value
  17051. * @param gradient defines the gradient factor
  17052. * @returns the new matrix
  17053. */
  17054. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  17055. /**
  17056. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17057. * @param startValue defines the start value
  17058. * @param endValue defines the end value
  17059. * @param gradient defines the gradient factor
  17060. * @param result defines the Matrix object where to store data
  17061. */
  17062. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  17063. /**
  17064. * Builds a new matrix whose values are computed by:
  17065. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  17066. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  17067. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  17068. * @param startValue defines the first matrix
  17069. * @param endValue defines the second matrix
  17070. * @param gradient defines the gradient between the two matrices
  17071. * @returns the new matrix
  17072. */
  17073. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  17074. /**
  17075. * Update a matrix to values which are computed by:
  17076. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  17077. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  17078. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  17079. * @param startValue defines the first matrix
  17080. * @param endValue defines the second matrix
  17081. * @param gradient defines the gradient between the two matrices
  17082. * @param result defines the target matrix
  17083. */
  17084. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  17085. /**
  17086. * 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"
  17087. * This function works in left handed mode
  17088. * @param eye defines the final position of the entity
  17089. * @param target defines where the entity should look at
  17090. * @param up defines the up vector for the entity
  17091. * @returns the new matrix
  17092. */
  17093. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  17094. /**
  17095. * 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".
  17096. * This function works in left handed mode
  17097. * @param eye defines the final position of the entity
  17098. * @param target defines where the entity should look at
  17099. * @param up defines the up vector for the entity
  17100. * @param result defines the target matrix
  17101. */
  17102. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  17103. /**
  17104. * 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"
  17105. * This function works in right handed mode
  17106. * @param eye defines the final position of the entity
  17107. * @param target defines where the entity should look at
  17108. * @param up defines the up vector for the entity
  17109. * @returns the new matrix
  17110. */
  17111. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  17112. /**
  17113. * 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".
  17114. * This function works in right handed mode
  17115. * @param eye defines the final position of the entity
  17116. * @param target defines where the entity should look at
  17117. * @param up defines the up vector for the entity
  17118. * @param result defines the target matrix
  17119. */
  17120. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  17121. /**
  17122. * Create a left-handed orthographic projection matrix
  17123. * @param width defines the viewport width
  17124. * @param height defines the viewport height
  17125. * @param znear defines the near clip plane
  17126. * @param zfar defines the far clip plane
  17127. * @returns a new matrix as a left-handed orthographic projection matrix
  17128. */
  17129. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  17130. /**
  17131. * Store a left-handed orthographic projection to a given matrix
  17132. * @param width defines the viewport width
  17133. * @param height defines the viewport height
  17134. * @param znear defines the near clip plane
  17135. * @param zfar defines the far clip plane
  17136. * @param result defines the target matrix
  17137. */
  17138. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  17139. /**
  17140. * Create a left-handed orthographic projection matrix
  17141. * @param left defines the viewport left coordinate
  17142. * @param right defines the viewport right coordinate
  17143. * @param bottom defines the viewport bottom coordinate
  17144. * @param top defines the viewport top coordinate
  17145. * @param znear defines the near clip plane
  17146. * @param zfar defines the far clip plane
  17147. * @returns a new matrix as a left-handed orthographic projection matrix
  17148. */
  17149. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  17150. /**
  17151. * Stores a left-handed orthographic projection into a given matrix
  17152. * @param left defines the viewport left coordinate
  17153. * @param right defines the viewport right coordinate
  17154. * @param bottom defines the viewport bottom coordinate
  17155. * @param top defines the viewport top coordinate
  17156. * @param znear defines the near clip plane
  17157. * @param zfar defines the far clip plane
  17158. * @param result defines the target matrix
  17159. */
  17160. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  17161. /**
  17162. * Creates a right-handed orthographic projection matrix
  17163. * @param left defines the viewport left coordinate
  17164. * @param right defines the viewport right coordinate
  17165. * @param bottom defines the viewport bottom coordinate
  17166. * @param top defines the viewport top coordinate
  17167. * @param znear defines the near clip plane
  17168. * @param zfar defines the far clip plane
  17169. * @returns a new matrix as a right-handed orthographic projection matrix
  17170. */
  17171. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  17172. /**
  17173. * Stores a right-handed orthographic projection into a given matrix
  17174. * @param left defines the viewport left coordinate
  17175. * @param right defines the viewport right coordinate
  17176. * @param bottom defines the viewport bottom coordinate
  17177. * @param top defines the viewport top coordinate
  17178. * @param znear defines the near clip plane
  17179. * @param zfar defines the far clip plane
  17180. * @param result defines the target matrix
  17181. */
  17182. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  17183. /**
  17184. * Creates a left-handed perspective projection matrix
  17185. * @param width defines the viewport width
  17186. * @param height defines the viewport height
  17187. * @param znear defines the near clip plane
  17188. * @param zfar defines the far clip plane
  17189. * @returns a new matrix as a left-handed perspective projection matrix
  17190. */
  17191. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  17192. /**
  17193. * Creates a left-handed perspective projection matrix
  17194. * @param fov defines the horizontal field of view
  17195. * @param aspect defines the aspect ratio
  17196. * @param znear defines the near clip plane
  17197. * @param zfar defines the far clip plane
  17198. * @returns a new matrix as a left-handed perspective projection matrix
  17199. */
  17200. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  17201. /**
  17202. * Stores a left-handed perspective projection into a given matrix
  17203. * @param fov defines the horizontal field of view
  17204. * @param aspect defines the aspect ratio
  17205. * @param znear defines the near clip plane
  17206. * @param zfar defines the far clip plane
  17207. * @param result defines the target matrix
  17208. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  17209. */
  17210. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  17211. /**
  17212. * Creates a right-handed perspective projection matrix
  17213. * @param fov defines the horizontal field of view
  17214. * @param aspect defines the aspect ratio
  17215. * @param znear defines the near clip plane
  17216. * @param zfar defines the far clip plane
  17217. * @returns a new matrix as a right-handed perspective projection matrix
  17218. */
  17219. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  17220. /**
  17221. * Stores a right-handed perspective projection into a given matrix
  17222. * @param fov defines the horizontal field of view
  17223. * @param aspect defines the aspect ratio
  17224. * @param znear defines the near clip plane
  17225. * @param zfar defines the far clip plane
  17226. * @param result defines the target matrix
  17227. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  17228. */
  17229. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  17230. /**
  17231. * Stores a perspective projection for WebVR info a given matrix
  17232. * @param fov defines the field of view
  17233. * @param znear defines the near clip plane
  17234. * @param zfar defines the far clip plane
  17235. * @param result defines the target matrix
  17236. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  17237. */
  17238. static PerspectiveFovWebVRToRef(fov: {
  17239. upDegrees: number;
  17240. downDegrees: number;
  17241. leftDegrees: number;
  17242. rightDegrees: number;
  17243. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  17244. /**
  17245. * Computes a complete transformation matrix
  17246. * @param viewport defines the viewport to use
  17247. * @param world defines the world matrix
  17248. * @param view defines the view matrix
  17249. * @param projection defines the projection matrix
  17250. * @param zmin defines the near clip plane
  17251. * @param zmax defines the far clip plane
  17252. * @returns the transformation matrix
  17253. */
  17254. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  17255. /**
  17256. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  17257. * @param matrix defines the matrix to use
  17258. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  17259. */
  17260. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  17261. /**
  17262. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  17263. * @param matrix defines the matrix to use
  17264. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  17265. */
  17266. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  17267. /**
  17268. * Compute the transpose of a given matrix
  17269. * @param matrix defines the matrix to transpose
  17270. * @returns the new matrix
  17271. */
  17272. static Transpose(matrix: Matrix): Matrix;
  17273. /**
  17274. * Compute the transpose of a matrix and store it in a target matrix
  17275. * @param matrix defines the matrix to transpose
  17276. * @param result defines the target matrix
  17277. */
  17278. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  17279. /**
  17280. * Computes a reflection matrix from a plane
  17281. * @param plane defines the reflection plane
  17282. * @returns a new matrix
  17283. */
  17284. static Reflection(plane: Plane): Matrix;
  17285. /**
  17286. * Computes a reflection matrix from a plane
  17287. * @param plane defines the reflection plane
  17288. * @param result defines the target matrix
  17289. */
  17290. static ReflectionToRef(plane: Plane, result: Matrix): void;
  17291. /**
  17292. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  17293. * @param xaxis defines the value of the 1st axis
  17294. * @param yaxis defines the value of the 2nd axis
  17295. * @param zaxis defines the value of the 3rd axis
  17296. * @param result defines the target matrix
  17297. */
  17298. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  17299. /**
  17300. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  17301. * @param quat defines the quaternion to use
  17302. * @param result defines the target matrix
  17303. */
  17304. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  17305. }
  17306. class Plane {
  17307. normal: Vector3;
  17308. d: number;
  17309. /**
  17310. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  17311. */
  17312. constructor(a: number, b: number, c: number, d: number);
  17313. /**
  17314. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  17315. */
  17316. asArray(): number[];
  17317. /**
  17318. * Returns a new plane copied from the current Plane.
  17319. */
  17320. clone(): Plane;
  17321. /**
  17322. * Returns the string "Plane".
  17323. */
  17324. getClassName(): string;
  17325. /**
  17326. * Returns the Plane hash code.
  17327. */
  17328. getHashCode(): number;
  17329. /**
  17330. * Normalize the current Plane in place.
  17331. * Returns the updated Plane.
  17332. */
  17333. normalize(): Plane;
  17334. /**
  17335. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  17336. */
  17337. transform(transformation: Matrix): Plane;
  17338. /**
  17339. * Returns the dot product (float) of the point coordinates and the plane normal.
  17340. */
  17341. dotCoordinate(point: Vector3): number;
  17342. /**
  17343. * Updates the current Plane from the plane defined by the three given points.
  17344. * Returns the updated Plane.
  17345. */
  17346. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  17347. /**
  17348. * Boolean : True is the vector "direction" is the same side than the plane normal.
  17349. */
  17350. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  17351. /**
  17352. * Returns the signed distance (float) from the given point to the Plane.
  17353. */
  17354. signedDistanceTo(point: Vector3): number;
  17355. /**
  17356. * Returns a new Plane from the given array.
  17357. */
  17358. static FromArray(array: ArrayLike<number>): Plane;
  17359. /**
  17360. * Returns a new Plane defined by the three given points.
  17361. */
  17362. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  17363. /**
  17364. * Returns a new Plane the normal vector to this plane at the given origin point.
  17365. * Note : the vector "normal" is updated because normalized.
  17366. */
  17367. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  17368. /**
  17369. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  17370. */
  17371. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  17372. }
  17373. class Viewport {
  17374. x: number;
  17375. y: number;
  17376. width: number;
  17377. height: number;
  17378. /**
  17379. * Creates a Viewport object located at (x, y) and sized (width, height).
  17380. */
  17381. constructor(x: number, y: number, width: number, height: number);
  17382. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  17383. /**
  17384. * Returns a new Viewport copied from the current one.
  17385. */
  17386. clone(): Viewport;
  17387. }
  17388. class Frustum {
  17389. /**
  17390. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  17391. */
  17392. static GetPlanes(transform: Matrix): Plane[];
  17393. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17394. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17395. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17396. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17397. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17398. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17399. /**
  17400. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  17401. */
  17402. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  17403. }
  17404. /** Defines supported spaces */
  17405. enum Space {
  17406. /** Local (object) space */
  17407. LOCAL = 0,
  17408. /** World space */
  17409. WORLD = 1,
  17410. /** Bone space */
  17411. BONE = 2,
  17412. }
  17413. /** Defines the 3 main axes */
  17414. class Axis {
  17415. /** X axis */
  17416. static X: Vector3;
  17417. /** Y axis */
  17418. static Y: Vector3;
  17419. /** Z axis */
  17420. static Z: Vector3;
  17421. }
  17422. class BezierCurve {
  17423. /**
  17424. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  17425. */
  17426. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  17427. }
  17428. /**
  17429. * Defines potential orientation for back face culling
  17430. */
  17431. enum Orientation {
  17432. /**
  17433. * Clockwise
  17434. */
  17435. CW = 0,
  17436. /** Counter clockwise */
  17437. CCW = 1,
  17438. }
  17439. /**
  17440. * Defines angle representation
  17441. */
  17442. class Angle {
  17443. private _radians;
  17444. /**
  17445. * Creates an Angle object of "radians" radians (float).
  17446. */
  17447. constructor(radians: number);
  17448. /**
  17449. * Get value in degrees
  17450. * @returns the Angle value in degrees (float)
  17451. */
  17452. degrees(): number;
  17453. /**
  17454. * Get value in radians
  17455. * @returns the Angle value in radians (float)
  17456. */
  17457. radians(): number;
  17458. /**
  17459. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  17460. * @param a defines first vector
  17461. * @param b defines second vector
  17462. * @returns a new Angle
  17463. */
  17464. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  17465. /**
  17466. * Gets a new Angle object from the given float in radians
  17467. * @param radians defines the angle value in radians
  17468. * @returns a new Angle
  17469. */
  17470. static FromRadians(radians: number): Angle;
  17471. /**
  17472. * Gets a new Angle object from the given float in degrees
  17473. * @param degrees defines the angle value in degrees
  17474. * @returns a new Angle
  17475. */
  17476. static FromDegrees(degrees: number): Angle;
  17477. }
  17478. class Arc2 {
  17479. startPoint: Vector2;
  17480. midPoint: Vector2;
  17481. endPoint: Vector2;
  17482. centerPoint: Vector2;
  17483. radius: number;
  17484. angle: Angle;
  17485. startAngle: Angle;
  17486. orientation: Orientation;
  17487. /**
  17488. * Creates an Arc object from the three given points : start, middle and end.
  17489. */
  17490. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  17491. }
  17492. class Path2 {
  17493. private _points;
  17494. private _length;
  17495. closed: boolean;
  17496. /**
  17497. * Creates a Path2 object from the starting 2D coordinates x and y.
  17498. */
  17499. constructor(x: number, y: number);
  17500. /**
  17501. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  17502. * Returns the updated Path2.
  17503. */
  17504. addLineTo(x: number, y: number): Path2;
  17505. /**
  17506. * 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.
  17507. * Returns the updated Path2.
  17508. */
  17509. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  17510. /**
  17511. * Closes the Path2.
  17512. * Returns the Path2.
  17513. */
  17514. close(): Path2;
  17515. /**
  17516. * Returns the Path2 total length (float).
  17517. */
  17518. length(): number;
  17519. /**
  17520. * Returns the Path2 internal array of points.
  17521. */
  17522. getPoints(): Vector2[];
  17523. /**
  17524. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  17525. */
  17526. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  17527. /**
  17528. * Returns a new Path2 starting at the coordinates (x, y).
  17529. */
  17530. static StartingAt(x: number, y: number): Path2;
  17531. }
  17532. class Path3D {
  17533. path: Vector3[];
  17534. private _curve;
  17535. private _distances;
  17536. private _tangents;
  17537. private _normals;
  17538. private _binormals;
  17539. private _raw;
  17540. /**
  17541. * new Path3D(path, normal, raw)
  17542. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  17543. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  17544. * path : an array of Vector3, the curve axis of the Path3D
  17545. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  17546. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  17547. */
  17548. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  17549. /**
  17550. * Returns the Path3D array of successive Vector3 designing its curve.
  17551. */
  17552. getCurve(): Vector3[];
  17553. /**
  17554. * Returns an array populated with tangent vectors on each Path3D curve point.
  17555. */
  17556. getTangents(): Vector3[];
  17557. /**
  17558. * Returns an array populated with normal vectors on each Path3D curve point.
  17559. */
  17560. getNormals(): Vector3[];
  17561. /**
  17562. * Returns an array populated with binormal vectors on each Path3D curve point.
  17563. */
  17564. getBinormals(): Vector3[];
  17565. /**
  17566. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  17567. */
  17568. getDistances(): number[];
  17569. /**
  17570. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  17571. * Returns the same object updated.
  17572. */
  17573. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  17574. private _compute(firstNormal);
  17575. private _getFirstNonNullVector(index);
  17576. private _getLastNonNullVector(index);
  17577. private _normalVector(v0, vt, va);
  17578. }
  17579. class Curve3 {
  17580. private _points;
  17581. private _length;
  17582. /**
  17583. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  17584. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  17585. * @param v1 (Vector3) the control point
  17586. * @param v2 (Vector3) the end point of the Quadratic Bezier
  17587. * @param nbPoints (integer) the wanted number of points in the curve
  17588. */
  17589. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  17590. /**
  17591. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  17592. * @param v0 (Vector3) the origin point of the Cubic Bezier
  17593. * @param v1 (Vector3) the first control point
  17594. * @param v2 (Vector3) the second control point
  17595. * @param v3 (Vector3) the end point of the Cubic Bezier
  17596. * @param nbPoints (integer) the wanted number of points in the curve
  17597. */
  17598. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  17599. /**
  17600. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  17601. * @param p1 (Vector3) the origin point of the Hermite Spline
  17602. * @param t1 (Vector3) the tangent vector at the origin point
  17603. * @param p2 (Vector3) the end point of the Hermite Spline
  17604. * @param t2 (Vector3) the tangent vector at the end point
  17605. * @param nbPoints (integer) the wanted number of points in the curve
  17606. */
  17607. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  17608. /**
  17609. * Returns a Curve3 object along a CatmullRom Spline curve :
  17610. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  17611. * @param nbPoints (integer) the wanted number of points between each curve control points
  17612. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  17613. */
  17614. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  17615. /**
  17616. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  17617. * A Curve3 is designed from a series of successive Vector3.
  17618. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  17619. */
  17620. constructor(points: Vector3[]);
  17621. /**
  17622. * Returns the Curve3 stored array of successive Vector3
  17623. */
  17624. getPoints(): Vector3[];
  17625. /**
  17626. * Returns the computed length (float) of the curve.
  17627. */
  17628. length(): number;
  17629. /**
  17630. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  17631. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  17632. * curveA and curveB keep unchanged.
  17633. */
  17634. continue(curve: Curve3): Curve3;
  17635. private _computeLength(path);
  17636. }
  17637. class PositionNormalVertex {
  17638. position: Vector3;
  17639. normal: Vector3;
  17640. constructor(position?: Vector3, normal?: Vector3);
  17641. clone(): PositionNormalVertex;
  17642. }
  17643. class PositionNormalTextureVertex {
  17644. position: Vector3;
  17645. normal: Vector3;
  17646. uv: Vector2;
  17647. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  17648. clone(): PositionNormalTextureVertex;
  17649. }
  17650. class Tmp {
  17651. static Color3: Color3[];
  17652. static Vector2: Vector2[];
  17653. static Vector3: Vector3[];
  17654. static Vector4: Vector4[];
  17655. static Quaternion: Quaternion[];
  17656. static Matrix: Matrix[];
  17657. }
  17658. }
  17659. declare module BABYLON {
  17660. class SphericalPolynomial {
  17661. x: Vector3;
  17662. y: Vector3;
  17663. z: Vector3;
  17664. xx: Vector3;
  17665. yy: Vector3;
  17666. zz: Vector3;
  17667. xy: Vector3;
  17668. yz: Vector3;
  17669. zx: Vector3;
  17670. addAmbient(color: Color3): void;
  17671. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  17672. scale(scale: number): void;
  17673. }
  17674. class SphericalHarmonics {
  17675. L00: Vector3;
  17676. L1_1: Vector3;
  17677. L10: Vector3;
  17678. L11: Vector3;
  17679. L2_2: Vector3;
  17680. L2_1: Vector3;
  17681. L20: Vector3;
  17682. L21: Vector3;
  17683. L22: Vector3;
  17684. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  17685. scale(scale: number): void;
  17686. convertIncidentRadianceToIrradiance(): void;
  17687. convertIrradianceToLambertianRadiance(): void;
  17688. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  17689. }
  17690. }
  17691. declare module BABYLON {
  17692. /**
  17693. * Class used to store all common mesh properties
  17694. */
  17695. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  17696. /** No occlusion */
  17697. static OCCLUSION_TYPE_NONE: number;
  17698. /** Occlusion set to optimisitic */
  17699. static OCCLUSION_TYPE_OPTIMISTIC: number;
  17700. /** Occlusion set to strict */
  17701. static OCCLUSION_TYPE_STRICT: number;
  17702. /** Use an accurante occlusion algorithm */
  17703. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  17704. /** Use a conservative occlusion algorithm */
  17705. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  17706. /**
  17707. * No billboard
  17708. */
  17709. static readonly BILLBOARDMODE_NONE: number;
  17710. /** Billboard on X axis */
  17711. static readonly BILLBOARDMODE_X: number;
  17712. /** Billboard on Y axis */
  17713. static readonly BILLBOARDMODE_Y: number;
  17714. /** Billboard on Z axis */
  17715. static readonly BILLBOARDMODE_Z: number;
  17716. /** Billboard on all axes */
  17717. static readonly BILLBOARDMODE_ALL: number;
  17718. private _facetPositions;
  17719. private _facetNormals;
  17720. private _facetPartitioning;
  17721. private _facetNb;
  17722. private _partitioningSubdivisions;
  17723. private _partitioningBBoxRatio;
  17724. private _facetDataEnabled;
  17725. private _facetParameters;
  17726. private _bbSize;
  17727. private _subDiv;
  17728. private _facetDepthSort;
  17729. private _facetDepthSortEnabled;
  17730. private _depthSortedIndices;
  17731. private _depthSortedFacets;
  17732. private _facetDepthSortFunction;
  17733. private _facetDepthSortFrom;
  17734. private _facetDepthSortOrigin;
  17735. private _invertedMatrix;
  17736. /**
  17737. * Gets the number of facets in the mesh
  17738. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  17739. */
  17740. readonly facetNb: number;
  17741. /**
  17742. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  17743. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  17744. */
  17745. partitioningSubdivisions: number;
  17746. /**
  17747. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  17748. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  17749. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  17750. */
  17751. partitioningBBoxRatio: number;
  17752. /**
  17753. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  17754. * Works only for updatable meshes.
  17755. * Doesn't work with multi-materials
  17756. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  17757. */
  17758. mustDepthSortFacets: boolean;
  17759. /**
  17760. * The location (Vector3) where the facet depth sort must be computed from.
  17761. * By default, the active camera position.
  17762. * Used only when facet depth sort is enabled
  17763. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  17764. */
  17765. facetDepthSortFrom: Vector3;
  17766. /**
  17767. * gets a boolean indicating if facetData is enabled
  17768. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  17769. */
  17770. readonly isFacetDataEnabled: boolean;
  17771. /** @hidden */
  17772. _updateNonUniformScalingState(value: boolean): boolean;
  17773. /**
  17774. * An event triggered when this mesh collides with another one
  17775. */
  17776. onCollideObservable: Observable<AbstractMesh>;
  17777. private _onCollideObserver;
  17778. /** Set a function to call when this mesh collides with another one */
  17779. onCollide: () => void;
  17780. /**
  17781. * An event triggered when the collision's position changes
  17782. */
  17783. onCollisionPositionChangeObservable: Observable<Vector3>;
  17784. private _onCollisionPositionChangeObserver;
  17785. /** Set a function to call when the collision's position changes */
  17786. onCollisionPositionChange: () => void;
  17787. /**
  17788. * An event triggered when material is changed
  17789. */
  17790. onMaterialChangedObservable: Observable<AbstractMesh>;
  17791. /**
  17792. * Gets or sets the orientation for POV movement & rotation
  17793. */
  17794. definedFacingForward: boolean;
  17795. /**
  17796. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  17797. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  17798. * * 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.
  17799. * @see http://doc.babylonjs.com/features/occlusionquery
  17800. */
  17801. occlusionQueryAlgorithmType: number;
  17802. /**
  17803. * 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:
  17804. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  17805. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  17806. * * 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.
  17807. * @see http://doc.babylonjs.com/features/occlusionquery
  17808. */
  17809. occlusionType: number;
  17810. /**
  17811. * 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.
  17812. * The default value is -1 which means don't break the query and wait till the result
  17813. * @see http://doc.babylonjs.com/features/occlusionquery
  17814. */
  17815. occlusionRetryCount: number;
  17816. private _occlusionInternalRetryCounter;
  17817. protected _isOccluded: boolean;
  17818. /**
  17819. * 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
  17820. * @see http://doc.babylonjs.com/features/occlusionquery
  17821. */
  17822. isOccluded: boolean;
  17823. private _isOcclusionQueryInProgress;
  17824. /**
  17825. * Flag to check the progress status of the query
  17826. * @see http://doc.babylonjs.com/features/occlusionquery
  17827. */
  17828. readonly isOcclusionQueryInProgress: boolean;
  17829. private _occlusionQuery;
  17830. private _visibility;
  17831. /**
  17832. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  17833. */
  17834. /**
  17835. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  17836. */
  17837. visibility: number;
  17838. /** Gets or sets the alpha index used to sort transparent meshes
  17839. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  17840. */
  17841. alphaIndex: number;
  17842. /**
  17843. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  17844. */
  17845. isVisible: boolean;
  17846. /**
  17847. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  17848. */
  17849. isPickable: boolean;
  17850. /**
  17851. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  17852. */
  17853. showBoundingBox: boolean;
  17854. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  17855. showSubMeshesBoundingBox: boolean;
  17856. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  17857. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  17858. */
  17859. isBlocker: boolean;
  17860. /**
  17861. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  17862. */
  17863. enablePointerMoveEvents: boolean;
  17864. /**
  17865. * Specifies the rendering group id for this mesh (0 by default)
  17866. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  17867. */
  17868. renderingGroupId: number;
  17869. private _material;
  17870. /** Gets or sets current material */
  17871. material: Nullable<Material>;
  17872. private _receiveShadows;
  17873. /**
  17874. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  17875. * @see http://doc.babylonjs.com/babylon101/shadows
  17876. */
  17877. receiveShadows: boolean;
  17878. /**
  17879. * Gets or sets a boolean indicating if the outline must be rendered as well
  17880. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  17881. */
  17882. renderOutline: boolean;
  17883. /** Defines color to use when rendering outline */
  17884. outlineColor: Color3;
  17885. /** Define width to use when rendering outline */
  17886. outlineWidth: number;
  17887. /**
  17888. * Gets or sets a boolean indicating if the overlay must be rendered as well
  17889. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  17890. */
  17891. renderOverlay: boolean;
  17892. /** Defines color to use when rendering overlay */
  17893. overlayColor: Color3;
  17894. /** Defines alpha to use when rendering overlay */
  17895. overlayAlpha: number;
  17896. private _hasVertexAlpha;
  17897. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  17898. hasVertexAlpha: boolean;
  17899. private _useVertexColors;
  17900. /** 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) */
  17901. useVertexColors: boolean;
  17902. private _computeBonesUsingShaders;
  17903. /**
  17904. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  17905. */
  17906. computeBonesUsingShaders: boolean;
  17907. private _numBoneInfluencers;
  17908. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  17909. numBoneInfluencers: number;
  17910. private _applyFog;
  17911. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  17912. applyFog: boolean;
  17913. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  17914. useOctreeForRenderingSelection: boolean;
  17915. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  17916. useOctreeForPicking: boolean;
  17917. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  17918. useOctreeForCollisions: boolean;
  17919. private _layerMask;
  17920. /**
  17921. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  17922. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  17923. */
  17924. layerMask: number;
  17925. /**
  17926. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  17927. */
  17928. alwaysSelectAsActiveMesh: boolean;
  17929. /**
  17930. * Gets or sets the current action manager
  17931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17932. */
  17933. actionManager: Nullable<ActionManager>;
  17934. /**
  17935. * Gets or sets impostor used for physic simulation
  17936. * @see http://doc.babylonjs.com/features/physics_engine
  17937. */
  17938. physicsImpostor: Nullable<PhysicsImpostor>;
  17939. private _checkCollisions;
  17940. private _collisionMask;
  17941. private _collisionGroup;
  17942. /**
  17943. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  17944. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  17945. */
  17946. ellipsoid: Vector3;
  17947. /**
  17948. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  17949. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  17950. */
  17951. ellipsoidOffset: Vector3;
  17952. private _collider;
  17953. private _oldPositionForCollisions;
  17954. private _diffPositionForCollisions;
  17955. /**
  17956. * Gets or sets a collision mask used to mask collisions (default is -1).
  17957. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  17958. */
  17959. collisionMask: number;
  17960. /**
  17961. * Gets or sets the current collision group mask (-1 by default).
  17962. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  17963. */
  17964. collisionGroup: number;
  17965. /**
  17966. * Defines edge width used when edgesRenderer is enabled
  17967. * @see https://www.babylonjs-playground.com/#10OJSG#13
  17968. */
  17969. edgesWidth: number;
  17970. /**
  17971. * Defines edge color used when edgesRenderer is enabled
  17972. * @see https://www.babylonjs-playground.com/#10OJSG#13
  17973. */
  17974. edgesColor: Color4;
  17975. /** @hidden */
  17976. _edgesRenderer: Nullable<EdgesRenderer>;
  17977. private _collisionsTransformMatrix;
  17978. private _collisionsScalingMatrix;
  17979. /** @hidden */
  17980. _masterMesh: Nullable<AbstractMesh>;
  17981. /** @hidden */
  17982. _boundingInfo: Nullable<BoundingInfo>;
  17983. /** @hidden */
  17984. _renderId: number;
  17985. /**
  17986. * Gets or sets the list of subMeshes
  17987. * @see http://doc.babylonjs.com/how_to/multi_materials
  17988. */
  17989. subMeshes: SubMesh[];
  17990. /** @hidden */
  17991. _submeshesOctree: Octree<SubMesh>;
  17992. /** @hidden */
  17993. _intersectionsInProgress: AbstractMesh[];
  17994. /** @hidden */
  17995. _unIndexed: boolean;
  17996. /** @hidden */
  17997. _lightSources: Light[];
  17998. /** @hidden */
  17999. readonly _positions: Nullable<Vector3[]>;
  18000. /** @hidden */
  18001. _waitingActions: any;
  18002. /** @hidden */
  18003. _waitingFreezeWorldMatrix: Nullable<boolean>;
  18004. private _skeleton;
  18005. /** @hidden */
  18006. _bonesTransformMatrices: Nullable<Float32Array>;
  18007. /**
  18008. * Gets or sets a skeleton to apply skining transformations
  18009. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18010. */
  18011. skeleton: Nullable<Skeleton>;
  18012. /**
  18013. * Creates a new AbstractMesh
  18014. * @param name defines the name of the mesh
  18015. * @param scene defines the hosting scene
  18016. */
  18017. constructor(name: string, scene?: Nullable<Scene>);
  18018. /**
  18019. * Returns the string "AbstractMesh"
  18020. * @returns "AbstractMesh"
  18021. */
  18022. getClassName(): string;
  18023. /**
  18024. * Gets a string representation of the current mesh
  18025. * @param fullDetails defines a boolean indicating if full details must be included
  18026. * @returns a string representation of the current mesh
  18027. */
  18028. toString(fullDetails?: boolean): string;
  18029. /** @hidden */
  18030. _rebuild(): void;
  18031. /** @hidden */
  18032. _resyncLightSources(): void;
  18033. /** @hidden */
  18034. _resyncLighSource(light: Light): void;
  18035. /** @hidden */
  18036. _unBindEffect(): void;
  18037. /** @hidden */
  18038. _removeLightSource(light: Light): void;
  18039. private _markSubMeshesAsDirty(func);
  18040. /** @hidden */
  18041. _markSubMeshesAsLightDirty(): void;
  18042. /** @hidden */
  18043. _markSubMeshesAsAttributesDirty(): void;
  18044. /** @hidden */
  18045. _markSubMeshesAsMiscDirty(): void;
  18046. /**
  18047. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  18048. */
  18049. scaling: Vector3;
  18050. /**
  18051. * Disables the mesh edge rendering mode
  18052. * @returns the currentAbstractMesh
  18053. */
  18054. disableEdgesRendering(): AbstractMesh;
  18055. /**
  18056. * Enables the edge rendering mode on the mesh.
  18057. * This mode makes the mesh edges visible
  18058. * @param epsilon defines the maximal distance between two angles to detect a face
  18059. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  18060. * @returns the currentAbstractMesh
  18061. * @see https://www.babylonjs-playground.com/#19O9TU#0
  18062. */
  18063. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  18064. /**
  18065. * Returns true if the mesh is blocked. Implemented by child classes
  18066. */
  18067. readonly isBlocked: boolean;
  18068. /**
  18069. * Returns the mesh itself by default. Implemented by child classes
  18070. * @param camera defines the camera to use to pick the right LOD level
  18071. * @returns the currentAbstractMesh
  18072. */
  18073. getLOD(camera: Camera): AbstractMesh;
  18074. /**
  18075. * Returns 0 by default. Implemented by child classes
  18076. * @returns an integer
  18077. */
  18078. getTotalVertices(): number;
  18079. /**
  18080. * Returns null by default. Implemented by child classes
  18081. * @returns null
  18082. */
  18083. getIndices(): Nullable<IndicesArray>;
  18084. /**
  18085. * Returns the array of the requested vertex data kind. Implemented by child classes
  18086. * @param kind defines the vertex data kind to use
  18087. * @returns null
  18088. */
  18089. getVerticesData(kind: string): Nullable<FloatArray>;
  18090. /**
  18091. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18092. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18093. * Note that a new underlying VertexBuffer object is created each call.
  18094. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18095. * @param kind defines vertex data kind:
  18096. * * BABYLON.VertexBuffer.PositionKind
  18097. * * BABYLON.VertexBuffer.UVKind
  18098. * * BABYLON.VertexBuffer.UV2Kind
  18099. * * BABYLON.VertexBuffer.UV3Kind
  18100. * * BABYLON.VertexBuffer.UV4Kind
  18101. * * BABYLON.VertexBuffer.UV5Kind
  18102. * * BABYLON.VertexBuffer.UV6Kind
  18103. * * BABYLON.VertexBuffer.ColorKind
  18104. * * BABYLON.VertexBuffer.MatricesIndicesKind
  18105. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  18106. * * BABYLON.VertexBuffer.MatricesWeightsKind
  18107. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  18108. * @param data defines the data source
  18109. * @param updatable defines if the data must be flagged as updatable (or static)
  18110. * @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
  18111. * @returns the current mesh
  18112. */
  18113. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18114. /**
  18115. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18116. * If the mesh has no geometry, it is simply returned as it is.
  18117. * @param kind defines vertex data kind:
  18118. * * BABYLON.VertexBuffer.PositionKind
  18119. * * BABYLON.VertexBuffer.UVKind
  18120. * * BABYLON.VertexBuffer.UV2Kind
  18121. * * BABYLON.VertexBuffer.UV3Kind
  18122. * * BABYLON.VertexBuffer.UV4Kind
  18123. * * BABYLON.VertexBuffer.UV5Kind
  18124. * * BABYLON.VertexBuffer.UV6Kind
  18125. * * BABYLON.VertexBuffer.ColorKind
  18126. * * BABYLON.VertexBuffer.MatricesIndicesKind
  18127. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  18128. * * BABYLON.VertexBuffer.MatricesWeightsKind
  18129. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  18130. * @param data defines the data source
  18131. * @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
  18132. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  18133. * @returns the current mesh
  18134. */
  18135. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  18136. /**
  18137. * Sets the mesh indices,
  18138. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18139. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  18140. * @param totalVertices Defines the total number of vertices
  18141. * @returns the current mesh
  18142. */
  18143. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  18144. /**
  18145. * Gets a boolean indicating if specific vertex data is present
  18146. * @param kind defines the vertex data kind to use
  18147. * @returns true is data kind is present
  18148. */
  18149. isVerticesDataPresent(kind: string): boolean;
  18150. /**
  18151. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  18152. * @returns a BoundingInfo
  18153. */
  18154. getBoundingInfo(): BoundingInfo;
  18155. /**
  18156. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  18157. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  18158. * @returns the current mesh
  18159. */
  18160. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  18161. /**
  18162. * Overwrite the current bounding info
  18163. * @param boundingInfo defines the new bounding info
  18164. * @returns the current mesh
  18165. */
  18166. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  18167. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  18168. readonly useBones: boolean;
  18169. /** @hidden */
  18170. _preActivate(): void;
  18171. /** @hidden */
  18172. _preActivateForIntermediateRendering(renderId: number): void;
  18173. /** @hidden */
  18174. _activate(renderId: number): void;
  18175. /**
  18176. * Gets the current world matrix
  18177. * @returns a Matrix
  18178. */
  18179. getWorldMatrix(): Matrix;
  18180. /** @hidden */
  18181. _getWorldMatrixDeterminant(): number;
  18182. /**
  18183. * Perform relative position change from the point of view of behind the front of the mesh.
  18184. * This is performed taking into account the meshes current rotation, so you do not have to care.
  18185. * Supports definition of mesh facing forward or backward
  18186. * @param amountRight defines the distance on the right axis
  18187. * @param amountUp defines the distance on the up axis
  18188. * @param amountForward defines the distance on the forward axis
  18189. * @returns the current mesh
  18190. */
  18191. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  18192. /**
  18193. * Calculate relative position change from the point of view of behind the front of the mesh.
  18194. * This is performed taking into account the meshes current rotation, so you do not have to care.
  18195. * Supports definition of mesh facing forward or backward
  18196. * @param amountRight defines the distance on the right axis
  18197. * @param amountUp defines the distance on the up axis
  18198. * @param amountForward defines the distance on the forward axis
  18199. * @returns the new displacement vector
  18200. */
  18201. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  18202. /**
  18203. * Perform relative rotation change from the point of view of behind the front of the mesh.
  18204. * Supports definition of mesh facing forward or backward
  18205. * @param flipBack defines the flip
  18206. * @param twirlClockwise defines the twirl
  18207. * @param tiltRight defines the tilt
  18208. * @returns the current mesh
  18209. */
  18210. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  18211. /**
  18212. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  18213. * Supports definition of mesh facing forward or backward.
  18214. * @param flipBack defines the flip
  18215. * @param twirlClockwise defines the twirl
  18216. * @param tiltRight defines the tilt
  18217. * @returns the new rotation vector
  18218. */
  18219. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  18220. /**
  18221. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  18222. * @param includeDescendants Include bounding info from descendants as well (true by default)
  18223. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  18224. * @returns the new bounding vectors
  18225. */
  18226. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  18227. min: Vector3;
  18228. max: Vector3;
  18229. };
  18230. /** @hidden */
  18231. _updateBoundingInfo(): AbstractMesh;
  18232. /** @hidden */
  18233. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  18234. /** @hidden */
  18235. protected _afterComputeWorldMatrix(): void;
  18236. /**
  18237. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  18238. * A mesh is in the frustum if its bounding box intersects the frustum
  18239. * @param frustumPlanes defines the frustum to test
  18240. * @returns true if the mesh is in the frustum planes
  18241. */
  18242. isInFrustum(frustumPlanes: Plane[]): boolean;
  18243. /**
  18244. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  18245. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  18246. * @param frustumPlanes defines the frustum to test
  18247. * @returns true if the mesh is completely in the frustum planes
  18248. */
  18249. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  18250. /**
  18251. * True if the mesh intersects another mesh or a SolidParticle object
  18252. * @param mesh defines a target mesh or SolidParticle to test
  18253. * @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)
  18254. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  18255. * @returns true if there is an intersection
  18256. */
  18257. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  18258. /**
  18259. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  18260. * @param point defines the point to test
  18261. * @returns true if there is an intersection
  18262. */
  18263. intersectsPoint(point: Vector3): boolean;
  18264. /**
  18265. * Gets the current physics impostor
  18266. * @see http://doc.babylonjs.com/features/physics_engine
  18267. * @returns a physics impostor or null
  18268. */
  18269. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  18270. /**
  18271. * Gets the position of the current mesh in camera space
  18272. * @param camera defines the camera to use
  18273. * @returns a position
  18274. */
  18275. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  18276. /**
  18277. * Returns the distance from the mesh to the active camera
  18278. * @param camera defines the camera to use
  18279. * @returns the distance
  18280. */
  18281. getDistanceToCamera(camera?: Nullable<Camera>): number;
  18282. /**
  18283. * Apply a physic impulse to the mesh
  18284. * @param force defines the force to apply
  18285. * @param contactPoint defines where to apply the force
  18286. * @returns the current mesh
  18287. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18288. */
  18289. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  18290. /**
  18291. * Creates a physic joint between two meshes
  18292. * @param otherMesh defines the other mesh to use
  18293. * @param pivot1 defines the pivot to use on this mesh
  18294. * @param pivot2 defines the pivot to use on the other mesh
  18295. * @param options defines additional options (can be plugin dependent)
  18296. * @returns the current mesh
  18297. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  18298. */
  18299. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  18300. /**
  18301. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  18302. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18303. */
  18304. checkCollisions: boolean;
  18305. /**
  18306. * Gets Collider object used to compute collisions (not physics)
  18307. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18308. */
  18309. readonly collider: Collider;
  18310. /**
  18311. * Move the mesh using collision engine
  18312. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18313. * @param displacement defines the requested displacement vector
  18314. * @returns the current mesh
  18315. */
  18316. moveWithCollisions(displacement: Vector3): AbstractMesh;
  18317. private _onCollisionPositionChange;
  18318. /**
  18319. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  18320. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18321. * @param maxCapacity defines the maximum size of each block (64 by default)
  18322. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  18323. * @returns the new octree
  18324. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  18325. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  18326. */
  18327. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  18328. /** @hidden */
  18329. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  18330. /** @hidden */
  18331. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  18332. /** @hidden */
  18333. _checkCollision(collider: Collider): AbstractMesh;
  18334. /** @hidden */
  18335. _generatePointsArray(): boolean;
  18336. /**
  18337. * Checks if the passed Ray intersects with the mesh
  18338. * @param ray defines the ray to use
  18339. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  18340. * @returns the picking info
  18341. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  18342. */
  18343. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  18344. /**
  18345. * Clones the current mesh
  18346. * @param name defines the mesh name
  18347. * @param newParent defines the new mesh parent
  18348. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  18349. * @returns the new mesh
  18350. */
  18351. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18352. /**
  18353. * Disposes all the submeshes of the current meshnp
  18354. * @returns the current mesh
  18355. */
  18356. releaseSubMeshes(): AbstractMesh;
  18357. /**
  18358. * Releases resources associated with this abstract mesh.
  18359. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18360. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18361. */
  18362. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18363. /**
  18364. * Adds the passed mesh as a child to the current mesh
  18365. * @param mesh defines the child mesh
  18366. * @returns the current mesh
  18367. */
  18368. addChild(mesh: AbstractMesh): AbstractMesh;
  18369. /**
  18370. * Removes the passed mesh from the current mesh children list
  18371. * @param mesh defines the child mesh
  18372. * @returns the current mesh
  18373. */
  18374. removeChild(mesh: AbstractMesh): AbstractMesh;
  18375. /** @hidden */
  18376. private _initFacetData();
  18377. /**
  18378. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  18379. * This method can be called within the render loop.
  18380. * 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
  18381. * @returns the current mesh
  18382. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18383. */
  18384. updateFacetData(): AbstractMesh;
  18385. /**
  18386. * Returns the facetLocalNormals array.
  18387. * The normals are expressed in the mesh local spac
  18388. * @returns an array of Vector3
  18389. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18390. */
  18391. getFacetLocalNormals(): Vector3[];
  18392. /**
  18393. * Returns the facetLocalPositions array.
  18394. * The facet positions are expressed in the mesh local space
  18395. * @returns an array of Vector3
  18396. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18397. */
  18398. getFacetLocalPositions(): Vector3[];
  18399. /**
  18400. * Returns the facetLocalPartioning array
  18401. * @returns an array of array of numbers
  18402. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18403. */
  18404. getFacetLocalPartitioning(): number[][];
  18405. /**
  18406. * Returns the i-th facet position in the world system.
  18407. * This method allocates a new Vector3 per call
  18408. * @param i defines the facet index
  18409. * @returns a new Vector3
  18410. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18411. */
  18412. getFacetPosition(i: number): Vector3;
  18413. /**
  18414. * Sets the reference Vector3 with the i-th facet position in the world system
  18415. * @param i defines the facet index
  18416. * @param ref defines the target vector
  18417. * @returns the current mesh
  18418. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18419. */
  18420. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  18421. /**
  18422. * Returns the i-th facet normal in the world system.
  18423. * This method allocates a new Vector3 per call
  18424. * @param i defines the facet index
  18425. * @returns a new Vector3
  18426. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18427. */
  18428. getFacetNormal(i: number): Vector3;
  18429. /**
  18430. * Sets the reference Vector3 with the i-th facet normal in the world system
  18431. * @param i defines the facet index
  18432. * @param ref defines the target vector
  18433. * @returns the current mesh
  18434. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18435. */
  18436. getFacetNormalToRef(i: number, ref: Vector3): this;
  18437. /**
  18438. * 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)
  18439. * @param x defines x coordinate
  18440. * @param y defines y coordinate
  18441. * @param z defines z coordinate
  18442. * @returns the array of facet indexes
  18443. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18444. */
  18445. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  18446. /**
  18447. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  18448. * @param projected sets as the (x,y,z) world projection on the facet
  18449. * @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
  18450. * @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
  18451. * @param x defines x coordinate
  18452. * @param y defines y coordinate
  18453. * @param z defines z coordinate
  18454. * @returns the face index if found (or null instead)
  18455. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18456. */
  18457. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  18458. /**
  18459. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  18460. * @param projected sets as the (x,y,z) local projection on the facet
  18461. * @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
  18462. * @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
  18463. * @param x defines x coordinate
  18464. * @param y defines y coordinate
  18465. * @param z defines z coordinate
  18466. * @returns the face index if found (or null instead)
  18467. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18468. */
  18469. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  18470. /**
  18471. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  18472. * @returns the parameters
  18473. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18474. */
  18475. getFacetDataParameters(): any;
  18476. /**
  18477. * Disables the feature FacetData and frees the related memory
  18478. * @returns the current mesh
  18479. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18480. */
  18481. disableFacetData(): AbstractMesh;
  18482. /**
  18483. * Updates the AbstractMesh indices array
  18484. * @param indices defines the data source
  18485. * @returns the current mesh
  18486. */
  18487. updateIndices(indices: IndicesArray): AbstractMesh;
  18488. /**
  18489. * Creates new normals data for the mesh
  18490. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  18491. * @returns the current mesh
  18492. */
  18493. createNormals(updatable: boolean): AbstractMesh;
  18494. /**
  18495. * Align the mesh with a normal
  18496. * @param normal defines the normal to use
  18497. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  18498. * @returns the current mesh
  18499. */
  18500. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  18501. /** @hidden */
  18502. protected _checkOcclusionQuery(): void;
  18503. }
  18504. }
  18505. declare module BABYLON {
  18506. class Buffer {
  18507. private _engine;
  18508. private _buffer;
  18509. private _data;
  18510. private _updatable;
  18511. private _instanced;
  18512. /**
  18513. * Gets the byte stride.
  18514. */
  18515. readonly byteStride: number;
  18516. /**
  18517. * Constructor
  18518. * @param engine the engine
  18519. * @param data the data to use for this buffer
  18520. * @param updatable whether the data is updatable
  18521. * @param stride the stride (optional)
  18522. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  18523. * @param instanced whether the buffer is instanced (optional)
  18524. * @param useBytes set to true if the stride in in bytes (optional)
  18525. */
  18526. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  18527. /**
  18528. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  18529. * @param kind defines the vertex buffer kind (position, normal, etc.)
  18530. * @param offset defines offset in the buffer (0 by default)
  18531. * @param size defines the size in floats of attributes (position is 3 for instance)
  18532. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  18533. * @param instanced defines if the vertex buffer contains indexed data
  18534. * @param useBytes defines if the offset and stride are in bytes
  18535. * @returns the new vertex buffer
  18536. */
  18537. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  18538. isUpdatable(): boolean;
  18539. getData(): Nullable<DataArray>;
  18540. getBuffer(): Nullable<WebGLBuffer>;
  18541. /**
  18542. * Gets the stride in float32 units (i.e. byte stride / 4).
  18543. * May not be an integer if the byte stride is not divisible by 4.
  18544. * DEPRECATED. Use byteStride instead.
  18545. * @returns the stride in float32 units
  18546. */
  18547. getStrideSize(): number;
  18548. create(data?: Nullable<DataArray>): void;
  18549. _rebuild(): void;
  18550. update(data: DataArray): void;
  18551. /**
  18552. * Updates the data directly.
  18553. * @param data the new data
  18554. * @param offset the new offset
  18555. * @param vertexCount the vertex count (optional)
  18556. * @param useBytes set to true if the offset is in bytes
  18557. */
  18558. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  18559. dispose(): void;
  18560. }
  18561. }
  18562. declare module BABYLON {
  18563. class CSG {
  18564. private polygons;
  18565. matrix: Matrix;
  18566. position: Vector3;
  18567. rotation: Vector3;
  18568. rotationQuaternion: Nullable<Quaternion>;
  18569. scaling: Vector3;
  18570. static FromMesh(mesh: Mesh): CSG;
  18571. private static FromPolygons(polygons);
  18572. clone(): CSG;
  18573. union(csg: CSG): CSG;
  18574. unionInPlace(csg: CSG): void;
  18575. subtract(csg: CSG): CSG;
  18576. subtractInPlace(csg: CSG): void;
  18577. intersect(csg: CSG): CSG;
  18578. intersectInPlace(csg: CSG): void;
  18579. inverse(): CSG;
  18580. inverseInPlace(): void;
  18581. copyTransformAttributes(csg: CSG): CSG;
  18582. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  18583. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  18584. }
  18585. }
  18586. declare module BABYLON {
  18587. /**
  18588. * Class used to store geometry data (vertex buffers + index buffer)
  18589. */
  18590. class Geometry implements IGetSetVerticesData {
  18591. /**
  18592. * Gets or sets the unique ID of the geometry
  18593. */
  18594. id: string;
  18595. /**
  18596. * Gets the delay loading state of the geometry (none by default which means not delayed)
  18597. */
  18598. delayLoadState: number;
  18599. /**
  18600. * Gets the file containing the data to load when running in delay load state
  18601. */
  18602. delayLoadingFile: Nullable<string>;
  18603. /**
  18604. * Callback called when the geometry is updated
  18605. */
  18606. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  18607. private _scene;
  18608. private _engine;
  18609. private _meshes;
  18610. private _totalVertices;
  18611. private _indices;
  18612. private _vertexBuffers;
  18613. private _isDisposed;
  18614. private _extend;
  18615. private _boundingBias;
  18616. /** @hidden */
  18617. _delayInfo: Array<string>;
  18618. private _indexBuffer;
  18619. private _indexBufferIsUpdatable;
  18620. /** @hidden */
  18621. _boundingInfo: Nullable<BoundingInfo>;
  18622. /** @hidden */
  18623. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  18624. /** @hidden */
  18625. _softwareSkinningRenderId: number;
  18626. private _vertexArrayObjects;
  18627. private _updatable;
  18628. /** @hidden */
  18629. _positions: Nullable<Vector3[]>;
  18630. /**
  18631. * 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
  18632. */
  18633. /**
  18634. * 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
  18635. */
  18636. boundingBias: Vector2;
  18637. /**
  18638. * Static function used to attach a new empty geometry to a mesh
  18639. * @param mesh defines the mesh to attach the geometry to
  18640. * @returns the new {BABYLON.Geometry}
  18641. */
  18642. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  18643. /**
  18644. * Creates a new geometry
  18645. * @param id defines the unique ID
  18646. * @param scene defines the hosting scene
  18647. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  18648. * @param updatable defines if geometry must be updatable (false by default)
  18649. * @param mesh defines the mesh that will be associated with the geometry
  18650. */
  18651. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  18652. /**
  18653. * Gets the current extend of the geometry
  18654. */
  18655. readonly extend: {
  18656. minimum: Vector3;
  18657. maximum: Vector3;
  18658. };
  18659. /**
  18660. * Gets the hosting scene
  18661. * @returns the hosting {BABYLON.Scene}
  18662. */
  18663. getScene(): Scene;
  18664. /**
  18665. * Gets the hosting engine
  18666. * @returns the hosting {BABYLON.Engine}
  18667. */
  18668. getEngine(): Engine;
  18669. /**
  18670. * Defines if the geometry is ready to use
  18671. * @returns true if the geometry is ready to be used
  18672. */
  18673. isReady(): boolean;
  18674. /**
  18675. * Gets a value indicating that the geometry should not be serialized
  18676. */
  18677. readonly doNotSerialize: boolean;
  18678. /** @hidden */
  18679. _rebuild(): void;
  18680. /**
  18681. * Affects all gemetry data in one call
  18682. * @param vertexData defines the geometry data
  18683. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  18684. */
  18685. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  18686. /**
  18687. * Set specific vertex data
  18688. * @param kind defines the data kind (Position, normal, etc...)
  18689. * @param data defines the vertex data to use
  18690. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  18691. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  18692. */
  18693. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  18694. /**
  18695. * Removes a specific vertex data
  18696. * @param kind defines the data kind (Position, normal, etc...)
  18697. */
  18698. removeVerticesData(kind: string): void;
  18699. /**
  18700. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  18701. * @param buffer defines the vertex buffer to use
  18702. * @param totalVertices defines the total number of vertices for position kind (could be null)
  18703. */
  18704. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  18705. /**
  18706. * Update a specific vertex buffer
  18707. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  18708. * It will do nothing if the buffer is not updatable
  18709. * @param kind defines the data kind (Position, normal, etc...)
  18710. * @param data defines the data to use
  18711. * @param offset defines the offset in the target buffer where to store the data
  18712. * @param useBytes set to true if the offset is in bytes
  18713. */
  18714. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  18715. /**
  18716. * Update a specific vertex buffer
  18717. * This function will create a new buffer if the current one is not updatable
  18718. * @param kind defines the data kind (Position, normal, etc...)
  18719. * @param data defines the data to use
  18720. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  18721. */
  18722. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  18723. private _updateBoundingInfo(updateExtends, data);
  18724. /** @hidden */
  18725. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  18726. /**
  18727. * Gets total number of vertices
  18728. * @returns the total number of vertices
  18729. */
  18730. getTotalVertices(): number;
  18731. /**
  18732. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  18733. * @param kind defines the data kind (Position, normal, etc...)
  18734. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  18735. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  18736. * @returns a float array containing vertex data
  18737. */
  18738. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  18739. /**
  18740. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  18741. * @param kind defines the data kind (Position, normal, etc...)
  18742. * @returns true if the vertex buffer with the specified kind is updatable
  18743. */
  18744. isVertexBufferUpdatable(kind: string): boolean;
  18745. /**
  18746. * Gets a specific vertex buffer
  18747. * @param kind defines the data kind (Position, normal, etc...)
  18748. * @returns a {BABYLON.VertexBuffer}
  18749. */
  18750. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  18751. /**
  18752. * Returns all vertex buffers
  18753. * @return an object holding all vertex buffers indexed by kind
  18754. */
  18755. getVertexBuffers(): Nullable<{
  18756. [key: string]: VertexBuffer;
  18757. }>;
  18758. /**
  18759. * Gets a boolean indicating if specific vertex buffer is present
  18760. * @param kind defines the data kind (Position, normal, etc...)
  18761. * @returns true if data is present
  18762. */
  18763. isVerticesDataPresent(kind: string): boolean;
  18764. /**
  18765. * Gets a list of all attached data kinds (Position, normal, etc...)
  18766. * @returns a list of string containing all kinds
  18767. */
  18768. getVerticesDataKinds(): string[];
  18769. /**
  18770. * Update index buffer
  18771. * @param indices defines the indices to store in the index buffer
  18772. * @param offset defines the offset in the target buffer where to store the data
  18773. */
  18774. updateIndices(indices: IndicesArray, offset?: number): void;
  18775. /**
  18776. * Creates a new index buffer
  18777. * @param indices defines the indices to store in the index buffer
  18778. * @param totalVertices defines the total number of vertices (could be null)
  18779. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  18780. */
  18781. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  18782. /**
  18783. * Return the total number of indices
  18784. * @returns the total number of indices
  18785. */
  18786. getTotalIndices(): number;
  18787. /**
  18788. * Gets the index buffer array
  18789. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  18790. * @returns the index buffer array
  18791. */
  18792. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  18793. /**
  18794. * Gets the index buffer
  18795. * @return the index buffer
  18796. */
  18797. getIndexBuffer(): Nullable<WebGLBuffer>;
  18798. /** @hidden */
  18799. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  18800. /**
  18801. * Release the associated resources for a specific mesh
  18802. * @param mesh defines the source mesh
  18803. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  18804. */
  18805. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  18806. /**
  18807. * Apply current geometry to a given mesh
  18808. * @param mesh defines the mesh to apply geometry to
  18809. */
  18810. applyToMesh(mesh: Mesh): void;
  18811. private _updateExtend(data?);
  18812. private _applyToMesh(mesh);
  18813. private notifyUpdate(kind?);
  18814. /**
  18815. * Load the geometry if it was flagged as delay loaded
  18816. * @param scene defines the hosting scene
  18817. * @param onLoaded defines a callback called when the geometry is loaded
  18818. */
  18819. load(scene: Scene, onLoaded?: () => void): void;
  18820. private _queueLoad(scene, onLoaded?);
  18821. /**
  18822. * Invert the geometry to move from a right handed system to a left handed one.
  18823. */
  18824. toLeftHanded(): void;
  18825. /** @hidden */
  18826. _resetPointsArrayCache(): void;
  18827. /** @hidden */
  18828. _generatePointsArray(): boolean;
  18829. /**
  18830. * Gets a value indicating if the geometry is disposed
  18831. * @returns true if the geometry was disposed
  18832. */
  18833. isDisposed(): boolean;
  18834. private _disposeVertexArrayObjects();
  18835. /**
  18836. * Free all associated resources
  18837. */
  18838. dispose(): void;
  18839. /**
  18840. * Clone the current geometry into a new geometry
  18841. * @param id defines the unique ID of the new geometry
  18842. * @returns a new geometry object
  18843. */
  18844. copy(id: string): Geometry;
  18845. /**
  18846. * Serialize the current geometry info (and not the vertices data) into a JSON object
  18847. * @return a JSON representation of the current geometry data (without the vertices data)
  18848. */
  18849. serialize(): any;
  18850. private toNumberArray(origin);
  18851. /**
  18852. * Serialize all vertices data into a JSON oject
  18853. * @returns a JSON representation of the current geometry data
  18854. */
  18855. serializeVerticeData(): any;
  18856. /**
  18857. * Extracts a clone of a mesh geometry
  18858. * @param mesh defines the source mesh
  18859. * @param id defines the unique ID of the new geometry object
  18860. * @returns the new geometry object
  18861. */
  18862. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  18863. /**
  18864. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  18865. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  18866. * Be aware Math.random() could cause collisions, but:
  18867. * "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"
  18868. * @returns a string containing a new GUID
  18869. */
  18870. static RandomId(): string;
  18871. /** @hidden */
  18872. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  18873. private static _CleanMatricesWeights(parsedGeometry, mesh);
  18874. /**
  18875. * Create a new geometry from persisted data (Using .babylon file format)
  18876. * @param parsedVertexData defines the persisted data
  18877. * @param scene defines the hosting scene
  18878. * @param rootUrl defines the root url to use to load assets (like delayed data)
  18879. * @returns the new geometry object
  18880. */
  18881. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  18882. }
  18883. /**
  18884. * Abstract class used to provide common services for all typed geometries
  18885. * @hidden
  18886. */
  18887. class _PrimitiveGeometry extends Geometry {
  18888. private _canBeRegenerated;
  18889. private _beingRegenerated;
  18890. /**
  18891. * Creates a new typed geometry
  18892. * @param id defines the unique ID of the geometry
  18893. * @param scene defines the hosting scene
  18894. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  18895. * @param mesh defines the hosting mesh (can be null)
  18896. */
  18897. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  18898. /**
  18899. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  18900. * @returns true if the geometry can be regenerated
  18901. */
  18902. canBeRegenerated(): boolean;
  18903. /**
  18904. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  18905. */
  18906. regenerate(): void;
  18907. /**
  18908. * Clone the geometry
  18909. * @param id defines the unique ID of the new geometry
  18910. * @returns the new geometry
  18911. */
  18912. asNewGeometry(id: string): Geometry;
  18913. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  18914. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  18915. /** @hidden */
  18916. _regenerateVertexData(): VertexData;
  18917. copy(id: string): Geometry;
  18918. serialize(): any;
  18919. }
  18920. /**
  18921. * Creates a ribbon geometry
  18922. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  18923. */
  18924. class RibbonGeometry extends _PrimitiveGeometry {
  18925. /**
  18926. * Defines the array of paths to use
  18927. */
  18928. pathArray: Vector3[][];
  18929. /**
  18930. * Defines if the last and first points of each path in your pathArray must be joined
  18931. */
  18932. closeArray: boolean;
  18933. /**
  18934. * Defines if the last and first points of each path in your pathArray must be joined
  18935. */
  18936. closePath: boolean;
  18937. /**
  18938. * Defines the offset between points
  18939. */
  18940. offset: number;
  18941. /**
  18942. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18943. */
  18944. side: number;
  18945. /**
  18946. * Creates a ribbon geometry
  18947. * @param id defines the unique ID of the geometry
  18948. * @param scene defines the hosting scene
  18949. * @param pathArray defines the array of paths to use
  18950. * @param closeArray defines if the last path and the first path must be joined
  18951. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  18952. * @param offset defines the offset between points
  18953. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  18954. * @param mesh defines the hosting mesh (can be null)
  18955. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18956. */
  18957. constructor(id: string, scene: Scene,
  18958. /**
  18959. * Defines the array of paths to use
  18960. */
  18961. pathArray: Vector3[][],
  18962. /**
  18963. * Defines if the last and first points of each path in your pathArray must be joined
  18964. */
  18965. closeArray: boolean,
  18966. /**
  18967. * Defines if the last and first points of each path in your pathArray must be joined
  18968. */
  18969. closePath: boolean,
  18970. /**
  18971. * Defines the offset between points
  18972. */
  18973. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  18974. /**
  18975. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18976. */
  18977. side?: number);
  18978. /** @hidden */
  18979. _regenerateVertexData(): VertexData;
  18980. copy(id: string): Geometry;
  18981. }
  18982. /**
  18983. * Creates a box geometry
  18984. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  18985. */
  18986. class BoxGeometry extends _PrimitiveGeometry {
  18987. /**
  18988. * Defines the zise of the box (width, height and depth are the same)
  18989. */
  18990. size: number;
  18991. /**
  18992. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  18993. */
  18994. side: number;
  18995. /**
  18996. * Creates a box geometry
  18997. * @param id defines the unique ID of the geometry
  18998. * @param scene defines the hosting scene
  18999. * @param size defines the zise of the box (width, height and depth are the same)
  19000. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19001. * @param mesh defines the hosting mesh (can be null)
  19002. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19003. */
  19004. constructor(id: string, scene: Scene,
  19005. /**
  19006. * Defines the zise of the box (width, height and depth are the same)
  19007. */
  19008. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19009. /**
  19010. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19011. */
  19012. side?: number);
  19013. _regenerateVertexData(): VertexData;
  19014. copy(id: string): Geometry;
  19015. serialize(): any;
  19016. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  19017. }
  19018. /**
  19019. * Creates a sphere geometry
  19020. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  19021. */
  19022. class SphereGeometry extends _PrimitiveGeometry {
  19023. /**
  19024. * Defines the number of segments to use to create the sphere
  19025. */
  19026. segments: number;
  19027. /**
  19028. * Defines the diameter of the sphere
  19029. */
  19030. diameter: number;
  19031. /**
  19032. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19033. */
  19034. side: number;
  19035. /**
  19036. * Create a new sphere geometry
  19037. * @param id defines the unique ID of the geometry
  19038. * @param scene defines the hosting scene
  19039. * @param segments defines the number of segments to use to create the sphere
  19040. * @param diameter defines the diameter of the sphere
  19041. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19042. * @param mesh defines the hosting mesh (can be null)
  19043. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19044. */
  19045. constructor(id: string, scene: Scene,
  19046. /**
  19047. * Defines the number of segments to use to create the sphere
  19048. */
  19049. segments: number,
  19050. /**
  19051. * Defines the diameter of the sphere
  19052. */
  19053. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19054. /**
  19055. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19056. */
  19057. side?: number);
  19058. _regenerateVertexData(): VertexData;
  19059. copy(id: string): Geometry;
  19060. serialize(): any;
  19061. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  19062. }
  19063. /**
  19064. * Creates a disc geometry
  19065. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  19066. */
  19067. class DiscGeometry extends _PrimitiveGeometry {
  19068. /**
  19069. * Defines the radius of the disc
  19070. */
  19071. radius: number;
  19072. /**
  19073. * Defines the tesselation factor to apply to the disc
  19074. */
  19075. tessellation: number;
  19076. /**
  19077. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19078. */
  19079. side: number;
  19080. /**
  19081. * Creates a new disc geometry
  19082. * @param id defines the unique ID of the geometry
  19083. * @param scene defines the hosting scene
  19084. * @param radius defines the radius of the disc
  19085. * @param tessellation defines the tesselation factor to apply to the disc
  19086. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19087. * @param mesh defines the hosting mesh (can be null)
  19088. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19089. */
  19090. constructor(id: string, scene: Scene,
  19091. /**
  19092. * Defines the radius of the disc
  19093. */
  19094. radius: number,
  19095. /**
  19096. * Defines the tesselation factor to apply to the disc
  19097. */
  19098. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19099. /**
  19100. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19101. */
  19102. side?: number);
  19103. _regenerateVertexData(): VertexData;
  19104. copy(id: string): Geometry;
  19105. }
  19106. /**
  19107. * Creates a new cylinder geometry
  19108. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  19109. */
  19110. class CylinderGeometry extends _PrimitiveGeometry {
  19111. /**
  19112. * Defines the height of the cylinder
  19113. */
  19114. height: number;
  19115. /**
  19116. * Defines the diameter of the cylinder's top cap
  19117. */
  19118. diameterTop: number;
  19119. /**
  19120. * Defines the diameter of the cylinder's bottom cap
  19121. */
  19122. diameterBottom: number;
  19123. /**
  19124. * Defines the tessellation factor to apply to the cylinder
  19125. */
  19126. tessellation: number;
  19127. /**
  19128. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  19129. */
  19130. subdivisions: number;
  19131. /**
  19132. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19133. */
  19134. side: number;
  19135. /**
  19136. * Creates a new cylinder geometry
  19137. * @param id defines the unique ID of the geometry
  19138. * @param scene defines the hosting scene
  19139. * @param height defines the height of the cylinder
  19140. * @param diameterTop defines the diameter of the cylinder's top cap
  19141. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  19142. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  19143. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  19144. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19145. * @param mesh defines the hosting mesh (can be null)
  19146. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19147. */
  19148. constructor(id: string, scene: Scene,
  19149. /**
  19150. * Defines the height of the cylinder
  19151. */
  19152. height: number,
  19153. /**
  19154. * Defines the diameter of the cylinder's top cap
  19155. */
  19156. diameterTop: number,
  19157. /**
  19158. * Defines the diameter of the cylinder's bottom cap
  19159. */
  19160. diameterBottom: number,
  19161. /**
  19162. * Defines the tessellation factor to apply to the cylinder
  19163. */
  19164. tessellation: number,
  19165. /**
  19166. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  19167. */
  19168. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19169. /**
  19170. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19171. */
  19172. side?: number);
  19173. _regenerateVertexData(): VertexData;
  19174. copy(id: string): Geometry;
  19175. serialize(): any;
  19176. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  19177. }
  19178. /**
  19179. * Creates a new torus geometry
  19180. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  19181. */
  19182. class TorusGeometry extends _PrimitiveGeometry {
  19183. /**
  19184. * Defines the diameter of the torus
  19185. */
  19186. diameter: number;
  19187. /**
  19188. * Defines the thickness of the torus (ie. internal diameter)
  19189. */
  19190. thickness: number;
  19191. /**
  19192. * Defines the tesselation factor to apply to the torus
  19193. */
  19194. tessellation: number;
  19195. /**
  19196. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19197. */
  19198. side: number;
  19199. /**
  19200. * Creates a new torus geometry
  19201. * @param id defines the unique ID of the geometry
  19202. * @param scene defines the hosting scene
  19203. * @param diameter defines the diameter of the torus
  19204. * @param thickness defines the thickness of the torus (ie. internal diameter)
  19205. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  19206. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19207. * @param mesh defines the hosting mesh (can be null)
  19208. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19209. */
  19210. constructor(id: string, scene: Scene,
  19211. /**
  19212. * Defines the diameter of the torus
  19213. */
  19214. diameter: number,
  19215. /**
  19216. * Defines the thickness of the torus (ie. internal diameter)
  19217. */
  19218. thickness: number,
  19219. /**
  19220. * Defines the tesselation factor to apply to the torus
  19221. */
  19222. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19223. /**
  19224. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19225. */
  19226. side?: number);
  19227. _regenerateVertexData(): VertexData;
  19228. copy(id: string): Geometry;
  19229. serialize(): any;
  19230. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  19231. }
  19232. /**
  19233. * Creates a new ground geometry
  19234. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  19235. */
  19236. class GroundGeometry extends _PrimitiveGeometry {
  19237. /**
  19238. * Defines the width of the ground
  19239. */
  19240. width: number;
  19241. /**
  19242. * Defines the height of the ground
  19243. */
  19244. height: number;
  19245. /**
  19246. * Defines the subdivisions to apply to the ground
  19247. */
  19248. subdivisions: number;
  19249. /**
  19250. * Creates a new ground geometry
  19251. * @param id defines the unique ID of the geometry
  19252. * @param scene defines the hosting scene
  19253. * @param width defines the width of the ground
  19254. * @param height defines the height of the ground
  19255. * @param subdivisions defines the subdivisions to apply to the ground
  19256. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19257. * @param mesh defines the hosting mesh (can be null)
  19258. */
  19259. constructor(id: string, scene: Scene,
  19260. /**
  19261. * Defines the width of the ground
  19262. */
  19263. width: number,
  19264. /**
  19265. * Defines the height of the ground
  19266. */
  19267. height: number,
  19268. /**
  19269. * Defines the subdivisions to apply to the ground
  19270. */
  19271. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  19272. _regenerateVertexData(): VertexData;
  19273. copy(id: string): Geometry;
  19274. serialize(): any;
  19275. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  19276. }
  19277. /**
  19278. * Creates a tiled ground geometry
  19279. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  19280. */
  19281. class TiledGroundGeometry extends _PrimitiveGeometry {
  19282. /**
  19283. * Defines the minimum value on X axis
  19284. */
  19285. xmin: number;
  19286. /**
  19287. * Defines the minimum value on Z axis
  19288. */
  19289. zmin: number;
  19290. /**
  19291. * Defines the maximum value on X axis
  19292. */
  19293. xmax: number;
  19294. /**
  19295. * Defines the maximum value on Z axis
  19296. */
  19297. zmax: number;
  19298. /**
  19299. * Defines the subdivisions to apply to the ground
  19300. */
  19301. subdivisions: {
  19302. w: number;
  19303. h: number;
  19304. };
  19305. /**
  19306. * Defines the precision to use when computing the tiles
  19307. */
  19308. precision: {
  19309. w: number;
  19310. h: number;
  19311. };
  19312. /**
  19313. * Creates a tiled ground geometry
  19314. * @param id defines the unique ID of the geometry
  19315. * @param scene defines the hosting scene
  19316. * @param xmin defines the minimum value on X axis
  19317. * @param zmin defines the minimum value on Z axis
  19318. * @param xmax defines the maximum value on X axis
  19319. * @param zmax defines the maximum value on Z axis
  19320. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  19321. * @param precision defines the precision to use when computing the tiles
  19322. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19323. * @param mesh defines the hosting mesh (can be null)
  19324. */
  19325. constructor(id: string, scene: Scene,
  19326. /**
  19327. * Defines the minimum value on X axis
  19328. */
  19329. xmin: number,
  19330. /**
  19331. * Defines the minimum value on Z axis
  19332. */
  19333. zmin: number,
  19334. /**
  19335. * Defines the maximum value on X axis
  19336. */
  19337. xmax: number,
  19338. /**
  19339. * Defines the maximum value on Z axis
  19340. */
  19341. zmax: number,
  19342. /**
  19343. * Defines the subdivisions to apply to the ground
  19344. */
  19345. subdivisions: {
  19346. w: number;
  19347. h: number;
  19348. },
  19349. /**
  19350. * Defines the precision to use when computing the tiles
  19351. */
  19352. precision: {
  19353. w: number;
  19354. h: number;
  19355. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  19356. _regenerateVertexData(): VertexData;
  19357. copy(id: string): Geometry;
  19358. }
  19359. /**
  19360. * Creates a plane geometry
  19361. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  19362. */
  19363. class PlaneGeometry extends _PrimitiveGeometry {
  19364. /**
  19365. * Defines the size of the plane (width === height)
  19366. */
  19367. size: number;
  19368. /**
  19369. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19370. */
  19371. side: number;
  19372. /**
  19373. * Creates a plane geometry
  19374. * @param id defines the unique ID of the geometry
  19375. * @param scene defines the hosting scene
  19376. * @param size defines the size of the plane (width === height)
  19377. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19378. * @param mesh defines the hosting mesh (can be null)
  19379. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19380. */
  19381. constructor(id: string, scene: Scene,
  19382. /**
  19383. * Defines the size of the plane (width === height)
  19384. */
  19385. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19386. /**
  19387. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19388. */
  19389. side?: number);
  19390. _regenerateVertexData(): VertexData;
  19391. copy(id: string): Geometry;
  19392. serialize(): any;
  19393. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  19394. }
  19395. /**
  19396. * Creates a torus knot geometry
  19397. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  19398. */
  19399. class TorusKnotGeometry extends _PrimitiveGeometry {
  19400. /**
  19401. * Defines the radius of the torus knot
  19402. */
  19403. radius: number;
  19404. /**
  19405. * Defines the thickness of the torus knot tube
  19406. */
  19407. tube: number;
  19408. /**
  19409. * Defines the number of radial segments
  19410. */
  19411. radialSegments: number;
  19412. /**
  19413. * Defines the number of tubular segments
  19414. */
  19415. tubularSegments: number;
  19416. /**
  19417. * Defines the first number of windings
  19418. */
  19419. p: number;
  19420. /**
  19421. * Defines the second number of windings
  19422. */
  19423. q: number;
  19424. /**
  19425. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19426. */
  19427. side: number;
  19428. /**
  19429. * Creates a torus knot geometry
  19430. * @param id defines the unique ID of the geometry
  19431. * @param scene defines the hosting scene
  19432. * @param radius defines the radius of the torus knot
  19433. * @param tube defines the thickness of the torus knot tube
  19434. * @param radialSegments defines the number of radial segments
  19435. * @param tubularSegments defines the number of tubular segments
  19436. * @param p defines the first number of windings
  19437. * @param q defines the second number of windings
  19438. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19439. * @param mesh defines the hosting mesh (can be null)
  19440. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19441. */
  19442. constructor(id: string, scene: Scene,
  19443. /**
  19444. * Defines the radius of the torus knot
  19445. */
  19446. radius: number,
  19447. /**
  19448. * Defines the thickness of the torus knot tube
  19449. */
  19450. tube: number,
  19451. /**
  19452. * Defines the number of radial segments
  19453. */
  19454. radialSegments: number,
  19455. /**
  19456. * Defines the number of tubular segments
  19457. */
  19458. tubularSegments: number,
  19459. /**
  19460. * Defines the first number of windings
  19461. */
  19462. p: number,
  19463. /**
  19464. * Defines the second number of windings
  19465. */
  19466. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19467. /**
  19468. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19469. */
  19470. side?: number);
  19471. _regenerateVertexData(): VertexData;
  19472. copy(id: string): Geometry;
  19473. serialize(): any;
  19474. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  19475. }
  19476. }
  19477. declare module BABYLON {
  19478. class GroundMesh extends Mesh {
  19479. generateOctree: boolean;
  19480. private _heightQuads;
  19481. _subdivisionsX: number;
  19482. _subdivisionsY: number;
  19483. _width: number;
  19484. _height: number;
  19485. _minX: number;
  19486. _maxX: number;
  19487. _minZ: number;
  19488. _maxZ: number;
  19489. constructor(name: string, scene: Scene);
  19490. getClassName(): string;
  19491. readonly subdivisions: number;
  19492. readonly subdivisionsX: number;
  19493. readonly subdivisionsY: number;
  19494. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19495. /**
  19496. * Returns a height (y) value in the Worl system :
  19497. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19498. * Returns the ground y position if (x, z) are outside the ground surface.
  19499. */
  19500. getHeightAtCoordinates(x: number, z: number): number;
  19501. /**
  19502. * Returns a normalized vector (Vector3) orthogonal to the ground
  19503. * at the ground coordinates (x, z) expressed in the World system.
  19504. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19505. */
  19506. getNormalAtCoordinates(x: number, z: number): Vector3;
  19507. /**
  19508. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19509. * at the ground coordinates (x, z) expressed in the World system.
  19510. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19511. * Returns the GroundMesh.
  19512. */
  19513. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19514. /**
  19515. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19516. * if the ground has been updated.
  19517. * This can be used in the render loop.
  19518. * Returns the GroundMesh.
  19519. */
  19520. updateCoordinateHeights(): GroundMesh;
  19521. private _getFacetAt(x, z);
  19522. private _initHeightQuads();
  19523. private _computeHeightQuads();
  19524. serialize(serializationObject: any): void;
  19525. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19526. }
  19527. }
  19528. declare module BABYLON {
  19529. /**
  19530. * Creates an instance based on a source mesh.
  19531. */
  19532. class InstancedMesh extends AbstractMesh {
  19533. private _sourceMesh;
  19534. private _currentLOD;
  19535. constructor(name: string, source: Mesh);
  19536. /**
  19537. * Returns the string "InstancedMesh".
  19538. */
  19539. getClassName(): string;
  19540. readonly receiveShadows: boolean;
  19541. readonly material: Nullable<Material>;
  19542. readonly visibility: number;
  19543. readonly skeleton: Nullable<Skeleton>;
  19544. renderingGroupId: number;
  19545. /**
  19546. * Returns the total number of vertices (integer).
  19547. */
  19548. getTotalVertices(): number;
  19549. readonly sourceMesh: Mesh;
  19550. /**
  19551. * Is this node ready to be used/rendered
  19552. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19553. * @return {boolean} is it ready
  19554. */
  19555. isReady(completeCheck?: boolean): boolean;
  19556. /**
  19557. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19558. */
  19559. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19560. /**
  19561. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19562. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19563. * The `data` are either a numeric array either a Float32Array.
  19564. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19565. * 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).
  19566. * Note that a new underlying VertexBuffer object is created each call.
  19567. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19568. *
  19569. * Possible `kind` values :
  19570. * - BABYLON.VertexBuffer.PositionKind
  19571. * - BABYLON.VertexBuffer.UVKind
  19572. * - BABYLON.VertexBuffer.UV2Kind
  19573. * - BABYLON.VertexBuffer.UV3Kind
  19574. * - BABYLON.VertexBuffer.UV4Kind
  19575. * - BABYLON.VertexBuffer.UV5Kind
  19576. * - BABYLON.VertexBuffer.UV6Kind
  19577. * - BABYLON.VertexBuffer.ColorKind
  19578. * - BABYLON.VertexBuffer.MatricesIndicesKind
  19579. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19580. * - BABYLON.VertexBuffer.MatricesWeightsKind
  19581. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19582. *
  19583. * Returns the Mesh.
  19584. */
  19585. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19586. /**
  19587. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19588. * If the mesh has no geometry, it is simply returned as it is.
  19589. * The `data` are either a numeric array either a Float32Array.
  19590. * No new underlying VertexBuffer object is created.
  19591. * 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.
  19592. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19593. *
  19594. * Possible `kind` values :
  19595. * - BABYLON.VertexBuffer.PositionKind
  19596. * - BABYLON.VertexBuffer.UVKind
  19597. * - BABYLON.VertexBuffer.UV2Kind
  19598. * - BABYLON.VertexBuffer.UV3Kind
  19599. * - BABYLON.VertexBuffer.UV4Kind
  19600. * - BABYLON.VertexBuffer.UV5Kind
  19601. * - BABYLON.VertexBuffer.UV6Kind
  19602. * - BABYLON.VertexBuffer.ColorKind
  19603. * - BABYLON.VertexBuffer.MatricesIndicesKind
  19604. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19605. * - BABYLON.VertexBuffer.MatricesWeightsKind
  19606. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19607. *
  19608. * Returns the Mesh.
  19609. */
  19610. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19611. /**
  19612. * Sets the mesh indices.
  19613. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19614. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19615. * This method creates a new index buffer each call.
  19616. * Returns the Mesh.
  19617. */
  19618. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19619. /**
  19620. * Boolean : True if the mesh owns the requested kind of data.
  19621. */
  19622. isVerticesDataPresent(kind: string): boolean;
  19623. /**
  19624. * Returns an array of indices (IndicesArray).
  19625. */
  19626. getIndices(): Nullable<IndicesArray>;
  19627. readonly _positions: Nullable<Vector3[]>;
  19628. /**
  19629. * Sets a new updated BoundingInfo to the mesh.
  19630. * Returns the mesh.
  19631. */
  19632. refreshBoundingInfo(): InstancedMesh;
  19633. _preActivate(): InstancedMesh;
  19634. _activate(renderId: number): InstancedMesh;
  19635. /**
  19636. * Returns the current associated LOD AbstractMesh.
  19637. */
  19638. getLOD(camera: Camera): AbstractMesh;
  19639. _syncSubMeshes(): InstancedMesh;
  19640. _generatePointsArray(): boolean;
  19641. /**
  19642. * Creates a new InstancedMesh from the current mesh.
  19643. * - name (string) : the cloned mesh name
  19644. * - newParent (optional Node) : the optional Node to parent the clone to.
  19645. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19646. *
  19647. * Returns the clone.
  19648. */
  19649. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  19650. /**
  19651. * Disposes the InstancedMesh.
  19652. * Returns nothing.
  19653. */
  19654. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19655. }
  19656. }
  19657. declare module BABYLON {
  19658. class LinesMesh extends Mesh {
  19659. useVertexColor: boolean | undefined;
  19660. useVertexAlpha: boolean | undefined;
  19661. color: Color3;
  19662. alpha: number;
  19663. /**
  19664. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19665. * This margin is expressed in world space coordinates, so its value may vary.
  19666. * Default value is 0.1
  19667. * @returns the intersection Threshold value.
  19668. */
  19669. /**
  19670. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19671. * This margin is expressed in world space coordinates, so its value may vary.
  19672. * @param value the new threshold to apply
  19673. */
  19674. intersectionThreshold: number;
  19675. private _intersectionThreshold;
  19676. private _colorShader;
  19677. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  19678. /**
  19679. * Returns the string "LineMesh"
  19680. */
  19681. getClassName(): string;
  19682. material: Material;
  19683. readonly checkCollisions: boolean;
  19684. createInstance(name: string): InstancedMesh;
  19685. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19686. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19687. dispose(doNotRecurse?: boolean): void;
  19688. /**
  19689. * Returns a new LineMesh object cloned from the current one.
  19690. */
  19691. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19692. }
  19693. }
  19694. declare module BABYLON {
  19695. /**
  19696. * @hidden
  19697. **/
  19698. class _InstancesBatch {
  19699. mustReturn: boolean;
  19700. visibleInstances: Nullable<InstancedMesh[]>[];
  19701. renderSelf: boolean[];
  19702. }
  19703. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  19704. static _FRONTSIDE: number;
  19705. static _BACKSIDE: number;
  19706. static _DOUBLESIDE: number;
  19707. static _DEFAULTSIDE: number;
  19708. static _NO_CAP: number;
  19709. static _CAP_START: number;
  19710. static _CAP_END: number;
  19711. static _CAP_ALL: number;
  19712. /**
  19713. * Mesh side orientation : usually the external or front surface
  19714. */
  19715. static readonly FRONTSIDE: number;
  19716. /**
  19717. * Mesh side orientation : usually the internal or back surface
  19718. */
  19719. static readonly BACKSIDE: number;
  19720. /**
  19721. * Mesh side orientation : both internal and external or front and back surfaces
  19722. */
  19723. static readonly DOUBLESIDE: number;
  19724. /**
  19725. * Mesh side orientation : by default, `FRONTSIDE`
  19726. */
  19727. static readonly DEFAULTSIDE: number;
  19728. /**
  19729. * Mesh cap setting : no cap
  19730. */
  19731. static readonly NO_CAP: number;
  19732. /**
  19733. * Mesh cap setting : one cap at the beginning of the mesh
  19734. */
  19735. static readonly CAP_START: number;
  19736. /**
  19737. * Mesh cap setting : one cap at the end of the mesh
  19738. */
  19739. static readonly CAP_END: number;
  19740. /**
  19741. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  19742. */
  19743. static readonly CAP_ALL: number;
  19744. /**
  19745. * An event triggered before rendering the mesh
  19746. */
  19747. onBeforeRenderObservable: Observable<Mesh>;
  19748. /**
  19749. * An event triggered after rendering the mesh
  19750. */
  19751. onAfterRenderObservable: Observable<Mesh>;
  19752. /**
  19753. * An event triggered before drawing the mesh
  19754. */
  19755. onBeforeDrawObservable: Observable<Mesh>;
  19756. private _onBeforeDrawObserver;
  19757. onBeforeDraw: () => void;
  19758. delayLoadState: number;
  19759. instances: InstancedMesh[];
  19760. delayLoadingFile: string;
  19761. _binaryInfo: any;
  19762. private _LODLevels;
  19763. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  19764. private _morphTargetManager;
  19765. morphTargetManager: Nullable<MorphTargetManager>;
  19766. _geometry: Nullable<Geometry>;
  19767. _delayInfo: Array<string>;
  19768. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  19769. _visibleInstances: any;
  19770. private _renderIdForInstances;
  19771. private _batchCache;
  19772. private _instancesBufferSize;
  19773. private _instancesBuffer;
  19774. private _instancesData;
  19775. private _overridenInstanceCount;
  19776. private _effectiveMaterial;
  19777. _shouldGenerateFlatShading: boolean;
  19778. private _preActivateId;
  19779. _originalBuilderSideOrientation: number;
  19780. overrideMaterialSideOrientation: Nullable<number>;
  19781. private _areNormalsFrozen;
  19782. private _sourcePositions;
  19783. private _sourceNormals;
  19784. private _source;
  19785. readonly source: Nullable<Mesh>;
  19786. isUnIndexed: boolean;
  19787. /**
  19788. * @constructor
  19789. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  19790. * @param {Scene} scene The scene to add this mesh to.
  19791. * @param {Node} parent The parent of this mesh, if it has one
  19792. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  19793. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19794. * When false, achieved by calling a clone(), also passing False.
  19795. * This will make creation of children, recursive.
  19796. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  19797. */
  19798. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  19799. /**
  19800. * Returns the string "Mesh".
  19801. */
  19802. getClassName(): string;
  19803. /**
  19804. * Returns a string.
  19805. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  19806. */
  19807. toString(fullDetails?: boolean): string;
  19808. _unBindEffect(): void;
  19809. /**
  19810. * True if the mesh has some Levels Of Details (LOD).
  19811. * Returns a boolean.
  19812. */
  19813. readonly hasLODLevels: boolean;
  19814. /**
  19815. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  19816. * @returns an array of {BABYLON.MeshLODLevel}
  19817. */
  19818. getLODLevels(): MeshLODLevel[];
  19819. private _sortLODLevels();
  19820. /**
  19821. * Add a mesh as LOD level triggered at the given distance.
  19822. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  19823. * @param {number} distance The distance from the center of the object to show this level
  19824. * @param {Mesh} mesh The mesh to be added as LOD level
  19825. * @return {Mesh} This mesh (for chaining)
  19826. */
  19827. addLODLevel(distance: number, mesh: Mesh): Mesh;
  19828. /**
  19829. * Returns the LOD level mesh at the passed distance or null if not found.
  19830. * It is related to the method `addLODLevel(distance, mesh)`.
  19831. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  19832. * Returns an object Mesh or `null`.
  19833. */
  19834. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  19835. /**
  19836. * Remove a mesh from the LOD array
  19837. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  19838. * @param {Mesh} mesh The mesh to be removed.
  19839. * @return {Mesh} This mesh (for chaining)
  19840. */
  19841. removeLODLevel(mesh: Mesh): Mesh;
  19842. /**
  19843. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  19844. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  19845. */
  19846. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  19847. /**
  19848. * Returns the mesh internal Geometry object.
  19849. */
  19850. readonly geometry: Nullable<Geometry>;
  19851. /**
  19852. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  19853. */
  19854. getTotalVertices(): number;
  19855. /**
  19856. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  19857. * 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.
  19858. * You can force the copy with forceCopy === true
  19859. * Returns null if the mesh has no geometry or no vertex buffer.
  19860. * Possible `kind` values :
  19861. * - BABYLON.VertexBuffer.PositionKind
  19862. * - BABYLON.VertexBuffer.UVKind
  19863. * - BABYLON.VertexBuffer.UV2Kind
  19864. * - BABYLON.VertexBuffer.UV3Kind
  19865. * - BABYLON.VertexBuffer.UV4Kind
  19866. * - BABYLON.VertexBuffer.UV5Kind
  19867. * - BABYLON.VertexBuffer.UV6Kind
  19868. * - BABYLON.VertexBuffer.ColorKind
  19869. * - BABYLON.VertexBuffer.MatricesIndicesKind
  19870. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19871. * - BABYLON.VertexBuffer.MatricesWeightsKind
  19872. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19873. */
  19874. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19875. /**
  19876. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  19877. * Returns `null` if the mesh has no geometry.
  19878. * Possible `kind` values :
  19879. * - BABYLON.VertexBuffer.PositionKind
  19880. * - BABYLON.VertexBuffer.UVKind
  19881. * - BABYLON.VertexBuffer.UV2Kind
  19882. * - BABYLON.VertexBuffer.UV3Kind
  19883. * - BABYLON.VertexBuffer.UV4Kind
  19884. * - BABYLON.VertexBuffer.UV5Kind
  19885. * - BABYLON.VertexBuffer.UV6Kind
  19886. * - BABYLON.VertexBuffer.ColorKind
  19887. * - BABYLON.VertexBuffer.MatricesIndicesKind
  19888. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19889. * - BABYLON.VertexBuffer.MatricesWeightsKind
  19890. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19891. */
  19892. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19893. isVerticesDataPresent(kind: string): boolean;
  19894. /**
  19895. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  19896. * Possible `kind` values :
  19897. * - BABYLON.VertexBuffer.PositionKind
  19898. * - BABYLON.VertexBuffer.UVKind
  19899. * - BABYLON.VertexBuffer.UV2Kind
  19900. * - BABYLON.VertexBuffer.UV3Kind
  19901. * - BABYLON.VertexBuffer.UV4Kind
  19902. * - BABYLON.VertexBuffer.UV5Kind
  19903. * - BABYLON.VertexBuffer.UV6Kind
  19904. * - BABYLON.VertexBuffer.ColorKind
  19905. * - BABYLON.VertexBuffer.MatricesIndicesKind
  19906. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19907. * - BABYLON.VertexBuffer.MatricesWeightsKind
  19908. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19909. */
  19910. isVertexBufferUpdatable(kind: string): boolean;
  19911. /**
  19912. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  19913. * Possible `kind` values :
  19914. * - BABYLON.VertexBuffer.PositionKind
  19915. * - BABYLON.VertexBuffer.UVKind
  19916. * - BABYLON.VertexBuffer.UV2Kind
  19917. * - BABYLON.VertexBuffer.UV3Kind
  19918. * - BABYLON.VertexBuffer.UV4Kind
  19919. * - BABYLON.VertexBuffer.UV5Kind
  19920. * - BABYLON.VertexBuffer.UV6Kind
  19921. * - BABYLON.VertexBuffer.ColorKind
  19922. * - BABYLON.VertexBuffer.MatricesIndicesKind
  19923. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19924. * - BABYLON.VertexBuffer.MatricesWeightsKind
  19925. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19926. */
  19927. getVerticesDataKinds(): string[];
  19928. /**
  19929. * Returns a positive integer : the total number of indices in this mesh geometry.
  19930. * Returns zero if the mesh has no geometry.
  19931. */
  19932. getTotalIndices(): number;
  19933. /**
  19934. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19935. * 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.
  19936. * Returns an empty array if the mesh has no geometry.
  19937. */
  19938. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  19939. readonly isBlocked: boolean;
  19940. /**
  19941. * Determine if the current mesh is ready to be rendered
  19942. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19943. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  19944. * @returns true if all associated assets are ready (material, textures, shaders)
  19945. */
  19946. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  19947. /**
  19948. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  19949. * This property is pertinent only for updatable parametric shapes.
  19950. */
  19951. readonly areNormalsFrozen: boolean;
  19952. /**
  19953. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  19954. * It has no effect at all on other shapes.
  19955. * It prevents the mesh normals from being recomputed on next `positions` array update.
  19956. * Returns the Mesh.
  19957. */
  19958. freezeNormals(): Mesh;
  19959. /**
  19960. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  19961. * It has no effect at all on other shapes.
  19962. * It reactivates the mesh normals computation if it was previously frozen.
  19963. * Returns the Mesh.
  19964. */
  19965. unfreezeNormals(): Mesh;
  19966. /**
  19967. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  19968. */
  19969. overridenInstanceCount: number;
  19970. _preActivate(): Mesh;
  19971. _preActivateForIntermediateRendering(renderId: number): Mesh;
  19972. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  19973. /**
  19974. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19975. * This means the mesh underlying bounding box and sphere are recomputed.
  19976. * Returns the Mesh.
  19977. */
  19978. refreshBoundingInfo(): Mesh;
  19979. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  19980. private _getPositionData(applySkeleton);
  19981. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  19982. subdivide(count: number): void;
  19983. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19984. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  19985. /**
  19986. * Sets the mesh VertexBuffer.
  19987. * Returns the Mesh.
  19988. */
  19989. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  19990. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19991. /**
  19992. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  19993. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  19994. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  19995. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  19996. * Returns the Mesh.
  19997. */
  19998. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  19999. /**
  20000. * Creates a un-shared specific occurence of the geometry for the mesh.
  20001. * Returns the Mesh.
  20002. */
  20003. makeGeometryUnique(): Mesh;
  20004. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20005. /**
  20006. * Update the current index buffer
  20007. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  20008. * Returns the Mesh.
  20009. */
  20010. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20011. /**
  20012. * Invert the geometry to move from a right handed system to a left handed one.
  20013. * Returns the Mesh.
  20014. */
  20015. toLeftHanded(): Mesh;
  20016. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20017. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20018. /**
  20019. * Registers for this mesh a javascript function called just before the rendering process.
  20020. * This function is passed the current mesh.
  20021. * Return the Mesh.
  20022. */
  20023. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20024. /**
  20025. * Disposes a previously registered javascript function called before the rendering.
  20026. * This function is passed the current mesh.
  20027. * Returns the Mesh.
  20028. */
  20029. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20030. /**
  20031. * Registers for this mesh a javascript function called just after the rendering is complete.
  20032. * This function is passed the current mesh.
  20033. * Returns the Mesh.
  20034. */
  20035. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20036. /**
  20037. * Disposes a previously registered javascript function called after the rendering.
  20038. * This function is passed the current mesh.
  20039. * Return the Mesh.
  20040. */
  20041. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20042. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20043. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20044. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20045. /**
  20046. * Triggers the draw call for the mesh.
  20047. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  20048. * Returns the Mesh.
  20049. */
  20050. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20051. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  20052. /**
  20053. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  20054. */
  20055. getEmittedParticleSystems(): IParticleSystem[];
  20056. /**
  20057. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  20058. */
  20059. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  20060. /**
  20061. * Normalize matrix weights so that all vertices have a total weight set to 1
  20062. */
  20063. cleanMatrixWeights(): void;
  20064. _checkDelayState(): Mesh;
  20065. private _queueLoad(scene);
  20066. /**
  20067. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  20068. */
  20069. isInFrustum(frustumPlanes: Plane[]): boolean;
  20070. /**
  20071. * Sets the mesh material by the material or multiMaterial `id` property.
  20072. * The material `id` is a string identifying the material or the multiMaterial.
  20073. * This method returns the Mesh.
  20074. */
  20075. setMaterialByID(id: string): Mesh;
  20076. /**
  20077. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20078. */
  20079. getAnimatables(): IAnimatable[];
  20080. /**
  20081. * Modifies the mesh geometry according to the passed transformation matrix.
  20082. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20083. * The mesh normals are modified accordingly the same transformation.
  20084. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  20085. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20086. * Returns the Mesh.
  20087. */
  20088. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20089. /**
  20090. * Modifies the mesh geometry according to its own current World Matrix.
  20091. * The mesh World Matrix is then reset.
  20092. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20093. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  20094. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20095. * Returns the Mesh.
  20096. */
  20097. bakeCurrentTransformIntoVertices(): Mesh;
  20098. readonly _positions: Nullable<Vector3[]>;
  20099. _resetPointsArrayCache(): Mesh;
  20100. _generatePointsArray(): boolean;
  20101. /**
  20102. * Returns a new Mesh object generated from the current mesh properties.
  20103. * This method must not get confused with createInstance().
  20104. * The parameter `name` is a string, the name given to the new mesh.
  20105. * The optional parameter `newParent` can be any Node object (default `null`).
  20106. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  20107. * 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.
  20108. */
  20109. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20110. /**
  20111. * Releases resources associated with this mesh.
  20112. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20113. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20114. */
  20115. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20116. /**
  20117. * Modifies the mesh geometry according to a displacement map.
  20118. * 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.
  20119. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20120. * This method returns nothing.
  20121. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  20122. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  20123. * 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.
  20124. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  20125. * The parameter `uvScale` is an optional vector2 used to scale UV.
  20126. *
  20127. * Returns the Mesh.
  20128. */
  20129. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  20130. /**
  20131. * Modifies the mesh geometry according to a displacementMap buffer.
  20132. * 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.
  20133. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20134. * This method returns nothing.
  20135. * 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.
  20136. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  20137. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  20138. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  20139. * The parameter `uvScale` is an optional vector2 used to scale UV.
  20140. *
  20141. * Returns the Mesh.
  20142. */
  20143. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  20144. /**
  20145. * Modify the mesh to get a flat shading rendering.
  20146. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20147. * This method returns the Mesh.
  20148. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20149. */
  20150. convertToFlatShadedMesh(): Mesh;
  20151. /**
  20152. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20153. * In other words, more vertices, no more indices and a single bigger VBO.
  20154. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20155. * Returns the Mesh.
  20156. */
  20157. convertToUnIndexedMesh(): Mesh;
  20158. /**
  20159. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  20160. * This method returns the Mesh.
  20161. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20162. */
  20163. flipFaces(flipNormals?: boolean): Mesh;
  20164. /**
  20165. * Creates a new InstancedMesh object from the mesh model.
  20166. * An instance shares the same properties and the same material than its model.
  20167. * Only these properties of each instance can then be set individually :
  20168. * - position
  20169. * - rotation
  20170. * - rotationQuaternion
  20171. * - setPivotMatrix
  20172. * - scaling
  20173. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  20174. * Warning : this method is not supported for Line mesh and LineSystem
  20175. */
  20176. createInstance(name: string): InstancedMesh;
  20177. /**
  20178. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20179. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20180. * This method returns the Mesh.
  20181. */
  20182. synchronizeInstances(): Mesh;
  20183. /**
  20184. * Simplify the mesh according to the given array of settings.
  20185. * Function will return immediately and will simplify async. It returns the Mesh.
  20186. * @param settings a collection of simplification settings.
  20187. * @param parallelProcessing should all levels calculate parallel or one after the other.
  20188. * @param type the type of simplification to run.
  20189. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  20190. */
  20191. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  20192. /**
  20193. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20194. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20195. * This should be used together with the simplification to avoid disappearing triangles.
  20196. * Returns the Mesh.
  20197. * @param successCallback an optional success callback to be called after the optimization finished.
  20198. */
  20199. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20200. serialize(serializationObject: any): void;
  20201. _syncGeometryWithMorphTargetManager(): void;
  20202. /**
  20203. * Returns a new Mesh object parsed from the source provided.
  20204. * The parameter `parsedMesh` is the source.
  20205. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  20206. */
  20207. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20208. /**
  20209. * Creates a ribbon mesh.
  20210. * Please consider using the same method from the MeshBuilder class instead.
  20211. * 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.
  20212. *
  20213. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  20214. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20215. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  20216. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  20217. * 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.
  20218. * 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.
  20219. * 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
  20220. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20221. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20222. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20223. */
  20224. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20225. /**
  20226. * Creates a plane polygonal mesh. By default, this is a disc.
  20227. * Please consider using the same method from the MeshBuilder class instead.
  20228. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  20229. * 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.
  20230. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20231. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20232. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20233. */
  20234. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20235. /**
  20236. * Creates a box mesh.
  20237. * Please consider using the same method from the MeshBuilder class instead.
  20238. * The parameter `size` sets the size (float) of each box side (default 1).
  20239. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20240. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20241. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20242. */
  20243. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20244. /**
  20245. * Creates a sphere mesh.
  20246. * Please consider using the same method from the MeshBuilder class instead.
  20247. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  20248. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  20249. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20250. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20251. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20252. */
  20253. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20254. /**
  20255. * Creates a cylinder or a cone mesh.
  20256. * Please consider using the same method from the MeshBuilder class instead.
  20257. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  20258. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  20259. * 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.
  20260. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  20261. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  20262. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20263. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20264. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20265. */
  20266. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  20267. /**
  20268. * Creates a torus mesh.
  20269. * Please consider using the same method from the MeshBuilder class instead.
  20270. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  20271. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  20272. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  20273. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20274. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20275. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20276. */
  20277. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20278. /**
  20279. * Creates a torus knot mesh.
  20280. * Please consider using the same method from the MeshBuilder class instead.
  20281. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  20282. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  20283. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  20284. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  20285. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20286. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20287. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20288. */
  20289. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20290. /**
  20291. * Creates a line mesh.
  20292. * Please consider using the same method from the MeshBuilder class instead.
  20293. * 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.
  20294. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  20295. * The parameter `points` is an array successive Vector3.
  20296. * 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
  20297. * When updating an instance, remember that only point positions can change, not the number of points.
  20298. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20299. */
  20300. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  20301. /**
  20302. * Creates a dashed line mesh.
  20303. * Please consider using the same method from the MeshBuilder class instead.
  20304. * 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.
  20305. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  20306. * The parameter `points` is an array successive Vector3.
  20307. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  20308. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  20309. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  20310. * 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
  20311. * When updating an instance, remember that only point positions can change, not the number of points.
  20312. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20313. */
  20314. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  20315. /**
  20316. * Creates a polygon mesh.
  20317. * Please consider using the same method from the MeshBuilder class instead.
  20318. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  20319. * 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.
  20320. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20321. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20322. * Remember you can only change the shape positions, not their number when updating a polygon.
  20323. */
  20324. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  20325. /**
  20326. * Creates an extruded polygon mesh, with depth in the Y direction.
  20327. * Please consider using the same method from the MeshBuilder class instead.
  20328. */
  20329. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  20330. /**
  20331. * Creates an extruded shape mesh.
  20332. * 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.
  20333. * Please consider using the same method from the MeshBuilder class instead.
  20334. *
  20335. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20336. * 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
  20337. * extruded along the Z axis.
  20338. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  20339. * 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.
  20340. * The parameter `scale` (float, default 1) is the value to scale the shape.
  20341. * 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
  20342. * 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
  20343. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  20344. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20345. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20346. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20347. */
  20348. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20349. /**
  20350. * Creates an custom extruded shape mesh.
  20351. * 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.
  20352. * Please consider using the same method from the MeshBuilder class instead.
  20353. *
  20354. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20355. * 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
  20356. * extruded along the Z axis.
  20357. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  20358. * 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
  20359. * and the distance of this point from the begining of the path :
  20360. * ```javascript
  20361. * var rotationFunction = function(i, distance) {
  20362. * // do things
  20363. * return rotationValue; }
  20364. * ```
  20365. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  20366. * 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
  20367. * and the distance of this point from the begining of the path :
  20368. * ```javascript
  20369. * var scaleFunction = function(i, distance) {
  20370. * // do things
  20371. * return scaleValue;}
  20372. * ```
  20373. * It must returns a float value that will be the scale value applied to the shape on each path point.
  20374. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  20375. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  20376. * 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
  20377. * 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
  20378. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  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 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;
  20384. /**
  20385. * Creates lathe mesh.
  20386. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  20387. * Please consider using the same method from the MeshBuilder class instead.
  20388. * 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
  20389. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  20390. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  20391. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  20392. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20393. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20394. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20395. */
  20396. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20397. /**
  20398. * Creates a plane mesh.
  20399. * Please consider using the same method from the MeshBuilder class instead.
  20400. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  20401. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20402. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20403. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20404. */
  20405. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20406. /**
  20407. * Creates a ground mesh.
  20408. * Please consider using the same method from the MeshBuilder class instead.
  20409. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  20410. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  20411. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20412. */
  20413. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  20414. /**
  20415. * Creates a tiled ground mesh.
  20416. * Please consider using the same method from the MeshBuilder class instead.
  20417. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  20418. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  20419. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  20420. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  20421. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  20422. * numbers of subdivisions on the ground width and height of each tile.
  20423. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20424. */
  20425. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  20426. w: number;
  20427. h: number;
  20428. }, precision: {
  20429. w: number;
  20430. h: number;
  20431. }, scene: Scene, updatable?: boolean): Mesh;
  20432. /**
  20433. * Creates a ground mesh from a height map.
  20434. * tuto : http://doc.babylonjs.com/babylon101/height_map
  20435. * Please consider using the same method from the MeshBuilder class instead.
  20436. * The parameter `url` sets the URL of the height map image resource.
  20437. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  20438. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  20439. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  20440. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  20441. * 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).
  20442. * This function is passed the newly built mesh :
  20443. * ```javascript
  20444. * function(mesh) { // do things
  20445. * return; }
  20446. * ```
  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 CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void): GroundMesh;
  20450. /**
  20451. * Creates a tube mesh.
  20452. * 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.
  20453. * Please consider using the same method from the MeshBuilder class instead.
  20454. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  20455. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  20456. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  20457. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  20458. * 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.
  20459. * It must return a radius value (positive float) :
  20460. * ```javascript
  20461. * var radiusFunction = function(i, distance) {
  20462. * // do things
  20463. * return radius; }
  20464. * ```
  20465. * 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
  20466. * 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
  20467. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20468. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20469. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20470. */
  20471. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  20472. (i: number, distance: number): number;
  20473. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20474. /**
  20475. * Creates a polyhedron mesh.
  20476. * Please consider using the same method from the MeshBuilder class instead.
  20477. * 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
  20478. * to choose the wanted type.
  20479. * The parameter `size` (positive float, default 1) sets the polygon size.
  20480. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  20481. * 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`.
  20482. * 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
  20483. * 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)`).
  20484. * 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
  20485. * 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.
  20486. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20487. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20488. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20489. */
  20490. static CreatePolyhedron(name: string, options: {
  20491. type?: number;
  20492. size?: number;
  20493. sizeX?: number;
  20494. sizeY?: number;
  20495. sizeZ?: number;
  20496. custom?: any;
  20497. faceUV?: Vector4[];
  20498. faceColors?: Color4[];
  20499. updatable?: boolean;
  20500. sideOrientation?: number;
  20501. }, scene: Scene): Mesh;
  20502. /**
  20503. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  20504. * Please consider using the same method from the MeshBuilder class instead.
  20505. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  20506. * 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`).
  20507. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  20508. * 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.
  20509. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20510. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20511. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20512. */
  20513. static CreateIcoSphere(name: string, options: {
  20514. radius?: number;
  20515. flat?: boolean;
  20516. subdivisions?: number;
  20517. sideOrientation?: number;
  20518. updatable?: boolean;
  20519. }, scene: Scene): Mesh;
  20520. /**
  20521. * Creates a decal mesh.
  20522. * Please consider using the same method from the MeshBuilder class instead.
  20523. * 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.
  20524. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  20525. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  20526. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  20527. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  20528. */
  20529. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  20530. /**
  20531. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20532. */
  20533. setPositionsForCPUSkinning(): Float32Array;
  20534. /**
  20535. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20536. */
  20537. setNormalsForCPUSkinning(): Float32Array;
  20538. /**
  20539. * Updates the vertex buffer by applying transformation from the bones.
  20540. * Returns the Mesh.
  20541. *
  20542. * @param {skeleton} skeleton to apply
  20543. */
  20544. applySkeleton(skeleton: Skeleton): Mesh;
  20545. /**
  20546. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  20547. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  20548. */
  20549. static MinMax(meshes: AbstractMesh[]): {
  20550. min: Vector3;
  20551. max: Vector3;
  20552. };
  20553. /**
  20554. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  20555. */
  20556. static Center(meshesOrMinMaxVector: {
  20557. min: Vector3;
  20558. max: Vector3;
  20559. } | AbstractMesh[]): Vector3;
  20560. /**
  20561. * Merge the array of meshes into a single mesh for performance reasons.
  20562. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  20563. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  20564. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  20565. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  20566. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  20567. */
  20568. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  20569. }
  20570. }
  20571. declare module BABYLON {
  20572. /**
  20573. * Define an interface for all classes that will get and set the data on vertices
  20574. */
  20575. interface IGetSetVerticesData {
  20576. isVerticesDataPresent(kind: string): boolean;
  20577. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20578. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  20579. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  20580. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  20581. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  20582. }
  20583. /**
  20584. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  20585. */
  20586. class VertexData {
  20587. /**
  20588. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  20589. */
  20590. positions: Nullable<FloatArray>;
  20591. /**
  20592. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  20593. */
  20594. normals: Nullable<FloatArray>;
  20595. /**
  20596. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  20597. */
  20598. tangents: Nullable<FloatArray>;
  20599. /**
  20600. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20601. */
  20602. uvs: Nullable<FloatArray>;
  20603. /**
  20604. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20605. */
  20606. uvs2: Nullable<FloatArray>;
  20607. /**
  20608. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20609. */
  20610. uvs3: Nullable<FloatArray>;
  20611. /**
  20612. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20613. */
  20614. uvs4: Nullable<FloatArray>;
  20615. /**
  20616. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20617. */
  20618. uvs5: Nullable<FloatArray>;
  20619. /**
  20620. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20621. */
  20622. uvs6: Nullable<FloatArray>;
  20623. /**
  20624. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  20625. */
  20626. colors: Nullable<FloatArray>;
  20627. /**
  20628. * 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).
  20629. */
  20630. matricesIndices: Nullable<FloatArray>;
  20631. /**
  20632. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  20633. */
  20634. matricesWeights: Nullable<FloatArray>;
  20635. /**
  20636. * An array extending the number of possible indices
  20637. */
  20638. matricesIndicesExtra: Nullable<FloatArray>;
  20639. /**
  20640. * An array extending the number of possible weights when the number of indices is extended
  20641. */
  20642. matricesWeightsExtra: Nullable<FloatArray>;
  20643. /**
  20644. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  20645. */
  20646. indices: Nullable<IndicesArray>;
  20647. /**
  20648. * Uses the passed data array to set the set the values for the specified kind of data
  20649. * @param data a linear array of floating numbers
  20650. * @param kind the type of data that is being set, eg positions, colors etc
  20651. */
  20652. set(data: FloatArray, kind: string): void;
  20653. /**
  20654. * Associates the vertexData to the passed Mesh.
  20655. * Sets it as updatable or not (default `false`)
  20656. * @param mesh the mesh the vertexData is applied to
  20657. * @param updatable when used and having the value true allows new data to update the vertexData
  20658. * @returns the VertexData
  20659. */
  20660. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  20661. /**
  20662. * Associates the vertexData to the passed Geometry.
  20663. * Sets it as updatable or not (default `false`)
  20664. * @param geometry the geometry the vertexData is applied to
  20665. * @param updatable when used and having the value true allows new data to update the vertexData
  20666. * @returns VertexData
  20667. */
  20668. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  20669. /**
  20670. * Updates the associated mesh
  20671. * @param mesh the mesh to be updated
  20672. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  20673. * @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
  20674. * @returns VertexData
  20675. */
  20676. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  20677. /**
  20678. * Updates the associated geometry
  20679. * @param geometry the geometry to be updated
  20680. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  20681. * @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
  20682. * @returns VertexData.
  20683. */
  20684. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  20685. private _applyTo(meshOrGeometry, updatable?);
  20686. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  20687. /**
  20688. * Transforms each position and each normal of the vertexData according to the passed Matrix
  20689. * @param matrix the transforming matrix
  20690. * @returns the VertexData
  20691. */
  20692. transform(matrix: Matrix): VertexData;
  20693. /**
  20694. * Merges the passed VertexData into the current one
  20695. * @param other the VertexData to be merged into the current one
  20696. * @returns the modified VertexData
  20697. */
  20698. merge(other: VertexData): VertexData;
  20699. private _mergeElement(source, other);
  20700. private _validate();
  20701. /**
  20702. * Serializes the VertexData
  20703. * @returns a serialized object
  20704. */
  20705. serialize(): any;
  20706. /**
  20707. * Extracts the vertexData from a mesh
  20708. * @param mesh the mesh from which to extract the VertexData
  20709. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  20710. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  20711. * @returns the object VertexData associated to the passed mesh
  20712. */
  20713. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  20714. /**
  20715. * Extracts the vertexData from the geometry
  20716. * @param geometry the geometry from which to extract the VertexData
  20717. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  20718. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  20719. * @returns the object VertexData associated to the passed mesh
  20720. */
  20721. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  20722. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  20723. /**
  20724. * Creates the VertexData for a Ribbon
  20725. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  20726. * * pathArray array of paths, each of which an array of successive Vector3
  20727. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  20728. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  20729. * * 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
  20730. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20731. * * 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)
  20732. * * 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)
  20733. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  20734. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  20735. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  20736. * @returns the VertexData of the ribbon
  20737. */
  20738. static CreateRibbon(options: {
  20739. pathArray: Vector3[][];
  20740. closeArray?: boolean;
  20741. closePath?: boolean;
  20742. offset?: number;
  20743. sideOrientation?: number;
  20744. frontUVs?: Vector4;
  20745. backUVs?: Vector4;
  20746. invertUV?: boolean;
  20747. uvs?: Vector2[];
  20748. colors?: Color4[];
  20749. }): VertexData;
  20750. /**
  20751. * Creates the VertexData for a box
  20752. * @param options an object used to set the following optional parameters for the box, required but can be empty
  20753. * * size sets the width, height and depth of the box to the value of size, optional default 1
  20754. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  20755. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  20756. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  20757. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  20758. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  20759. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20760. * * 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)
  20761. * * 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)
  20762. * @returns the VertexData of the box
  20763. */
  20764. static CreateBox(options: {
  20765. size?: number;
  20766. width?: number;
  20767. height?: number;
  20768. depth?: number;
  20769. faceUV?: Vector4[];
  20770. faceColors?: Color4[];
  20771. sideOrientation?: number;
  20772. frontUVs?: Vector4;
  20773. backUVs?: Vector4;
  20774. }): VertexData;
  20775. /**
  20776. * Creates the VertexData for an ellipsoid, defaults to a sphere
  20777. * @param options an object used to set the following optional parameters for the box, required but can be empty
  20778. * * segments sets the number of horizontal strips optional, default 32
  20779. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  20780. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  20781. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  20782. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  20783. * * 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
  20784. * * 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
  20785. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20786. * * 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)
  20787. * * 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)
  20788. * @returns the VertexData of the ellipsoid
  20789. */
  20790. static CreateSphere(options: {
  20791. segments?: number;
  20792. diameter?: number;
  20793. diameterX?: number;
  20794. diameterY?: number;
  20795. diameterZ?: number;
  20796. arc?: number;
  20797. slice?: number;
  20798. sideOrientation?: number;
  20799. frontUVs?: Vector4;
  20800. backUVs?: Vector4;
  20801. }): VertexData;
  20802. /**
  20803. * Creates the VertexData for a cylinder, cone or prism
  20804. * @param options an object used to set the following optional parameters for the box, required but can be empty
  20805. * * height sets the height (y direction) of the cylinder, optional, default 2
  20806. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  20807. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  20808. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  20809. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  20810. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  20811. * * 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
  20812. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  20813. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  20814. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  20815. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  20816. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20817. * * 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)
  20818. * * 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)
  20819. * @returns the VertexData of the cylinder, cone or prism
  20820. */
  20821. static CreateCylinder(options: {
  20822. height?: number;
  20823. diameterTop?: number;
  20824. diameterBottom?: number;
  20825. diameter?: number;
  20826. tessellation?: number;
  20827. subdivisions?: number;
  20828. arc?: number;
  20829. faceColors?: Color4[];
  20830. faceUV?: Vector4[];
  20831. hasRings?: boolean;
  20832. enclose?: boolean;
  20833. sideOrientation?: number;
  20834. frontUVs?: Vector4;
  20835. backUVs?: Vector4;
  20836. }): VertexData;
  20837. /**
  20838. * Creates the VertexData for a torus
  20839. * @param options an object used to set the following optional parameters for the box, required but can be empty
  20840. * * diameter the diameter of the torus, optional default 1
  20841. * * thickness the diameter of the tube forming the torus, optional default 0.5
  20842. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  20843. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20844. * * 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)
  20845. * * 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)
  20846. * @returns the VertexData of the torus
  20847. */
  20848. static CreateTorus(options: {
  20849. diameter?: number;
  20850. thickness?: number;
  20851. tessellation?: number;
  20852. sideOrientation?: number;
  20853. frontUVs?: Vector4;
  20854. backUVs?: Vector4;
  20855. }): VertexData;
  20856. /**
  20857. * Creates the VertexData of the LineSystem
  20858. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  20859. * - lines an array of lines, each line being an array of successive Vector3
  20860. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  20861. * @returns the VertexData of the LineSystem
  20862. */
  20863. static CreateLineSystem(options: {
  20864. lines: Vector3[][];
  20865. colors?: Nullable<Color4[][]>;
  20866. }): VertexData;
  20867. /**
  20868. * Create the VertexData for a DashedLines
  20869. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  20870. * - points an array successive Vector3
  20871. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  20872. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  20873. * - dashNb the intended total number of dashes, optional, default 200
  20874. * @returns the VertexData for the DashedLines
  20875. */
  20876. static CreateDashedLines(options: {
  20877. points: Vector3[];
  20878. dashSize?: number;
  20879. gapSize?: number;
  20880. dashNb?: number;
  20881. }): VertexData;
  20882. /**
  20883. * Creates the VertexData for a Ground
  20884. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  20885. * - width the width (x direction) of the ground, optional, default 1
  20886. * - height the height (z direction) of the ground, optional, default 1
  20887. * - subdivisions the number of subdivisions per side, optional, default 1
  20888. * @returns the VertexData of the Ground
  20889. */
  20890. static CreateGround(options: {
  20891. width?: number;
  20892. height?: number;
  20893. subdivisions?: number;
  20894. subdivisionsX?: number;
  20895. subdivisionsY?: number;
  20896. }): VertexData;
  20897. /**
  20898. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  20899. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  20900. * * xmin the ground minimum X coordinate, optional, default -1
  20901. * * zmin the ground minimum Z coordinate, optional, default -1
  20902. * * xmax the ground maximum X coordinate, optional, default 1
  20903. * * zmax the ground maximum Z coordinate, optional, default 1
  20904. * * 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}
  20905. * * 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}
  20906. * @returns the VertexData of the TiledGround
  20907. */
  20908. static CreateTiledGround(options: {
  20909. xmin: number;
  20910. zmin: number;
  20911. xmax: number;
  20912. zmax: number;
  20913. subdivisions?: {
  20914. w: number;
  20915. h: number;
  20916. };
  20917. precision?: {
  20918. w: number;
  20919. h: number;
  20920. };
  20921. }): VertexData;
  20922. /**
  20923. * Creates the VertexData of the Ground designed from a heightmap
  20924. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  20925. * * width the width (x direction) of the ground
  20926. * * height the height (z direction) of the ground
  20927. * * subdivisions the number of subdivisions per side
  20928. * * minHeight the minimum altitude on the ground, optional, default 0
  20929. * * maxHeight the maximum altitude on the ground, optional default 1
  20930. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  20931. * * buffer the array holding the image color data
  20932. * * bufferWidth the width of image
  20933. * * bufferHeight the height of image
  20934. * @returns the VertexData of the Ground designed from a heightmap
  20935. */
  20936. static CreateGroundFromHeightMap(options: {
  20937. width: number;
  20938. height: number;
  20939. subdivisions: number;
  20940. minHeight: number;
  20941. maxHeight: number;
  20942. colorFilter: Color3;
  20943. buffer: Uint8Array;
  20944. bufferWidth: number;
  20945. bufferHeight: number;
  20946. }): VertexData;
  20947. /**
  20948. * Creates the VertexData for a Plane
  20949. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  20950. * * size sets the width and height of the plane to the value of size, optional default 1
  20951. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  20952. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  20953. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20954. * * 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)
  20955. * * 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)
  20956. * @returns the VertexData of the box
  20957. */
  20958. static CreatePlane(options: {
  20959. size?: number;
  20960. width?: number;
  20961. height?: number;
  20962. sideOrientation?: number;
  20963. frontUVs?: Vector4;
  20964. backUVs?: Vector4;
  20965. }): VertexData;
  20966. /**
  20967. * Creates the VertexData of the Disc or regular Polygon
  20968. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  20969. * * radius the radius of the disc, optional default 0.5
  20970. * * tessellation the number of polygon sides, optional, default 64
  20971. * * 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
  20972. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20973. * * 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)
  20974. * * 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)
  20975. * @returns the VertexData of the box
  20976. */
  20977. static CreateDisc(options: {
  20978. radius?: number;
  20979. tessellation?: number;
  20980. arc?: number;
  20981. sideOrientation?: number;
  20982. frontUVs?: Vector4;
  20983. backUVs?: Vector4;
  20984. }): VertexData;
  20985. /**
  20986. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  20987. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  20988. * @param polygon a mesh built from polygonTriangulation.build()
  20989. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20990. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  20991. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  20992. * @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)
  20993. * @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)
  20994. * @returns the VertexData of the Polygon
  20995. */
  20996. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  20997. /**
  20998. * Creates the VertexData of the IcoSphere
  20999. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21000. * * radius the radius of the IcoSphere, optional default 1
  21001. * * radiusX allows stretching in the x direction, optional, default radius
  21002. * * radiusY allows stretching in the y direction, optional, default radius
  21003. * * radiusZ allows stretching in the z direction, optional, default radius
  21004. * * flat when true creates a flat shaded mesh, optional, default true
  21005. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21006. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21007. * * 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)
  21008. * * 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)
  21009. * @returns the VertexData of the IcoSphere
  21010. */
  21011. static CreateIcoSphere(options: {
  21012. radius?: number;
  21013. radiusX?: number;
  21014. radiusY?: number;
  21015. radiusZ?: number;
  21016. flat?: boolean;
  21017. subdivisions?: number;
  21018. sideOrientation?: number;
  21019. frontUVs?: Vector4;
  21020. backUVs?: Vector4;
  21021. }): VertexData;
  21022. /**
  21023. * Creates the VertexData for a Polyhedron
  21024. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21025. * * type provided types are:
  21026. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21027. * * 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)
  21028. * * size the size of the IcoSphere, optional default 1
  21029. * * sizeX allows stretching in the x direction, optional, default size
  21030. * * sizeY allows stretching in the y direction, optional, default size
  21031. * * sizeZ allows stretching in the z direction, optional, default size
  21032. * * 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
  21033. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21034. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21035. * * flat when true creates a flat shaded mesh, optional, default true
  21036. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21037. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21038. * * 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)
  21039. * * 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)
  21040. * @returns the VertexData of the Polyhedron
  21041. */
  21042. static CreatePolyhedron(options: {
  21043. type?: number;
  21044. size?: number;
  21045. sizeX?: number;
  21046. sizeY?: number;
  21047. sizeZ?: number;
  21048. custom?: any;
  21049. faceUV?: Vector4[];
  21050. faceColors?: Color4[];
  21051. flat?: boolean;
  21052. sideOrientation?: number;
  21053. frontUVs?: Vector4;
  21054. backUVs?: Vector4;
  21055. }): VertexData;
  21056. /**
  21057. * Creates the VertexData for a TorusKnot
  21058. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21059. * * radius the radius of the torus knot, optional, default 2
  21060. * * tube the thickness of the tube, optional, default 0.5
  21061. * * radialSegments the number of sides on each tube segments, optional, default 32
  21062. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21063. * * p the number of windings around the z axis, optional, default 2
  21064. * * q the number of windings around the x axis, optional, default 3
  21065. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21066. * * 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)
  21067. * * 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)
  21068. * @returns the VertexData of the Torus Knot
  21069. */
  21070. static CreateTorusKnot(options: {
  21071. radius?: number;
  21072. tube?: number;
  21073. radialSegments?: number;
  21074. tubularSegments?: number;
  21075. p?: number;
  21076. q?: number;
  21077. sideOrientation?: number;
  21078. frontUVs?: Vector4;
  21079. backUVs?: Vector4;
  21080. }): VertexData;
  21081. /**
  21082. * Compute normals for given positions and indices
  21083. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21084. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21085. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21086. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21087. * * facetNormals : optional array of facet normals (vector3)
  21088. * * facetPositions : optional array of facet positions (vector3)
  21089. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21090. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21091. * * bInfo : optional bounding info, required for facetPartitioning computation
  21092. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21093. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21094. * * useRightHandedSystem: optional boolean to for right handed system computation
  21095. * * depthSort : optional boolean to enable the facet depth sort computation
  21096. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21097. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21098. */
  21099. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21100. facetNormals?: any;
  21101. facetPositions?: any;
  21102. facetPartitioning?: any;
  21103. ratio?: number;
  21104. bInfo?: any;
  21105. bbSize?: Vector3;
  21106. subDiv?: any;
  21107. useRightHandedSystem?: boolean;
  21108. depthSort?: boolean;
  21109. distanceTo?: Vector3;
  21110. depthSortedFacets?: any;
  21111. }): void;
  21112. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  21113. /**
  21114. * Applies VertexData created from the imported parameters to the geometry
  21115. * @param parsedVertexData the parsed data from an imported file
  21116. * @param geometry the geometry to apply the VertexData to
  21117. */
  21118. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21119. }
  21120. }
  21121. declare module BABYLON {
  21122. /**
  21123. * Class containing static functions to help procedurally build meshes
  21124. */
  21125. class MeshBuilder {
  21126. private static updateSideOrientation(orientation?);
  21127. /**
  21128. * Creates a box mesh
  21129. * * The parameter `size` sets the size (float) of each box side (default 1)
  21130. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  21131. * * 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)
  21132. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  21133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21134. * * 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
  21135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21136. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  21137. * @param name defines the name of the mesh
  21138. * @param options defines the options used to create the mesh
  21139. * @param scene defines the hosting scene
  21140. * @returns the box mesh
  21141. */
  21142. static CreateBox(name: string, options: {
  21143. size?: number;
  21144. width?: number;
  21145. height?: number;
  21146. depth?: number;
  21147. faceUV?: Vector4[];
  21148. faceColors?: Color4[];
  21149. sideOrientation?: number;
  21150. frontUVs?: Vector4;
  21151. backUVs?: Vector4;
  21152. updatable?: boolean;
  21153. }, scene?: Nullable<Scene>): Mesh;
  21154. /**
  21155. * Creates a sphere mesh
  21156. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  21157. * * 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`)
  21158. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  21159. * * 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
  21160. * * 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)
  21161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21162. * * 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
  21163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21164. * @param name defines the name of the mesh
  21165. * @param options defines the options used to create the mesh
  21166. * @param scene defines the hosting scene
  21167. * @returns the sphere mesh
  21168. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  21169. */
  21170. static CreateSphere(name: string, options: {
  21171. segments?: number;
  21172. diameter?: number;
  21173. diameterX?: number;
  21174. diameterY?: number;
  21175. diameterZ?: number;
  21176. arc?: number;
  21177. slice?: number;
  21178. sideOrientation?: number;
  21179. frontUVs?: Vector4;
  21180. backUVs?: Vector4;
  21181. updatable?: boolean;
  21182. }, scene: any): Mesh;
  21183. /**
  21184. * Creates a plane polygonal mesh. By default, this is a disc
  21185. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  21186. * * 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
  21187. * * 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
  21188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21189. * * 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
  21190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21191. * @param name defines the name of the mesh
  21192. * @param options defines the options used to create the mesh
  21193. * @param scene defines the hosting scene
  21194. * @returns the plane polygonal mesh
  21195. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  21196. */
  21197. static CreateDisc(name: string, options: {
  21198. radius?: number;
  21199. tessellation?: number;
  21200. arc?: number;
  21201. updatable?: boolean;
  21202. sideOrientation?: number;
  21203. frontUVs?: Vector4;
  21204. backUVs?: Vector4;
  21205. }, scene?: Nullable<Scene>): Mesh;
  21206. /**
  21207. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21208. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21209. * * 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`)
  21210. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21211. * * 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
  21212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21213. * * 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
  21214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21215. * @param name defines the name of the mesh
  21216. * @param options defines the options used to create the mesh
  21217. * @param scene defines the hosting scene
  21218. * @returns the icosahedron mesh
  21219. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21220. */
  21221. static CreateIcoSphere(name: string, options: {
  21222. radius?: number;
  21223. radiusX?: number;
  21224. radiusY?: number;
  21225. radiusZ?: number;
  21226. flat?: boolean;
  21227. subdivisions?: number;
  21228. sideOrientation?: number;
  21229. frontUVs?: Vector4;
  21230. backUVs?: Vector4;
  21231. updatable?: boolean;
  21232. }, scene: Scene): Mesh;
  21233. /**
  21234. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  21235. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  21236. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  21237. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  21238. * * 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
  21239. * * 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
  21240. * * 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
  21241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21242. * * 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
  21243. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  21244. * * 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
  21245. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  21246. * * 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
  21247. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  21248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21249. * @param name defines the name of the mesh
  21250. * @param options defines the options used to create the mesh
  21251. * @param scene defines the hosting scene
  21252. * @returns the ribbon mesh
  21253. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21254. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  21255. */
  21256. static CreateRibbon(name: string, options: {
  21257. pathArray: Vector3[][];
  21258. closeArray?: boolean;
  21259. closePath?: boolean;
  21260. offset?: number;
  21261. updatable?: boolean;
  21262. sideOrientation?: number;
  21263. frontUVs?: Vector4;
  21264. backUVs?: Vector4;
  21265. instance?: Mesh;
  21266. invertUV?: boolean;
  21267. uvs?: Vector2[];
  21268. colors?: Color4[];
  21269. }, scene?: Nullable<Scene>): Mesh;
  21270. /**
  21271. * Creates a cylinder or a cone mesh
  21272. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21273. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21274. * * 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.
  21275. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21276. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21277. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  21278. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  21279. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  21280. * * 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).
  21281. * * 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
  21282. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  21283. * * 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
  21284. * * 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.
  21285. * * If `enclose` is false, a ring surface is one element.
  21286. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  21287. * * 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
  21288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21289. * * 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
  21290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21291. * @param name defines the name of the mesh
  21292. * @param options defines the options used to create the mesh
  21293. * @param scene defines the hosting scene
  21294. * @returns the cylinder mesh
  21295. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  21296. */
  21297. static CreateCylinder(name: string, options: {
  21298. height?: number;
  21299. diameterTop?: number;
  21300. diameterBottom?: number;
  21301. diameter?: number;
  21302. tessellation?: number;
  21303. subdivisions?: number;
  21304. arc?: number;
  21305. faceColors?: Color4[];
  21306. faceUV?: Vector4[];
  21307. updatable?: boolean;
  21308. hasRings?: boolean;
  21309. enclose?: boolean;
  21310. sideOrientation?: number;
  21311. frontUVs?: Vector4;
  21312. backUVs?: Vector4;
  21313. }, scene: any): Mesh;
  21314. /**
  21315. * Creates a torus mesh
  21316. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  21317. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  21318. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  21319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21320. * * 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
  21321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21322. * @param name defines the name of the mesh
  21323. * @param options defines the options used to create the mesh
  21324. * @param scene defines the hosting scene
  21325. * @returns the torus mesh
  21326. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  21327. */
  21328. static CreateTorus(name: string, options: {
  21329. diameter?: number;
  21330. thickness?: number;
  21331. tessellation?: number;
  21332. updatable?: boolean;
  21333. sideOrientation?: number;
  21334. frontUVs?: Vector4;
  21335. backUVs?: Vector4;
  21336. }, scene: any): Mesh;
  21337. /**
  21338. * Creates a torus knot mesh
  21339. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  21340. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  21341. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  21342. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  21343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21344. * * 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
  21345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21346. * @param name defines the name of the mesh
  21347. * @param options defines the options used to create the mesh
  21348. * @param scene defines the hosting scene
  21349. * @returns the torus knot mesh
  21350. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  21351. */
  21352. static CreateTorusKnot(name: string, options: {
  21353. radius?: number;
  21354. tube?: number;
  21355. radialSegments?: number;
  21356. tubularSegments?: number;
  21357. p?: number;
  21358. q?: number;
  21359. updatable?: boolean;
  21360. sideOrientation?: number;
  21361. frontUVs?: Vector4;
  21362. backUVs?: Vector4;
  21363. }, scene: any): Mesh;
  21364. /**
  21365. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  21366. * * 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
  21367. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  21368. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  21369. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  21370. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  21371. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  21372. * * 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
  21373. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  21374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21375. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  21376. * @param name defines the name of the new line system
  21377. * @param options defines the options used to create the line system
  21378. * @param scene defines the hosting scene
  21379. * @returns a new line system mesh
  21380. */
  21381. static CreateLineSystem(name: string, options: {
  21382. lines: Vector3[][];
  21383. updatable?: boolean;
  21384. instance?: Nullable<LinesMesh>;
  21385. colors?: Nullable<Color4[][]>;
  21386. useVertexAlpha?: boolean;
  21387. }, scene: Nullable<Scene>): LinesMesh;
  21388. /**
  21389. * Creates a line mesh
  21390. * 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
  21391. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  21392. * * The parameter `points` is an array successive Vector3
  21393. * * 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
  21394. * * The optional parameter `colors` is an array of successive Color4, one per line point
  21395. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  21396. * * When updating an instance, remember that only point positions can change, not the number of points
  21397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21398. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  21399. * @param name defines the name of the new line system
  21400. * @param options defines the options used to create the line system
  21401. * @param scene defines the hosting scene
  21402. * @returns a new line mesh
  21403. */
  21404. static CreateLines(name: string, options: {
  21405. points: Vector3[];
  21406. updatable?: boolean;
  21407. instance?: Nullable<LinesMesh>;
  21408. colors?: Color4[];
  21409. useVertexAlpha?: boolean;
  21410. }, scene?: Nullable<Scene>): LinesMesh;
  21411. /**
  21412. * Creates a dashed line mesh
  21413. * * 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
  21414. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  21415. * * The parameter `points` is an array successive Vector3
  21416. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  21417. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  21418. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21419. * * 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
  21420. * * When updating an instance, remember that only point positions can change, not the number of points
  21421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21422. * @param name defines the name of the mesh
  21423. * @param options defines the options used to create the mesh
  21424. * @param scene defines the hosting scene
  21425. * @returns the dashed line mesh
  21426. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  21427. */
  21428. static CreateDashedLines(name: string, options: {
  21429. points: Vector3[];
  21430. dashSize?: number;
  21431. gapSize?: number;
  21432. dashNb?: number;
  21433. updatable?: boolean;
  21434. instance?: LinesMesh;
  21435. }, scene?: Nullable<Scene>): LinesMesh;
  21436. /**
  21437. * 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.
  21438. * * 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.
  21439. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21440. * * 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.
  21441. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  21442. * * 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
  21443. * * 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
  21444. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21446. * * 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
  21447. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  21448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21449. * @param name defines the name of the mesh
  21450. * @param options defines the options used to create the mesh
  21451. * @param scene defines the hosting scene
  21452. * @returns the extruded shape mesh
  21453. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  21454. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21455. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21456. */
  21457. static ExtrudeShape(name: string, options: {
  21458. shape: Vector3[];
  21459. path: Vector3[];
  21460. scale?: number;
  21461. rotation?: number;
  21462. cap?: number;
  21463. updatable?: boolean;
  21464. sideOrientation?: number;
  21465. frontUVs?: Vector4;
  21466. backUVs?: Vector4;
  21467. instance?: Mesh;
  21468. invertUV?: boolean;
  21469. }, scene?: Nullable<Scene>): Mesh;
  21470. /**
  21471. * Creates an custom extruded shape mesh.
  21472. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  21473. * * 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.
  21474. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21475. * * 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
  21476. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  21477. * * 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
  21478. * * It must returns a float value that will be the scale value applied to the shape on each path point
  21479. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21480. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  21481. * * 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
  21482. * * 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
  21483. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  21484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21485. * * 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
  21486. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  21487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21488. * @param name defines the name of the mesh
  21489. * @param options defines the options used to create the mesh
  21490. * @param scene defines the hosting scene
  21491. * @returns the custom extruded shape mesh
  21492. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  21493. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  21494. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21495. */
  21496. static ExtrudeShapeCustom(name: string, options: {
  21497. shape: Vector3[];
  21498. path: Vector3[];
  21499. scaleFunction?: any;
  21500. rotationFunction?: any;
  21501. ribbonCloseArray?: boolean;
  21502. ribbonClosePath?: boolean;
  21503. cap?: number;
  21504. updatable?: boolean;
  21505. sideOrientation?: number;
  21506. frontUVs?: Vector4;
  21507. backUVs?: Vector4;
  21508. instance?: Mesh;
  21509. invertUV?: boolean;
  21510. }, scene: Scene): Mesh;
  21511. /**
  21512. * Creates lathe mesh.
  21513. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  21514. * * 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
  21515. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  21516. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  21517. * * 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
  21518. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  21519. * * 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
  21520. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21521. * * 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
  21522. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  21523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21524. * @param name defines the name of the mesh
  21525. * @param options defines the options used to create the mesh
  21526. * @param scene defines the hosting scene
  21527. * @returns the lathe mesh
  21528. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  21529. */
  21530. static CreateLathe(name: string, options: {
  21531. shape: Vector3[];
  21532. radius?: number;
  21533. tessellation?: number;
  21534. arc?: number;
  21535. closed?: boolean;
  21536. updatable?: boolean;
  21537. sideOrientation?: number;
  21538. frontUVs?: Vector4;
  21539. backUVs?: Vector4;
  21540. cap?: number;
  21541. invertUV?: boolean;
  21542. }, scene: Scene): Mesh;
  21543. /**
  21544. * Creates a plane mesh
  21545. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  21546. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  21547. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  21548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21549. * * 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
  21550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21551. * @param name defines the name of the mesh
  21552. * @param options defines the options used to create the mesh
  21553. * @param scene defines the hosting scene
  21554. * @returns the plane mesh
  21555. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  21556. */
  21557. static CreatePlane(name: string, options: {
  21558. size?: number;
  21559. width?: number;
  21560. height?: number;
  21561. sideOrientation?: number;
  21562. frontUVs?: Vector4;
  21563. backUVs?: Vector4;
  21564. updatable?: boolean;
  21565. sourcePlane?: Plane;
  21566. }, scene: Scene): Mesh;
  21567. /**
  21568. * Creates a ground mesh
  21569. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  21570. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  21571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21572. * @param name defines the name of the mesh
  21573. * @param options defines the options used to create the mesh
  21574. * @param scene defines the hosting scene
  21575. * @returns the ground mesh
  21576. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  21577. */
  21578. static CreateGround(name: string, options: {
  21579. width?: number;
  21580. height?: number;
  21581. subdivisions?: number;
  21582. subdivisionsX?: number;
  21583. subdivisionsY?: number;
  21584. updatable?: boolean;
  21585. }, scene: any): Mesh;
  21586. /**
  21587. * Creates a tiled ground mesh
  21588. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  21589. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  21590. * * 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
  21591. * * 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
  21592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21593. * @param name defines the name of the mesh
  21594. * @param options defines the options used to create the mesh
  21595. * @param scene defines the hosting scene
  21596. * @returns the tiled ground mesh
  21597. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  21598. */
  21599. static CreateTiledGround(name: string, options: {
  21600. xmin: number;
  21601. zmin: number;
  21602. xmax: number;
  21603. zmax: number;
  21604. subdivisions?: {
  21605. w: number;
  21606. h: number;
  21607. };
  21608. precision?: {
  21609. w: number;
  21610. h: number;
  21611. };
  21612. updatable?: boolean;
  21613. }, scene: Scene): Mesh;
  21614. /**
  21615. * Creates a ground mesh from a height map
  21616. * * The parameter `url` sets the URL of the height map image resource.
  21617. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  21618. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  21619. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  21620. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  21621. * * 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.
  21622. * * 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).
  21623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21624. * @param name defines the name of the mesh
  21625. * @param url defines the url to the height map
  21626. * @param options defines the options used to create the mesh
  21627. * @param scene defines the hosting scene
  21628. * @returns the ground mesh
  21629. * @see http://doc.babylonjs.com/babylon101/height_map
  21630. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  21631. */
  21632. static CreateGroundFromHeightMap(name: string, url: string, options: {
  21633. width?: number;
  21634. height?: number;
  21635. subdivisions?: number;
  21636. minHeight?: number;
  21637. maxHeight?: number;
  21638. colorFilter?: Color3;
  21639. updatable?: boolean;
  21640. onReady?: (mesh: GroundMesh) => void;
  21641. }, scene: Scene): GroundMesh;
  21642. /**
  21643. * Creates a polygon mesh
  21644. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  21645. * * 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
  21646. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21648. * * 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)
  21649. * * Remember you can only change the shape positions, not their number when updating a polygon
  21650. * @param name defines the name of the mesh
  21651. * @param options defines the options used to create the mesh
  21652. * @param scene defines the hosting scene
  21653. * @returns the polygon mesh
  21654. */
  21655. static CreatePolygon(name: string, options: {
  21656. shape: Vector3[];
  21657. holes?: Vector3[][];
  21658. depth?: number;
  21659. faceUV?: Vector4[];
  21660. faceColors?: Color4[];
  21661. updatable?: boolean;
  21662. sideOrientation?: number;
  21663. frontUVs?: Vector4;
  21664. backUVs?: Vector4;
  21665. }, scene: Scene): Mesh;
  21666. /**
  21667. * Creates an extruded polygon mesh, with depth in the Y direction.
  21668. * * 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)
  21669. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  21670. * @param name defines the name of the mesh
  21671. * @param options defines the options used to create the mesh
  21672. * @param scene defines the hosting scene
  21673. * @returns the polygon mesh
  21674. */
  21675. static ExtrudePolygon(name: string, options: {
  21676. shape: Vector3[];
  21677. holes?: Vector3[][];
  21678. depth?: number;
  21679. faceUV?: Vector4[];
  21680. faceColors?: Color4[];
  21681. updatable?: boolean;
  21682. sideOrientation?: number;
  21683. frontUVs?: Vector4;
  21684. backUVs?: Vector4;
  21685. }, scene: Scene): Mesh;
  21686. /**
  21687. * Creates a tube mesh.
  21688. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  21689. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  21690. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  21691. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  21692. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  21693. * * 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)
  21694. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  21695. * * 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
  21696. * * 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
  21697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21698. * * 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
  21699. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  21700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21701. * @param name defines the name of the mesh
  21702. * @param options defines the options used to create the mesh
  21703. * @param scene defines the hosting scene
  21704. * @returns the tube mesh
  21705. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  21706. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  21707. */
  21708. static CreateTube(name: string, options: {
  21709. path: Vector3[];
  21710. radius?: number;
  21711. tessellation?: number;
  21712. radiusFunction?: {
  21713. (i: number, distance: number): number;
  21714. };
  21715. cap?: number;
  21716. arc?: number;
  21717. updatable?: boolean;
  21718. sideOrientation?: number;
  21719. frontUVs?: Vector4;
  21720. backUVs?: Vector4;
  21721. instance?: Mesh;
  21722. invertUV?: boolean;
  21723. }, scene: Scene): Mesh;
  21724. /**
  21725. * Creates a polyhedron mesh
  21726. * * 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
  21727. * * The parameter `size` (positive float, default 1) sets the polygon size
  21728. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21729. * * 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`
  21730. * * 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
  21731. * * 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)`)
  21732. * * 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
  21733. * * 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
  21734. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21735. * * 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
  21736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21737. * @param name defines the name of the mesh
  21738. * @param options defines the options used to create the mesh
  21739. * @param scene defines the hosting scene
  21740. * @returns the polyhedron mesh
  21741. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  21742. */
  21743. static CreatePolyhedron(name: string, options: {
  21744. type?: number;
  21745. size?: number;
  21746. sizeX?: number;
  21747. sizeY?: number;
  21748. sizeZ?: number;
  21749. custom?: any;
  21750. faceUV?: Vector4[];
  21751. faceColors?: Color4[];
  21752. flat?: boolean;
  21753. updatable?: boolean;
  21754. sideOrientation?: number;
  21755. frontUVs?: Vector4;
  21756. backUVs?: Vector4;
  21757. }, scene: Scene): Mesh;
  21758. /**
  21759. * Creates a decal mesh.
  21760. * 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
  21761. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  21762. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  21763. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  21764. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  21765. * @param name defines the name of the mesh
  21766. * @param sourceMesh defines the mesh where the decal must be applied
  21767. * @param options defines the options used to create the mesh
  21768. * @param scene defines the hosting scene
  21769. * @returns the decal mesh
  21770. * @see http://doc.babylonjs.com/how_to/decals
  21771. */
  21772. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  21773. position?: Vector3;
  21774. normal?: Vector3;
  21775. size?: Vector3;
  21776. angle?: number;
  21777. }): Mesh;
  21778. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  21779. }
  21780. }
  21781. declare module BABYLON {
  21782. class MeshLODLevel {
  21783. distance: number;
  21784. mesh: Mesh;
  21785. constructor(distance: number, mesh: Mesh);
  21786. }
  21787. }
  21788. declare module BABYLON {
  21789. /**
  21790. * A simplifier interface for future simplification implementations.
  21791. */
  21792. interface ISimplifier {
  21793. /**
  21794. * Simplification of a given mesh according to the given settings.
  21795. * Since this requires computation, it is assumed that the function runs async.
  21796. * @param settings The settings of the simplification, including quality and distance
  21797. * @param successCallback A callback that will be called after the mesh was simplified.
  21798. * @param errorCallback in case of an error, this callback will be called. optional.
  21799. */
  21800. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  21801. }
  21802. /**
  21803. * Expected simplification settings.
  21804. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  21805. */
  21806. interface ISimplificationSettings {
  21807. quality: number;
  21808. distance: number;
  21809. optimizeMesh?: boolean;
  21810. }
  21811. class SimplificationSettings implements ISimplificationSettings {
  21812. quality: number;
  21813. distance: number;
  21814. optimizeMesh: boolean | undefined;
  21815. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  21816. }
  21817. interface ISimplificationTask {
  21818. settings: Array<ISimplificationSettings>;
  21819. simplificationType: SimplificationType;
  21820. mesh: Mesh;
  21821. successCallback?: () => void;
  21822. parallelProcessing: boolean;
  21823. }
  21824. class SimplificationQueue {
  21825. private _simplificationArray;
  21826. running: boolean;
  21827. constructor();
  21828. addTask(task: ISimplificationTask): void;
  21829. executeNext(): void;
  21830. runSimplification(task: ISimplificationTask): void;
  21831. private getSimplifier(task);
  21832. }
  21833. /**
  21834. * The implemented types of simplification
  21835. * At the moment only Quadratic Error Decimation is implemented
  21836. */
  21837. enum SimplificationType {
  21838. /** Quadratic error decimation */
  21839. QUADRATIC = 0,
  21840. }
  21841. class DecimationTriangle {
  21842. vertices: Array<DecimationVertex>;
  21843. normal: Vector3;
  21844. error: Array<number>;
  21845. deleted: boolean;
  21846. isDirty: boolean;
  21847. borderFactor: number;
  21848. deletePending: boolean;
  21849. originalOffset: number;
  21850. constructor(vertices: Array<DecimationVertex>);
  21851. }
  21852. class DecimationVertex {
  21853. position: Vector3;
  21854. id: number;
  21855. q: QuadraticMatrix;
  21856. isBorder: boolean;
  21857. triangleStart: number;
  21858. triangleCount: number;
  21859. originalOffsets: Array<number>;
  21860. constructor(position: Vector3, id: number);
  21861. updatePosition(newPosition: Vector3): void;
  21862. }
  21863. class QuadraticMatrix {
  21864. data: Array<number>;
  21865. constructor(data?: Array<number>);
  21866. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  21867. addInPlace(matrix: QuadraticMatrix): void;
  21868. addArrayInPlace(data: Array<number>): void;
  21869. add(matrix: QuadraticMatrix): QuadraticMatrix;
  21870. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  21871. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  21872. }
  21873. class Reference {
  21874. vertexId: number;
  21875. triangleId: number;
  21876. constructor(vertexId: number, triangleId: number);
  21877. }
  21878. /**
  21879. * An implementation of the Quadratic Error simplification algorithm.
  21880. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  21881. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  21882. * @author RaananW
  21883. */
  21884. class QuadraticErrorSimplification implements ISimplifier {
  21885. private _mesh;
  21886. private triangles;
  21887. private vertices;
  21888. private references;
  21889. private _reconstructedMesh;
  21890. syncIterations: number;
  21891. aggressiveness: number;
  21892. decimationIterations: number;
  21893. boundingBoxEpsilon: number;
  21894. constructor(_mesh: Mesh);
  21895. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  21896. private runDecimation(settings, submeshIndex, successCallback);
  21897. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  21898. private init(callback);
  21899. private reconstructMesh(submeshIndex);
  21900. private initDecimatedMesh();
  21901. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  21902. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  21903. private identifyBorder();
  21904. private updateMesh(identifyBorders?);
  21905. private vertexError(q, point);
  21906. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  21907. }
  21908. }
  21909. declare module BABYLON {
  21910. class Polygon {
  21911. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  21912. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  21913. static Parse(input: string): Vector2[];
  21914. static StartingAt(x: number, y: number): Path2;
  21915. }
  21916. class PolygonMeshBuilder {
  21917. private _points;
  21918. private _outlinepoints;
  21919. private _holes;
  21920. private _name;
  21921. private _scene;
  21922. private _epoints;
  21923. private _eholes;
  21924. private _addToepoint(points);
  21925. constructor(name: string, contours: Path2, scene: Scene);
  21926. constructor(name: string, contours: Vector2[], scene: Scene);
  21927. addHole(hole: Vector2[]): PolygonMeshBuilder;
  21928. build(updatable?: boolean, depth?: number): Mesh;
  21929. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  21930. }
  21931. }
  21932. declare module BABYLON {
  21933. class BaseSubMesh {
  21934. _materialDefines: Nullable<MaterialDefines>;
  21935. _materialEffect: Nullable<Effect>;
  21936. readonly effect: Nullable<Effect>;
  21937. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21938. }
  21939. class SubMesh extends BaseSubMesh implements ICullable {
  21940. materialIndex: number;
  21941. verticesStart: number;
  21942. verticesCount: number;
  21943. indexStart: number;
  21944. indexCount: number;
  21945. linesIndexCount: number;
  21946. private _mesh;
  21947. private _renderingMesh;
  21948. private _boundingInfo;
  21949. private _linesIndexBuffer;
  21950. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21951. _trianglePlanes: Plane[];
  21952. _lastColliderTransformMatrix: Matrix;
  21953. _renderId: number;
  21954. _alphaIndex: number;
  21955. _distanceToCamera: number;
  21956. _id: number;
  21957. private _currentMaterial;
  21958. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21959. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21960. readonly IsGlobal: boolean;
  21961. /**
  21962. * Returns the submesh BoudingInfo object.
  21963. */
  21964. getBoundingInfo(): BoundingInfo;
  21965. /**
  21966. * Sets the submesh BoundingInfo.
  21967. * Return the SubMesh.
  21968. */
  21969. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21970. /**
  21971. * Returns the mesh of the current submesh.
  21972. */
  21973. getMesh(): AbstractMesh;
  21974. /**
  21975. * Returns the rendering mesh of the submesh.
  21976. */
  21977. getRenderingMesh(): Mesh;
  21978. /**
  21979. * Returns the submesh material.
  21980. */
  21981. getMaterial(): Nullable<Material>;
  21982. /**
  21983. * Sets a new updated BoundingInfo object to the submesh.
  21984. * Returns the SubMesh.
  21985. */
  21986. refreshBoundingInfo(): SubMesh;
  21987. _checkCollision(collider: Collider): boolean;
  21988. /**
  21989. * Updates the submesh BoundingInfo.
  21990. * Returns the Submesh.
  21991. */
  21992. updateBoundingInfo(world: Matrix): SubMesh;
  21993. /**
  21994. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21995. * Boolean returned.
  21996. */
  21997. isInFrustum(frustumPlanes: Plane[]): boolean;
  21998. /**
  21999. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  22000. * Boolean returned.
  22001. */
  22002. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22003. /**
  22004. * Renders the submesh.
  22005. * Returns it.
  22006. */
  22007. render(enableAlphaMode: boolean): SubMesh;
  22008. /**
  22009. * Returns a new Index Buffer.
  22010. * Type returned : WebGLBuffer.
  22011. */
  22012. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22013. /**
  22014. * True is the passed Ray intersects the submesh bounding box.
  22015. * Boolean returned.
  22016. */
  22017. canIntersects(ray: Ray): boolean;
  22018. /**
  22019. * Returns an object IntersectionInfo.
  22020. */
  22021. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  22022. _rebuild(): void;
  22023. /**
  22024. * Creates a new Submesh from the passed Mesh.
  22025. */
  22026. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22027. /**
  22028. * Disposes the Submesh.
  22029. * Returns nothing.
  22030. */
  22031. dispose(): void;
  22032. /**
  22033. * Creates a new Submesh from the passed parameters :
  22034. * - materialIndex (integer) : the index of the main mesh material.
  22035. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  22036. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  22037. * - mesh (Mesh) : the main mesh to create the submesh from.
  22038. * - renderingMesh (optional Mesh) : rendering mesh.
  22039. */
  22040. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22041. }
  22042. }
  22043. declare module BABYLON {
  22044. class TransformNode extends Node {
  22045. static BILLBOARDMODE_NONE: number;
  22046. static BILLBOARDMODE_X: number;
  22047. static BILLBOARDMODE_Y: number;
  22048. static BILLBOARDMODE_Z: number;
  22049. static BILLBOARDMODE_ALL: number;
  22050. private _forward;
  22051. private _forwardInverted;
  22052. private _up;
  22053. private _right;
  22054. private _rightInverted;
  22055. private _rotation;
  22056. private _rotationQuaternion;
  22057. protected _scaling: Vector3;
  22058. protected _isDirty: boolean;
  22059. private _transformToBoneReferal;
  22060. billboardMode: number;
  22061. scalingDeterminant: number;
  22062. infiniteDistance: boolean;
  22063. position: Vector3;
  22064. _poseMatrix: Matrix;
  22065. private _localWorld;
  22066. _worldMatrix: Matrix;
  22067. _worldMatrixDeterminant: number;
  22068. private _absolutePosition;
  22069. private _pivotMatrix;
  22070. private _pivotMatrixInverse;
  22071. private _postMultiplyPivotMatrix;
  22072. protected _isWorldMatrixFrozen: boolean;
  22073. /**
  22074. * An event triggered after the world matrix is updated
  22075. */
  22076. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  22077. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  22078. /**
  22079. * Gets a string idenfifying the name of the class
  22080. * @returns "TransformNode" string
  22081. */
  22082. getClassName(): string;
  22083. /**
  22084. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  22085. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  22086. * Default : (0.0, 0.0, 0.0)
  22087. */
  22088. rotation: Vector3;
  22089. /**
  22090. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  22091. * Default : (1.0, 1.0, 1.0)
  22092. */
  22093. /**
  22094. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  22095. * Default : (1.0, 1.0, 1.0)
  22096. */
  22097. scaling: Vector3;
  22098. /**
  22099. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  22100. * It's null by default.
  22101. * 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)
  22102. */
  22103. rotationQuaternion: Nullable<Quaternion>;
  22104. /**
  22105. * The forward direction of that transform in world space.
  22106. */
  22107. readonly forward: Vector3;
  22108. /**
  22109. * The up direction of that transform in world space.
  22110. */
  22111. readonly up: Vector3;
  22112. /**
  22113. * The right direction of that transform in world space.
  22114. */
  22115. readonly right: Vector3;
  22116. /**
  22117. * Returns the latest update of the World matrix
  22118. * Returns a Matrix.
  22119. */
  22120. getWorldMatrix(): Matrix;
  22121. /** @hidden */
  22122. _getWorldMatrixDeterminant(): number;
  22123. /**
  22124. * Returns directly the latest state of the mesh World matrix.
  22125. * A Matrix is returned.
  22126. */
  22127. readonly worldMatrixFromCache: Matrix;
  22128. /**
  22129. * Copies the paramater passed Matrix into the mesh Pose matrix.
  22130. * Returns the TransformNode.
  22131. */
  22132. updatePoseMatrix(matrix: Matrix): TransformNode;
  22133. /**
  22134. * Returns the mesh Pose matrix.
  22135. * Returned object : Matrix
  22136. */
  22137. getPoseMatrix(): Matrix;
  22138. _isSynchronized(): boolean;
  22139. _initCache(): void;
  22140. markAsDirty(property: string): TransformNode;
  22141. /**
  22142. * Returns the current mesh absolute position.
  22143. * Retuns a Vector3.
  22144. */
  22145. readonly absolutePosition: Vector3;
  22146. /**
  22147. * Sets a new matrix to apply before all other transformation
  22148. * @param matrix defines the transform matrix
  22149. * @returns the current TransformNode
  22150. */
  22151. setPreTransformMatrix(matrix: Matrix): TransformNode;
  22152. /**
  22153. * Sets a new pivot matrix to the current node
  22154. * @param matrix defines the new pivot matrix to use
  22155. * @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
  22156. * @returns the current TransformNode
  22157. */
  22158. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  22159. /**
  22160. * Returns the mesh pivot matrix.
  22161. * Default : Identity.
  22162. * A Matrix is returned.
  22163. */
  22164. getPivotMatrix(): Matrix;
  22165. /**
  22166. * Prevents the World matrix to be computed any longer.
  22167. * Returns the TransformNode.
  22168. */
  22169. freezeWorldMatrix(): TransformNode;
  22170. /**
  22171. * Allows back the World matrix computation.
  22172. * Returns the TransformNode.
  22173. */
  22174. unfreezeWorldMatrix(): this;
  22175. /**
  22176. * True if the World matrix has been frozen.
  22177. * Returns a boolean.
  22178. */
  22179. readonly isWorldMatrixFrozen: boolean;
  22180. /**
  22181. * Retuns the mesh absolute position in the World.
  22182. * Returns a Vector3.
  22183. */
  22184. getAbsolutePosition(): Vector3;
  22185. /**
  22186. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  22187. * Returns the TransformNode.
  22188. */
  22189. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22190. /**
  22191. * Sets the mesh position in its local space.
  22192. * Returns the TransformNode.
  22193. */
  22194. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  22195. /**
  22196. * Returns the mesh position in the local space from the current World matrix values.
  22197. * Returns a new Vector3.
  22198. */
  22199. getPositionExpressedInLocalSpace(): Vector3;
  22200. /**
  22201. * Translates the mesh along the passed Vector3 in its local space.
  22202. * Returns the TransformNode.
  22203. */
  22204. locallyTranslate(vector3: Vector3): TransformNode;
  22205. private static _lookAtVectorCache;
  22206. /**
  22207. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  22208. * @param targetPoint the position (must be in same space as current mesh) to look at
  22209. * @param yawCor optional yaw (y-axis) correction in radians
  22210. * @param pitchCor optional pitch (x-axis) correction in radians
  22211. * @param rollCor optional roll (z-axis) correction in radians
  22212. * @param space the choosen space of the target
  22213. * @returns the TransformNode.
  22214. */
  22215. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  22216. /**
  22217. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  22218. * This Vector3 is expressed in the World space.
  22219. */
  22220. getDirection(localAxis: Vector3): Vector3;
  22221. /**
  22222. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  22223. * localAxis is expressed in the mesh local space.
  22224. * result is computed in the Wordl space from the mesh World matrix.
  22225. * Returns the TransformNode.
  22226. */
  22227. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  22228. /**
  22229. * Sets a new pivot point to the current node
  22230. * @param point defines the new pivot point to use
  22231. * @param space defines if the point is in world or local space (local by default)
  22232. * @returns the current TransformNode
  22233. */
  22234. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  22235. /**
  22236. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  22237. */
  22238. getPivotPoint(): Vector3;
  22239. /**
  22240. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  22241. * Returns the TransformNode.
  22242. */
  22243. getPivotPointToRef(result: Vector3): TransformNode;
  22244. /**
  22245. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  22246. */
  22247. getAbsolutePivotPoint(): Vector3;
  22248. /**
  22249. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  22250. * Returns the TransformNode.
  22251. */
  22252. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  22253. /**
  22254. * Defines the passed node as the parent of the current node.
  22255. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  22256. * Returns the TransformNode.
  22257. */
  22258. setParent(node: Nullable<Node>): TransformNode;
  22259. private _nonUniformScaling;
  22260. readonly nonUniformScaling: boolean;
  22261. _updateNonUniformScalingState(value: boolean): boolean;
  22262. /**
  22263. * Attach the current TransformNode to another TransformNode associated with a bone
  22264. * @param bone Bone affecting the TransformNode
  22265. * @param affectedTransformNode TransformNode associated with the bone
  22266. */
  22267. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  22268. detachFromBone(): TransformNode;
  22269. private static _rotationAxisCache;
  22270. /**
  22271. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  22272. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  22273. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  22274. * The passed axis is also normalized.
  22275. * Returns the TransformNode.
  22276. */
  22277. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22278. /**
  22279. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  22280. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  22281. * The passed axis is also normalized.
  22282. * Returns the TransformNode.
  22283. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  22284. */
  22285. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  22286. /**
  22287. * Translates the mesh along the axis vector for the passed distance in the given space.
  22288. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  22289. * Returns the TransformNode.
  22290. */
  22291. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22292. /**
  22293. * Adds a rotation step to the mesh current rotation.
  22294. * x, y, z are Euler angles expressed in radians.
  22295. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  22296. * This means this rotation is made in the mesh local space only.
  22297. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  22298. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  22299. * ```javascript
  22300. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  22301. * ```
  22302. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  22303. * 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.
  22304. * Returns the TransformNode.
  22305. */
  22306. addRotation(x: number, y: number, z: number): TransformNode;
  22307. /**
  22308. * Computes the mesh World matrix and returns it.
  22309. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  22310. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  22311. * If the parameter `force`is set to `true`, the actual computation is done.
  22312. * Returns the mesh World Matrix.
  22313. */
  22314. computeWorldMatrix(force?: boolean): Matrix;
  22315. protected _afterComputeWorldMatrix(): void;
  22316. /**
  22317. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  22318. * @param func: callback function to add
  22319. *
  22320. * Returns the TransformNode.
  22321. */
  22322. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  22323. /**
  22324. * Removes a registered callback function.
  22325. * Returns the TransformNode.
  22326. */
  22327. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  22328. /**
  22329. * Clone the current transform node
  22330. * Returns the new transform node
  22331. * @param name Name of the new clone
  22332. * @param newParent New parent for the clone
  22333. * @param doNotCloneChildren Do not clone children hierarchy
  22334. */
  22335. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  22336. serialize(currentSerializationObject?: any): any;
  22337. /**
  22338. * Returns a new TransformNode object parsed from the source provided.
  22339. * The parameter `parsedMesh` is the source.
  22340. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  22341. */
  22342. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  22343. /**
  22344. * Releases resources associated with this transform node.
  22345. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22346. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22347. */
  22348. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22349. }
  22350. }
  22351. declare module BABYLON {
  22352. class VertexBuffer {
  22353. private _buffer;
  22354. private _kind;
  22355. private _size;
  22356. private _ownsBuffer;
  22357. private _instanced;
  22358. private _instanceDivisor;
  22359. /**
  22360. * The byte type.
  22361. */
  22362. static readonly BYTE: number;
  22363. /**
  22364. * The unsigned byte type.
  22365. */
  22366. static readonly UNSIGNED_BYTE: number;
  22367. /**
  22368. * The short type.
  22369. */
  22370. static readonly SHORT: number;
  22371. /**
  22372. * The unsigned short type.
  22373. */
  22374. static readonly UNSIGNED_SHORT: number;
  22375. /**
  22376. * The integer type.
  22377. */
  22378. static readonly INT: number;
  22379. /**
  22380. * The unsigned integer type.
  22381. */
  22382. static readonly UNSIGNED_INT: number;
  22383. /**
  22384. * The float type.
  22385. */
  22386. static readonly FLOAT: number;
  22387. /**
  22388. * Gets or sets the instance divisor when in instanced mode
  22389. */
  22390. instanceDivisor: number;
  22391. /**
  22392. * Gets the byte stride.
  22393. */
  22394. readonly byteStride: number;
  22395. /**
  22396. * Gets the byte offset.
  22397. */
  22398. readonly byteOffset: number;
  22399. /**
  22400. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  22401. */
  22402. readonly normalized: boolean;
  22403. /**
  22404. * Gets the data type of each component in the array.
  22405. */
  22406. readonly type: number;
  22407. /**
  22408. * Constructor
  22409. * @param engine the engine
  22410. * @param data the data to use for this vertex buffer
  22411. * @param kind the vertex buffer kind
  22412. * @param updatable whether the data is updatable
  22413. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  22414. * @param stride the stride (optional)
  22415. * @param instanced whether the buffer is instanced (optional)
  22416. * @param offset the offset of the data (optional)
  22417. * @param size the number of components (optional)
  22418. * @param type the type of the component (optional)
  22419. * @param normalized whether the data contains normalized data (optional)
  22420. * @param useBytes set to true if stride and offset are in bytes (optional)
  22421. */
  22422. 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);
  22423. _rebuild(): void;
  22424. /**
  22425. * Returns the kind of the VertexBuffer (string).
  22426. */
  22427. getKind(): string;
  22428. /**
  22429. * Boolean : is the VertexBuffer updatable ?
  22430. */
  22431. isUpdatable(): boolean;
  22432. /**
  22433. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  22434. */
  22435. getData(): Nullable<DataArray>;
  22436. /**
  22437. * Returns the WebGLBuffer associated to the VertexBuffer.
  22438. */
  22439. getBuffer(): Nullable<WebGLBuffer>;
  22440. /**
  22441. * Returns the stride as a multiple of the type byte length.
  22442. * DEPRECATED. Use byteStride instead.
  22443. */
  22444. getStrideSize(): number;
  22445. /**
  22446. * Returns the offset as a multiple of the type byte length.
  22447. * DEPRECATED. Use byteOffset instead.
  22448. */
  22449. getOffset(): number;
  22450. /**
  22451. * Returns the number of components per vertex attribute (integer).
  22452. */
  22453. getSize(): number;
  22454. /**
  22455. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  22456. */
  22457. getIsInstanced(): boolean;
  22458. /**
  22459. * Returns the instancing divisor, zero for non-instanced (integer).
  22460. */
  22461. getInstanceDivisor(): number;
  22462. /**
  22463. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  22464. * Returns the created WebGLBuffer.
  22465. */
  22466. create(data?: DataArray): void;
  22467. /**
  22468. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  22469. * This function will create a new buffer if the current one is not updatable
  22470. * Returns the updated WebGLBuffer.
  22471. */
  22472. update(data: DataArray): void;
  22473. /**
  22474. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  22475. * Returns the directly updated WebGLBuffer.
  22476. * @param data the new data
  22477. * @param offset the new offset
  22478. * @param useBytes set to true if the offset is in bytes
  22479. */
  22480. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  22481. /**
  22482. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  22483. */
  22484. dispose(): void;
  22485. /**
  22486. * Enumerates each value of this vertex buffer as numbers.
  22487. * @param count the number of values to enumerate
  22488. * @param callback the callback function called for each value
  22489. */
  22490. forEach(count: number, callback: (value: number, index: number) => void): void;
  22491. private static _PositionKind;
  22492. private static _NormalKind;
  22493. private static _TangentKind;
  22494. private static _UVKind;
  22495. private static _UV2Kind;
  22496. private static _UV3Kind;
  22497. private static _UV4Kind;
  22498. private static _UV5Kind;
  22499. private static _UV6Kind;
  22500. private static _ColorKind;
  22501. private static _MatricesIndicesKind;
  22502. private static _MatricesWeightsKind;
  22503. private static _MatricesIndicesExtraKind;
  22504. private static _MatricesWeightsExtraKind;
  22505. static readonly PositionKind: string;
  22506. static readonly NormalKind: string;
  22507. static readonly TangentKind: string;
  22508. static readonly UVKind: string;
  22509. static readonly UV2Kind: string;
  22510. static readonly UV3Kind: string;
  22511. static readonly UV4Kind: string;
  22512. static readonly UV5Kind: string;
  22513. static readonly UV6Kind: string;
  22514. static readonly ColorKind: string;
  22515. static readonly MatricesIndicesKind: string;
  22516. static readonly MatricesWeightsKind: string;
  22517. static readonly MatricesIndicesExtraKind: string;
  22518. static readonly MatricesWeightsExtraKind: string;
  22519. /**
  22520. * Deduces the stride given a kind.
  22521. * @param kind The kind string to deduce
  22522. * @returns The deduced stride
  22523. */
  22524. static DeduceStride(kind: string): number;
  22525. /**
  22526. * Gets the byte length of the given type.
  22527. * @param type the type
  22528. * @returns the number of bytes
  22529. */
  22530. static GetTypeByteLength(type: number): number;
  22531. /**
  22532. * Enumerates each value of the given parameters as numbers.
  22533. * @param data the data to enumerate
  22534. * @param byteOffset the byte offset of the data
  22535. * @param byteStride the byte stride of the data
  22536. * @param componentCount the number of components per element
  22537. * @param componentType the type of the component
  22538. * @param count the total number of components
  22539. * @param normalized whether the data is normalized
  22540. * @param callback the callback function called for each value
  22541. */
  22542. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  22543. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  22544. }
  22545. }
  22546. declare module BABYLON {
  22547. /**
  22548. * This represents a GPU particle system in Babylon
  22549. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  22550. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  22551. */
  22552. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  22553. /**
  22554. * The id of the Particle system.
  22555. */
  22556. id: string;
  22557. /**
  22558. * The friendly name of the Particle system.
  22559. */
  22560. name: string;
  22561. /**
  22562. * The emitter represents the Mesh or position we are attaching the particle system to.
  22563. */
  22564. emitter: Nullable<AbstractMesh | Vector3>;
  22565. /**
  22566. * The rendering group used by the Particle system to chose when to render.
  22567. */
  22568. renderingGroupId: number;
  22569. /**
  22570. * The layer mask we are rendering the particles through.
  22571. */
  22572. layerMask: number;
  22573. private _capacity;
  22574. private _activeCount;
  22575. private _currentActiveCount;
  22576. private _renderEffect;
  22577. private _updateEffect;
  22578. private _buffer0;
  22579. private _buffer1;
  22580. private _spriteBuffer;
  22581. private _updateVAO;
  22582. private _renderVAO;
  22583. private _targetIndex;
  22584. private _sourceBuffer;
  22585. private _targetBuffer;
  22586. private _scene;
  22587. private _engine;
  22588. private _currentRenderId;
  22589. private _started;
  22590. private _stopped;
  22591. private _timeDelta;
  22592. private _randomTexture;
  22593. private readonly _attributesStrideSize;
  22594. private _updateEffectOptions;
  22595. private _randomTextureSize;
  22596. private _actualFrame;
  22597. /**
  22598. * List of animations used by the particle system.
  22599. */
  22600. animations: Animation[];
  22601. /**
  22602. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  22603. */
  22604. static readonly IsSupported: boolean;
  22605. /**
  22606. * An event triggered when the system is disposed.
  22607. */
  22608. onDisposeObservable: Observable<GPUParticleSystem>;
  22609. /**
  22610. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  22611. */
  22612. updateSpeed: number;
  22613. /**
  22614. * The amount of time the particle system is running (depends of the overall update speed).
  22615. */
  22616. targetStopDuration: number;
  22617. /**
  22618. * The texture used to render each particle. (this can be a spritesheet)
  22619. */
  22620. particleTexture: Nullable<Texture>;
  22621. /**
  22622. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  22623. */
  22624. blendMode: number;
  22625. /**
  22626. * Minimum life time of emitting particles.
  22627. */
  22628. minLifeTime: number;
  22629. /**
  22630. * Maximum life time of emitting particles.
  22631. */
  22632. maxLifeTime: number;
  22633. /**
  22634. * Minimum Size of emitting particles.
  22635. */
  22636. minSize: number;
  22637. /**
  22638. * Maximum Size of emitting particles.
  22639. */
  22640. maxSize: number;
  22641. /**
  22642. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  22643. */
  22644. color1: Color4;
  22645. /**
  22646. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  22647. */
  22648. color2: Color4;
  22649. /**
  22650. * Color the particle will have at the end of its lifetime.
  22651. */
  22652. colorDead: Color4;
  22653. /**
  22654. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  22655. */
  22656. emitRate: number;
  22657. /**
  22658. * You can use gravity if you want to give an orientation to your particles.
  22659. */
  22660. gravity: Vector3;
  22661. /**
  22662. * Minimum power of emitting particles.
  22663. */
  22664. minEmitPower: number;
  22665. /**
  22666. * Maximum power of emitting particles.
  22667. */
  22668. maxEmitPower: number;
  22669. /**
  22670. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  22671. */
  22672. minAngularSpeed: number;
  22673. /**
  22674. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  22675. */
  22676. maxAngularSpeed: number;
  22677. /**
  22678. * The particle emitter type defines the emitter used by the particle system.
  22679. * It can be for example box, sphere, or cone...
  22680. */
  22681. particleEmitterType: Nullable<IParticleEmitterType>;
  22682. /**
  22683. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  22684. * This only works when particleEmitterTyps is a BoxParticleEmitter
  22685. */
  22686. direction1: Vector3;
  22687. /**
  22688. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  22689. * This only works when particleEmitterTyps is a BoxParticleEmitter
  22690. */
  22691. direction2: Vector3;
  22692. /**
  22693. * 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.
  22694. * This only works when particleEmitterTyps is a BoxParticleEmitter
  22695. */
  22696. minEmitBox: Vector3;
  22697. /**
  22698. * 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.
  22699. * This only works when particleEmitterTyps is a BoxParticleEmitter
  22700. */
  22701. maxEmitBox: Vector3;
  22702. /**
  22703. * Gets the maximum number of particles active at the same time.
  22704. * @returns The max number of active particles.
  22705. */
  22706. getCapacity(): number;
  22707. /**
  22708. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  22709. * to override the particles.
  22710. */
  22711. forceDepthWrite: boolean;
  22712. /**
  22713. * Gets or set the number of active particles
  22714. */
  22715. activeParticleCount: number;
  22716. /**
  22717. * Is this system ready to be used/rendered
  22718. * @return true if the system is ready
  22719. */
  22720. isReady(): boolean;
  22721. /**
  22722. * Gets Wether the system has been started.
  22723. * @returns True if it has been started, otherwise false.
  22724. */
  22725. isStarted(): boolean;
  22726. /**
  22727. * Starts the particle system and begins to emit.
  22728. */
  22729. start(): void;
  22730. /**
  22731. * Stops the particle system.
  22732. */
  22733. stop(): void;
  22734. /**
  22735. * Remove all active particles
  22736. */
  22737. reset(): void;
  22738. /**
  22739. * Returns the string "GPUParticleSystem"
  22740. * @returns a string containing the class name
  22741. */
  22742. getClassName(): string;
  22743. /**
  22744. * Instantiates a GPU particle system.
  22745. * 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.
  22746. * @param name The name of the particle system
  22747. * @param capacity The max number of particles alive at the same time
  22748. * @param scene The scene the particle system belongs to
  22749. */
  22750. constructor(name: string, options: Partial<{
  22751. capacity: number;
  22752. randomTextureSize: number;
  22753. }>, scene: Scene);
  22754. private _createUpdateVAO(source);
  22755. private _createRenderVAO(source, spriteSource);
  22756. private _initialize(force?);
  22757. /** @hidden */
  22758. _recreateUpdateEffect(): void;
  22759. /** @hidden */
  22760. _recreateRenderEffect(): void;
  22761. /**
  22762. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  22763. */
  22764. animate(): void;
  22765. /**
  22766. * Renders the particle system in its current state.
  22767. * @returns the current number of particles
  22768. */
  22769. render(): number;
  22770. /**
  22771. * Rebuilds the particle system
  22772. */
  22773. rebuild(): void;
  22774. private _releaseBuffers();
  22775. private _releaseVAOs();
  22776. /**
  22777. * Disposes the particle system and free the associated resources
  22778. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  22779. */
  22780. dispose(disposeTexture?: boolean): void;
  22781. /**
  22782. * Clones the particle system.
  22783. * @param name The name of the cloned object
  22784. * @param newEmitter The new emitter to use
  22785. * @returns the cloned particle system
  22786. */
  22787. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  22788. /**
  22789. * Serializes the particle system to a JSON object.
  22790. * @returns the JSON object
  22791. */
  22792. serialize(): any;
  22793. /**
  22794. * Parses a JSON object to create a GPU particle system.
  22795. * @param parsedParticleSystem The JSON object to parse
  22796. * @param scene The scene to create the particle system in
  22797. * @param rootUrl The root url to use to load external dependencies like texture
  22798. * @returns the parsed GPU particle system
  22799. */
  22800. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  22801. }
  22802. }
  22803. declare module BABYLON {
  22804. /**
  22805. * Interface representing a particle system in Babylon.
  22806. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  22807. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  22808. */
  22809. interface IParticleSystem {
  22810. /**
  22811. * The id of the Particle system.
  22812. */
  22813. id: string;
  22814. /**
  22815. * The name of the Particle system.
  22816. */
  22817. name: string;
  22818. /**
  22819. * The emitter represents the Mesh or position we are attaching the particle system to.
  22820. */
  22821. emitter: Nullable<AbstractMesh | Vector3>;
  22822. /**
  22823. * The rendering group used by the Particle system to chose when to render.
  22824. */
  22825. renderingGroupId: number;
  22826. /**
  22827. * The layer mask we are rendering the particles through.
  22828. */
  22829. layerMask: number;
  22830. /**
  22831. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  22832. */
  22833. updateSpeed: number;
  22834. /**
  22835. * The amount of time the particle system is running (depends of the overall update speed).
  22836. */
  22837. targetStopDuration: number;
  22838. /**
  22839. * The texture used to render each particle. (this can be a spritesheet)
  22840. */
  22841. particleTexture: Nullable<Texture>;
  22842. /**
  22843. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  22844. */
  22845. blendMode: number;
  22846. /**
  22847. * Minimum life time of emitting particles.
  22848. */
  22849. minLifeTime: number;
  22850. /**
  22851. * Maximum life time of emitting particles.
  22852. */
  22853. maxLifeTime: number;
  22854. /**
  22855. * Minimum Size of emitting particles.
  22856. */
  22857. minSize: number;
  22858. /**
  22859. * Maximum Size of emitting particles.
  22860. */
  22861. maxSize: number;
  22862. /**
  22863. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  22864. */
  22865. color1: Color4;
  22866. /**
  22867. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  22868. */
  22869. color2: Color4;
  22870. /**
  22871. * Color the particle will have at the end of its lifetime.
  22872. */
  22873. colorDead: Color4;
  22874. /**
  22875. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  22876. */
  22877. emitRate: number;
  22878. /**
  22879. * You can use gravity if you want to give an orientation to your particles.
  22880. */
  22881. gravity: Vector3;
  22882. /**
  22883. * Minimum power of emitting particles.
  22884. */
  22885. minEmitPower: number;
  22886. /**
  22887. * Maximum power of emitting particles.
  22888. */
  22889. maxEmitPower: number;
  22890. /**
  22891. * The particle emitter type defines the emitter used by the particle system.
  22892. * It can be for example box, sphere, or cone...
  22893. */
  22894. particleEmitterType: Nullable<IParticleEmitterType>;
  22895. /**
  22896. * Gets the maximum number of particles active at the same time.
  22897. * @returns The max number of active particles.
  22898. */
  22899. getCapacity(): number;
  22900. /**
  22901. * Gets Wether the system has been started.
  22902. * @returns True if it has been started, otherwise false.
  22903. */
  22904. isStarted(): boolean;
  22905. /**
  22906. * Gets if the particle system has been started.
  22907. * @return true if the system has been started, otherwise false.
  22908. */
  22909. isStarted(): boolean;
  22910. /**
  22911. * Animates the particle system for this frame.
  22912. */
  22913. animate(): void;
  22914. /**
  22915. * Renders the particle system in its current state.
  22916. * @returns the current number of particles
  22917. */
  22918. render(): number;
  22919. /**
  22920. * Dispose the particle system and frees its associated resources.
  22921. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  22922. */
  22923. dispose(disposeTexture?: boolean): void;
  22924. /**
  22925. * Clones the particle system.
  22926. * @param name The name of the cloned object
  22927. * @param newEmitter The new emitter to use
  22928. * @returns the cloned particle system
  22929. */
  22930. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  22931. /**
  22932. * Serializes the particle system to a JSON object.
  22933. * @returns the JSON object
  22934. */
  22935. serialize(): any;
  22936. /**
  22937. * Rebuild the particle system
  22938. */
  22939. rebuild(): void;
  22940. /**
  22941. * Starts the particle system and begins to emit.
  22942. */
  22943. start(): void;
  22944. /**
  22945. * Stops the particle system.
  22946. */
  22947. stop(): void;
  22948. /**
  22949. * Remove all active particles
  22950. */
  22951. reset(): void;
  22952. /**
  22953. * Is this system ready to be used/rendered
  22954. * @return true if the system is ready
  22955. */
  22956. isReady(): boolean;
  22957. }
  22958. }
  22959. declare module BABYLON {
  22960. /**
  22961. * A particle represents one of the element emitted by a particle system.
  22962. * This is mainly define by its coordinates, direction, velocity and age.
  22963. */
  22964. class Particle {
  22965. /**
  22966. * particleSystem the particle system the particle belongs to.
  22967. */
  22968. particleSystem: ParticleSystem;
  22969. /**
  22970. * The world position of the particle in the scene.
  22971. */
  22972. position: Vector3;
  22973. /**
  22974. * The world direction of the particle in the scene.
  22975. */
  22976. direction: Vector3;
  22977. /**
  22978. * The color of the particle.
  22979. */
  22980. color: Color4;
  22981. /**
  22982. * The color change of the particle per step.
  22983. */
  22984. colorStep: Color4;
  22985. /**
  22986. * Defines how long will the life of the particle be.
  22987. */
  22988. lifeTime: number;
  22989. /**
  22990. * The current age of the particle.
  22991. */
  22992. age: number;
  22993. /**
  22994. * The current size of the particle.
  22995. */
  22996. size: number;
  22997. /**
  22998. * The current angle of the particle.
  22999. */
  23000. angle: number;
  23001. /**
  23002. * Defines how fast is the angle changing.
  23003. */
  23004. angularSpeed: number;
  23005. /**
  23006. * Defines the cell index used by the particle to be rendered from a sprite.
  23007. */
  23008. cellIndex: number;
  23009. private _currentFrameCounter;
  23010. /**
  23011. * Creates a new instance Particle
  23012. * @param particleSystem the particle system the particle belongs to
  23013. */
  23014. constructor(
  23015. /**
  23016. * particleSystem the particle system the particle belongs to.
  23017. */
  23018. particleSystem: ParticleSystem);
  23019. private updateCellInfoFromSystem();
  23020. /**
  23021. * Defines how the sprite cell index is updated for the particle. This is
  23022. * defined as a callback.
  23023. */
  23024. updateCellIndex: (scaledUpdateSpeed: number) => void;
  23025. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  23026. private _updateCellIndexWithCustomSpeed();
  23027. /**
  23028. * Copy the properties of particle to another one.
  23029. * @param other the particle to copy the information to.
  23030. */
  23031. copyTo(other: Particle): void;
  23032. }
  23033. }
  23034. declare module BABYLON {
  23035. /**
  23036. * This represents a particle system in Babylon.
  23037. * 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.
  23038. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  23039. * @example https://doc.babylonjs.com/babylon101/particles
  23040. */
  23041. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  23042. /**
  23043. * Source color is added to the destination color without alpha affecting the result.
  23044. */
  23045. static BLENDMODE_ONEONE: number;
  23046. /**
  23047. * Blend current color and particle color using particle’s alpha.
  23048. */
  23049. static BLENDMODE_STANDARD: number;
  23050. /**
  23051. * List of animations used by the particle system.
  23052. */
  23053. animations: Animation[];
  23054. /**
  23055. * The id of the Particle system.
  23056. */
  23057. id: string;
  23058. /**
  23059. * The friendly name of the Particle system.
  23060. */
  23061. name: string;
  23062. /**
  23063. * The rendering group used by the Particle system to chose when to render.
  23064. */
  23065. renderingGroupId: number;
  23066. /**
  23067. * The emitter represents the Mesh or position we are attaching the particle system to.
  23068. */
  23069. emitter: Nullable<AbstractMesh | Vector3>;
  23070. /**
  23071. * The maximum number of particles to emit per frame
  23072. */
  23073. emitRate: number;
  23074. /**
  23075. * If you want to launch only a few particles at once, that can be done, as well.
  23076. */
  23077. manualEmitCount: number;
  23078. /**
  23079. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  23080. */
  23081. updateSpeed: number;
  23082. /**
  23083. * The amount of time the particle system is running (depends of the overall update speed).
  23084. */
  23085. targetStopDuration: number;
  23086. /**
  23087. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  23088. */
  23089. disposeOnStop: boolean;
  23090. /**
  23091. * Minimum power of emitting particles.
  23092. */
  23093. minEmitPower: number;
  23094. /**
  23095. * Maximum power of emitting particles.
  23096. */
  23097. maxEmitPower: number;
  23098. /**
  23099. * Minimum life time of emitting particles.
  23100. */
  23101. minLifeTime: number;
  23102. /**
  23103. * Maximum life time of emitting particles.
  23104. */
  23105. maxLifeTime: number;
  23106. /**
  23107. * Minimum Size of emitting particles.
  23108. */
  23109. minSize: number;
  23110. /**
  23111. * Maximum Size of emitting particles.
  23112. */
  23113. maxSize: number;
  23114. /**
  23115. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  23116. */
  23117. minAngularSpeed: number;
  23118. /**
  23119. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  23120. */
  23121. maxAngularSpeed: number;
  23122. /**
  23123. * The texture used to render each particle. (this can be a spritesheet)
  23124. */
  23125. particleTexture: Nullable<Texture>;
  23126. /**
  23127. * The layer mask we are rendering the particles through.
  23128. */
  23129. layerMask: number;
  23130. /**
  23131. * This can help using your own shader to render the particle system.
  23132. * The according effect will be created
  23133. */
  23134. customShader: any;
  23135. /**
  23136. * By default particle system starts as soon as they are created. This prevents the
  23137. * automatic start to happen and let you decide when to start emitting particles.
  23138. */
  23139. preventAutoStart: boolean;
  23140. /**
  23141. * This function can be defined to provide custom update for active particles.
  23142. * This function will be called instead of regular update (age, position, color, etc.).
  23143. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  23144. */
  23145. updateFunction: (particles: Particle[]) => void;
  23146. /**
  23147. * Callback triggered when the particle animation is ending.
  23148. */
  23149. onAnimationEnd: Nullable<() => void>;
  23150. /**
  23151. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  23152. */
  23153. blendMode: number;
  23154. /**
  23155. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  23156. * to override the particles.
  23157. */
  23158. forceDepthWrite: boolean;
  23159. /**
  23160. * You can use gravity if you want to give an orientation to your particles.
  23161. */
  23162. gravity: Vector3;
  23163. /**
  23164. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23165. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23166. */
  23167. direction1: Vector3;
  23168. /**
  23169. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23170. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23171. */
  23172. direction2: Vector3;
  23173. /**
  23174. * 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.
  23175. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23176. */
  23177. minEmitBox: Vector3;
  23178. /**
  23179. * 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.
  23180. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23181. */
  23182. maxEmitBox: Vector3;
  23183. /**
  23184. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23185. */
  23186. color1: Color4;
  23187. /**
  23188. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23189. */
  23190. color2: Color4;
  23191. /**
  23192. * Color the particle will have at the end of its lifetime.
  23193. */
  23194. colorDead: Color4;
  23195. /**
  23196. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  23197. */
  23198. textureMask: Color4;
  23199. /**
  23200. * The particle emitter type defines the emitter used by the particle system.
  23201. * It can be for example box, sphere, or cone...
  23202. */
  23203. particleEmitterType: IParticleEmitterType;
  23204. /**
  23205. * This function can be defined to specify initial direction for every new particle.
  23206. * It by default use the emitterType defined function.
  23207. */
  23208. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  23209. /**
  23210. * This function can be defined to specify initial position for every new particle.
  23211. * It by default use the emitterType defined function.
  23212. */
  23213. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  23214. /**
  23215. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  23216. */
  23217. spriteCellLoop: boolean;
  23218. /**
  23219. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  23220. */
  23221. spriteCellChangeSpeed: number;
  23222. /**
  23223. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  23224. */
  23225. startSpriteCellID: number;
  23226. /**
  23227. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  23228. */
  23229. endSpriteCellID: number;
  23230. /**
  23231. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  23232. */
  23233. spriteCellWidth: number;
  23234. /**
  23235. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  23236. */
  23237. spriteCellHeight: number;
  23238. /**
  23239. * An event triggered when the system is disposed.
  23240. */
  23241. onDisposeObservable: Observable<ParticleSystem>;
  23242. private _onDisposeObserver;
  23243. /**
  23244. * Sets a callback that will be triggered when the system is disposed.
  23245. */
  23246. onDispose: () => void;
  23247. /**
  23248. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  23249. */
  23250. readonly isAnimationSheetEnabled: Boolean;
  23251. private _particles;
  23252. private _epsilon;
  23253. private _capacity;
  23254. private _scene;
  23255. private _stockParticles;
  23256. private _newPartsExcess;
  23257. private _vertexData;
  23258. private _vertexBuffer;
  23259. private _vertexBuffers;
  23260. private _indexBuffer;
  23261. private _effect;
  23262. private _customEffect;
  23263. private _cachedDefines;
  23264. private _scaledColorStep;
  23265. private _colorDiff;
  23266. private _scaledDirection;
  23267. private _scaledGravity;
  23268. private _currentRenderId;
  23269. private _alive;
  23270. private _started;
  23271. private _stopped;
  23272. private _actualFrame;
  23273. private _scaledUpdateSpeed;
  23274. private _vertexBufferSize;
  23275. private _isAnimationSheetEnabled;
  23276. /**
  23277. * 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.
  23278. */
  23279. subEmitters: ParticleSystem[];
  23280. /**
  23281. * The current active Sub-systems, this property is used by the root particle system only.
  23282. */
  23283. activeSubSystems: Array<ParticleSystem>;
  23284. private _rootParticleSystem;
  23285. /**
  23286. * Gets the current list of active particles
  23287. */
  23288. readonly particles: Particle[];
  23289. /**
  23290. * Returns the string "ParticleSystem"
  23291. * @returns a string containing the class name
  23292. */
  23293. getClassName(): string;
  23294. /**
  23295. * Instantiates a particle system.
  23296. * 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.
  23297. * @param name The name of the particle system
  23298. * @param capacity The max number of particles alive at the same time
  23299. * @param scene The scene the particle system belongs to
  23300. * @param customEffect a custom effect used to change the way particles are rendered by default
  23301. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  23302. * @param epsilon Offset used to render the particles
  23303. */
  23304. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  23305. private _createIndexBuffer();
  23306. /**
  23307. * Gets the maximum number of particles active at the same time.
  23308. * @returns The max number of active particles.
  23309. */
  23310. getCapacity(): number;
  23311. /**
  23312. * Gets Wether there are still active particles in the system.
  23313. * @returns True if it is alive, otherwise false.
  23314. */
  23315. isAlive(): boolean;
  23316. /**
  23317. * Gets Wether the system has been started.
  23318. * @returns True if it has been started, otherwise false.
  23319. */
  23320. isStarted(): boolean;
  23321. /**
  23322. * Starts the particle system and begins to emit.
  23323. */
  23324. start(): void;
  23325. /**
  23326. * Stops the particle system.
  23327. * @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.
  23328. */
  23329. stop(stopSubEmitters?: boolean): void;
  23330. /**
  23331. * Remove all active particles
  23332. */
  23333. reset(): void;
  23334. /**
  23335. * @hidden (for internal use only)
  23336. */
  23337. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  23338. /**
  23339. * @hidden (for internal use only)
  23340. */
  23341. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  23342. /**
  23343. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  23344. * Its lifetime will start back at 0.
  23345. */
  23346. recycleParticle: (particle: Particle) => void;
  23347. private _stopSubEmitters();
  23348. private _createParticle;
  23349. private _removeFromRoot();
  23350. private _emitFromParticle;
  23351. private _update(newParticles);
  23352. private _getEffect();
  23353. /**
  23354. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  23355. */
  23356. animate(): void;
  23357. private _appendParticleVertexes;
  23358. private _appenedParticleVertexesWithSheet(offset, particle);
  23359. private _appenedParticleVertexesNoSheet(offset, particle);
  23360. /**
  23361. * Rebuilds the particle system.
  23362. */
  23363. rebuild(): void;
  23364. /**
  23365. * Is this system ready to be used/rendered
  23366. * @return true if the system is ready
  23367. */
  23368. isReady(): boolean;
  23369. /**
  23370. * Renders the particle system in its current state.
  23371. * @returns the current number of particles
  23372. */
  23373. render(): number;
  23374. /**
  23375. * Disposes the particle system and free the associated resources
  23376. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  23377. */
  23378. dispose(disposeTexture?: boolean): void;
  23379. /**
  23380. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  23381. * @param radius The radius of the sphere to emit from
  23382. * @returns the emitter
  23383. */
  23384. createSphereEmitter(radius?: number): SphereParticleEmitter;
  23385. /**
  23386. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  23387. * @param radius The radius of the sphere to emit from
  23388. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  23389. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  23390. * @returns the emitter
  23391. */
  23392. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  23393. /**
  23394. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  23395. * @param radius The radius of the cone to emit from
  23396. * @param angle The base angle of the cone
  23397. * @returns the emitter
  23398. */
  23399. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  23400. /**
  23401. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  23402. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  23403. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  23404. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  23405. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  23406. * @returns the emitter
  23407. */
  23408. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  23409. /**
  23410. * Clones the particle system.
  23411. * @param name The name of the cloned object
  23412. * @param newEmitter The new emitter to use
  23413. * @returns the cloned particle system
  23414. */
  23415. clone(name: string, newEmitter: any): ParticleSystem;
  23416. /**
  23417. * Serializes the particle system to a JSON object.
  23418. * @returns the JSON object
  23419. */
  23420. serialize(): any;
  23421. /**
  23422. * Parses a JSON object to create a particle system.
  23423. * @param parsedParticleSystem The JSON object to parse
  23424. * @param scene The scene to create the particle system in
  23425. * @param rootUrl The root url to use to load external dependencies like texture
  23426. * @returns the Parsed particle system
  23427. */
  23428. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  23429. }
  23430. }
  23431. declare module BABYLON {
  23432. /**
  23433. * Represents one particle of a solid particle system.
  23434. */
  23435. class SolidParticle {
  23436. /**
  23437. * particle global index
  23438. */
  23439. idx: number;
  23440. /**
  23441. * The color of the particle
  23442. */
  23443. color: Nullable<Color4>;
  23444. /**
  23445. * The world space position of the particle.
  23446. */
  23447. position: Vector3;
  23448. /**
  23449. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23450. */
  23451. rotation: Vector3;
  23452. /**
  23453. * The world space rotation quaternion of the particle.
  23454. */
  23455. rotationQuaternion: Nullable<Quaternion>;
  23456. /**
  23457. * The scaling of the particle.
  23458. */
  23459. scaling: Vector3;
  23460. /**
  23461. * The uvs of the particle.
  23462. */
  23463. uvs: Vector4;
  23464. /**
  23465. * The current speed of the particle.
  23466. */
  23467. velocity: Vector3;
  23468. /**
  23469. * The pivot point in the particle local space.
  23470. */
  23471. pivot: Vector3;
  23472. /**
  23473. * Must the particle be translated from its pivot point in its local space ?
  23474. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23475. * Default : false
  23476. */
  23477. translateFromPivot: boolean;
  23478. /**
  23479. * Is the particle active or not ?
  23480. */
  23481. alive: boolean;
  23482. /**
  23483. * Is the particle visible or not ?
  23484. */
  23485. isVisible: boolean;
  23486. /**
  23487. * Index of this particle in the global "positions" array (Internal use)
  23488. */
  23489. _pos: number;
  23490. /**
  23491. * Index of this particle in the global "indices" array (Internal use)
  23492. */
  23493. _ind: number;
  23494. /**
  23495. * ModelShape of this particle (Internal use)
  23496. */
  23497. _model: ModelShape;
  23498. /**
  23499. * ModelShape id of this particle
  23500. */
  23501. shapeId: number;
  23502. /**
  23503. * Index of the particle in its shape id (Internal use)
  23504. */
  23505. idxInShape: number;
  23506. /**
  23507. * Reference to the shape model BoundingInfo object (Internal use)
  23508. */
  23509. _modelBoundingInfo: BoundingInfo;
  23510. /**
  23511. * Particle BoundingInfo object (Internal use)
  23512. */
  23513. _boundingInfo: BoundingInfo;
  23514. /**
  23515. * Reference to the SPS what the particle belongs to (Internal use)
  23516. */
  23517. _sps: SolidParticleSystem;
  23518. /**
  23519. * Still set as invisible in order to skip useless computations (Internal use)
  23520. */
  23521. _stillInvisible: boolean;
  23522. /**
  23523. * Last computed particle rotation matrix
  23524. */
  23525. _rotationMatrix: number[];
  23526. /**
  23527. * Parent particle Id, if any.
  23528. * Default null.
  23529. */
  23530. parentId: Nullable<number>;
  23531. /**
  23532. * Internal global position in the SPS.
  23533. */
  23534. _globalPosition: Vector3;
  23535. /**
  23536. * Creates a Solid Particle object.
  23537. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23538. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23539. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23540. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23541. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23542. * @param shapeId (integer) is the model shape identifier in the SPS.
  23543. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23544. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23545. */
  23546. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23547. /**
  23548. * Legacy support, changed scale to scaling
  23549. */
  23550. /**
  23551. * Legacy support, changed scale to scaling
  23552. */
  23553. scale: Vector3;
  23554. /**
  23555. * Legacy support, changed quaternion to rotationQuaternion
  23556. */
  23557. /**
  23558. * Legacy support, changed quaternion to rotationQuaternion
  23559. */
  23560. quaternion: Nullable<Quaternion>;
  23561. /**
  23562. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23563. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23564. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23565. * @returns true if it intersects
  23566. */
  23567. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23568. }
  23569. /**
  23570. * Represents the shape of the model used by one particle of a solid particle system.
  23571. * SPS internal tool, don't use it manually.
  23572. */
  23573. class ModelShape {
  23574. /**
  23575. * The shape id.
  23576. */
  23577. shapeID: number;
  23578. /**
  23579. * flat array of model positions (internal use)
  23580. */
  23581. _shape: Vector3[];
  23582. /**
  23583. * flat array of model UVs (internal use)
  23584. */
  23585. _shapeUV: number[];
  23586. /**
  23587. * length of the shape in the model indices array (internal use)
  23588. */
  23589. _indicesLength: number;
  23590. /**
  23591. * Custom position function (internal use)
  23592. */
  23593. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23594. /**
  23595. * Custom vertex function (internal use)
  23596. */
  23597. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23598. /**
  23599. * 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.
  23600. * SPS internal tool, don't use it manually.
  23601. * @hidden
  23602. */
  23603. 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>);
  23604. }
  23605. /**
  23606. * Represents a Depth Sorted Particle in the solid particle system.
  23607. */
  23608. class DepthSortedParticle {
  23609. /**
  23610. * Index of the particle in the "indices" array
  23611. */
  23612. ind: number;
  23613. /**
  23614. * Length of the particle shape in the "indices" array
  23615. */
  23616. indicesLength: number;
  23617. /**
  23618. * Squared distance from the particle to the camera
  23619. */
  23620. sqDistance: number;
  23621. }
  23622. }
  23623. declare module BABYLON {
  23624. /**
  23625. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23626. *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.
  23627. * The SPS is also a particle system. It provides some methods to manage the particles.
  23628. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23629. *
  23630. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23631. */
  23632. class SolidParticleSystem implements IDisposable {
  23633. /**
  23634. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23635. * Example : var p = SPS.particles[i];
  23636. */
  23637. particles: SolidParticle[];
  23638. /**
  23639. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23640. */
  23641. nbParticles: number;
  23642. /**
  23643. * If the particles must ever face the camera (default false). Useful for planar particles.
  23644. */
  23645. billboard: boolean;
  23646. /**
  23647. * Recompute normals when adding a shape
  23648. */
  23649. recomputeNormals: boolean;
  23650. /**
  23651. * This a counter ofr your own usage. It's not set by any SPS functions.
  23652. */
  23653. counter: number;
  23654. /**
  23655. * The SPS name. This name is also given to the underlying mesh.
  23656. */
  23657. name: string;
  23658. /**
  23659. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23660. */
  23661. mesh: Mesh;
  23662. /**
  23663. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23664. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23665. */
  23666. vars: any;
  23667. /**
  23668. * This array is populated when the SPS is set as 'pickable'.
  23669. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23670. * Each element of this array is an object `{idx: int, faceId: int}`.
  23671. * `idx` is the picked particle index in the `SPS.particles` array
  23672. * `faceId` is the picked face index counted within this particle.
  23673. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23674. */
  23675. pickedParticles: {
  23676. idx: number;
  23677. faceId: number;
  23678. }[];
  23679. /**
  23680. * This array is populated when `enableDepthSort` is set to true.
  23681. * Each element of this array is an instance of the class DepthSortedParticle.
  23682. */
  23683. depthSortedParticles: DepthSortedParticle[];
  23684. /**
  23685. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23686. */
  23687. _bSphereOnly: boolean;
  23688. /**
  23689. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23690. */
  23691. _bSphereRadiusFactor: number;
  23692. private _scene;
  23693. private _positions;
  23694. private _indices;
  23695. private _normals;
  23696. private _colors;
  23697. private _uvs;
  23698. private _indices32;
  23699. private _positions32;
  23700. private _normals32;
  23701. private _fixedNormal32;
  23702. private _colors32;
  23703. private _uvs32;
  23704. private _index;
  23705. private _updatable;
  23706. private _pickable;
  23707. private _isVisibilityBoxLocked;
  23708. private _alwaysVisible;
  23709. private _depthSort;
  23710. private _shapeCounter;
  23711. private _copy;
  23712. private _shape;
  23713. private _shapeUV;
  23714. private _color;
  23715. private _computeParticleColor;
  23716. private _computeParticleTexture;
  23717. private _computeParticleRotation;
  23718. private _computeParticleVertex;
  23719. private _computeBoundingBox;
  23720. private _depthSortParticles;
  23721. private _cam_axisZ;
  23722. private _cam_axisY;
  23723. private _cam_axisX;
  23724. private _axisZ;
  23725. private _camera;
  23726. private _particle;
  23727. private _camDir;
  23728. private _camInvertedPosition;
  23729. private _rotMatrix;
  23730. private _invertMatrix;
  23731. private _rotated;
  23732. private _quaternion;
  23733. private _vertex;
  23734. private _normal;
  23735. private _yaw;
  23736. private _pitch;
  23737. private _roll;
  23738. private _halfroll;
  23739. private _halfpitch;
  23740. private _halfyaw;
  23741. private _sinRoll;
  23742. private _cosRoll;
  23743. private _sinPitch;
  23744. private _cosPitch;
  23745. private _sinYaw;
  23746. private _cosYaw;
  23747. private _mustUnrotateFixedNormals;
  23748. private _minimum;
  23749. private _maximum;
  23750. private _minBbox;
  23751. private _maxBbox;
  23752. private _particlesIntersect;
  23753. private _depthSortFunction;
  23754. private _needs32Bits;
  23755. private _pivotBackTranslation;
  23756. private _scaledPivot;
  23757. private _particleHasParent;
  23758. private _parent;
  23759. /**
  23760. * Creates a SPS (Solid Particle System) object.
  23761. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23762. * @param scene (Scene) is the scene in which the SPS is added.
  23763. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23764. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23765. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23766. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23767. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23768. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23769. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23770. */
  23771. constructor(name: string, scene: Scene, options?: {
  23772. updatable?: boolean;
  23773. isPickable?: boolean;
  23774. enableDepthSort?: boolean;
  23775. particleIntersection?: boolean;
  23776. boundingSphereOnly?: boolean;
  23777. bSphereRadiusFactor?: number;
  23778. });
  23779. /**
  23780. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23781. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23782. * @returns the created mesh
  23783. */
  23784. buildMesh(): Mesh;
  23785. /**
  23786. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23787. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23788. * Thus the particles generated from `digest()` have their property `position` set yet.
  23789. * @param mesh ( Mesh ) is the mesh to be digested
  23790. * @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
  23791. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23792. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23793. * @returns the current SPS
  23794. */
  23795. digest(mesh: Mesh, options?: {
  23796. facetNb?: number;
  23797. number?: number;
  23798. delta?: number;
  23799. }): SolidParticleSystem;
  23800. private _unrotateFixedNormals();
  23801. private _resetCopy();
  23802. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  23803. private _posToShape(positions);
  23804. private _uvsToShapeUV(uvs);
  23805. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  23806. /**
  23807. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23808. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23809. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23810. * @param nb (positive integer) the number of particles to be created from this model
  23811. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23812. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23813. * @returns the number of shapes in the system
  23814. */
  23815. addShape(mesh: Mesh, nb: number, options?: {
  23816. positionFunction?: any;
  23817. vertexFunction?: any;
  23818. }): number;
  23819. private _rebuildParticle(particle);
  23820. /**
  23821. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23822. * @returns the SPS.
  23823. */
  23824. rebuildMesh(): SolidParticleSystem;
  23825. /**
  23826. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23827. * This method calls `updateParticle()` for each particle of the SPS.
  23828. * For an animated SPS, it is usually called within the render loop.
  23829. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23830. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23831. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23832. * @returns the SPS.
  23833. */
  23834. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23835. private _quaternionRotationYPR();
  23836. private _quaternionToRotationMatrix();
  23837. /**
  23838. * Disposes the SPS.
  23839. */
  23840. dispose(): void;
  23841. /**
  23842. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23843. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23844. * @returns the SPS.
  23845. */
  23846. refreshVisibleSize(): SolidParticleSystem;
  23847. /**
  23848. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23849. * @param size the size (float) of the visibility box
  23850. * note : this doesn't lock the SPS mesh bounding box.
  23851. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23852. */
  23853. setVisibilityBox(size: number): void;
  23854. /**
  23855. * Gets whether the SPS as always visible or not
  23856. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23857. */
  23858. /**
  23859. * Sets the SPS as always visible or not
  23860. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23861. */
  23862. isAlwaysVisible: boolean;
  23863. /**
  23864. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23865. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23866. */
  23867. /**
  23868. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23869. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23870. */
  23871. isVisibilityBoxLocked: boolean;
  23872. /**
  23873. * Gets if `setParticles()` computes the particle rotations or not.
  23874. * Default value : true. The SPS is faster when it's set to false.
  23875. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23876. */
  23877. /**
  23878. * Tells to `setParticles()` to compute the particle rotations or not.
  23879. * Default value : true. The SPS is faster when it's set to false.
  23880. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23881. */
  23882. computeParticleRotation: boolean;
  23883. /**
  23884. * Gets if `setParticles()` computes the particle colors or not.
  23885. * Default value : true. The SPS is faster when it's set to false.
  23886. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23887. */
  23888. /**
  23889. * Tells to `setParticles()` to compute the particle colors or not.
  23890. * Default value : true. The SPS is faster when it's set to false.
  23891. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23892. */
  23893. computeParticleColor: boolean;
  23894. /**
  23895. * Gets if `setParticles()` computes the particle textures or not.
  23896. * Default value : true. The SPS is faster when it's set to false.
  23897. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23898. */
  23899. computeParticleTexture: boolean;
  23900. /**
  23901. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23902. * Default value : false. The SPS is faster when it's set to false.
  23903. * Note : the particle custom vertex positions aren't stored values.
  23904. */
  23905. /**
  23906. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23907. * Default value : false. The SPS is faster when it's set to false.
  23908. * Note : the particle custom vertex positions aren't stored values.
  23909. */
  23910. computeParticleVertex: boolean;
  23911. /**
  23912. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23913. */
  23914. /**
  23915. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23916. */
  23917. computeBoundingBox: boolean;
  23918. /**
  23919. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23920. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23921. * Default : `true`
  23922. */
  23923. /**
  23924. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23925. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23926. * Default : `true`
  23927. */
  23928. depthSortParticles: boolean;
  23929. /**
  23930. * This function does nothing. It may be overwritten to set all the particle first values.
  23931. * The SPS doesn't call this function, you may have to call it by your own.
  23932. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23933. */
  23934. initParticles(): void;
  23935. /**
  23936. * This function does nothing. It may be overwritten to recycle a particle.
  23937. * The SPS doesn't call this function, you may have to call it by your own.
  23938. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23939. * @param particle The particle to recycle
  23940. * @returns the recycled particle
  23941. */
  23942. recycleParticle(particle: SolidParticle): SolidParticle;
  23943. /**
  23944. * Updates a particle : this function should be overwritten by the user.
  23945. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23946. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23947. * @example : just set a particle position or velocity and recycle conditions
  23948. * @param particle The particle to update
  23949. * @returns the updated particle
  23950. */
  23951. updateParticle(particle: SolidParticle): SolidParticle;
  23952. /**
  23953. * Updates a vertex of a particle : it can be overwritten by the user.
  23954. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23955. * @param particle the current particle
  23956. * @param vertex the current index of the current particle
  23957. * @param pt the index of the current vertex in the particle shape
  23958. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23959. * @example : just set a vertex particle position
  23960. * @returns the updated vertex
  23961. */
  23962. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23963. /**
  23964. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23965. * This does nothing and may be overwritten by the user.
  23966. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23967. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23968. * @param update the boolean update value actually passed to setParticles()
  23969. */
  23970. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23971. /**
  23972. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23973. * This will be passed three parameters.
  23974. * This does nothing and may be overwritten by the user.
  23975. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23976. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23977. * @param update the boolean update value actually passed to setParticles()
  23978. */
  23979. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23980. }
  23981. }
  23982. declare module BABYLON {
  23983. /**
  23984. * Defines a target to use with MorphTargetManager
  23985. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23986. */
  23987. class MorphTarget implements IAnimatable {
  23988. /** defines the name of the target */
  23989. name: string;
  23990. /**
  23991. * Gets or sets the list of animations
  23992. */
  23993. animations: Animation[];
  23994. private _scene;
  23995. private _positions;
  23996. private _normals;
  23997. private _tangents;
  23998. private _influence;
  23999. /**
  24000. * Observable raised when the influence changes
  24001. */
  24002. onInfluenceChanged: Observable<boolean>;
  24003. /**
  24004. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  24005. */
  24006. influence: number;
  24007. private _animationPropertiesOverride;
  24008. /**
  24009. * Gets or sets the animation properties override
  24010. */
  24011. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24012. /**
  24013. * Creates a new MorphTarget
  24014. * @param name defines the name of the target
  24015. * @param influence defines the influence to use
  24016. */
  24017. constructor(
  24018. /** defines the name of the target */
  24019. name: string, influence?: number, scene?: Nullable<Scene>);
  24020. /**
  24021. * Gets a boolean defining if the target contains position data
  24022. */
  24023. readonly hasPositions: boolean;
  24024. /**
  24025. * Gets a boolean defining if the target contains normal data
  24026. */
  24027. readonly hasNormals: boolean;
  24028. /**
  24029. * Gets a boolean defining if the target contains tangent data
  24030. */
  24031. readonly hasTangents: boolean;
  24032. /**
  24033. * Affects position data to this target
  24034. * @param data defines the position data to use
  24035. */
  24036. setPositions(data: Nullable<FloatArray>): void;
  24037. /**
  24038. * Gets the position data stored in this target
  24039. * @returns a FloatArray containing the position data (or null if not present)
  24040. */
  24041. getPositions(): Nullable<FloatArray>;
  24042. /**
  24043. * Affects normal data to this target
  24044. * @param data defines the normal data to use
  24045. */
  24046. setNormals(data: Nullable<FloatArray>): void;
  24047. /**
  24048. * Gets the normal data stored in this target
  24049. * @returns a FloatArray containing the normal data (or null if not present)
  24050. */
  24051. getNormals(): Nullable<FloatArray>;
  24052. /**
  24053. * Affects tangent data to this target
  24054. * @param data defines the tangent data to use
  24055. */
  24056. setTangents(data: Nullable<FloatArray>): void;
  24057. /**
  24058. * Gets the tangent data stored in this target
  24059. * @returns a FloatArray containing the tangent data (or null if not present)
  24060. */
  24061. getTangents(): Nullable<FloatArray>;
  24062. /**
  24063. * Serializes the current target into a Serialization object
  24064. * @returns the serialized object
  24065. */
  24066. serialize(): any;
  24067. /**
  24068. * Creates a new target from serialized data
  24069. * @param serializationObject defines the serialized data to use
  24070. * @returns a new MorphTarget
  24071. */
  24072. static Parse(serializationObject: any): MorphTarget;
  24073. /**
  24074. * Creates a MorphTarget from mesh data
  24075. * @param mesh defines the source mesh
  24076. * @param name defines the name to use for the new target
  24077. * @param influence defines the influence to attach to the target
  24078. * @returns a new MorphTarget
  24079. */
  24080. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  24081. }
  24082. }
  24083. declare module BABYLON {
  24084. /**
  24085. * This class is used to deform meshes using morphing between different targets
  24086. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24087. */
  24088. class MorphTargetManager {
  24089. private _targets;
  24090. private _targetObservable;
  24091. private _activeTargets;
  24092. private _scene;
  24093. private _influences;
  24094. private _supportsNormals;
  24095. private _supportsTangents;
  24096. private _vertexCount;
  24097. private _uniqueId;
  24098. private _tempInfluences;
  24099. /**
  24100. * Creates a new MorphTargetManager
  24101. * @param scene defines the current scene
  24102. */
  24103. constructor(scene?: Nullable<Scene>);
  24104. /**
  24105. * Gets the unique ID of this manager
  24106. */
  24107. readonly uniqueId: number;
  24108. /**
  24109. * Gets the number of vertices handled by this manager
  24110. */
  24111. readonly vertexCount: number;
  24112. /**
  24113. * Gets a boolean indicating if this manager supports morphing of normals
  24114. */
  24115. readonly supportsNormals: boolean;
  24116. /**
  24117. * Gets a boolean indicating if this manager supports morphing of tangents
  24118. */
  24119. readonly supportsTangents: boolean;
  24120. /**
  24121. * Gets the number of targets stored in this manager
  24122. */
  24123. readonly numTargets: number;
  24124. /**
  24125. * Gets the number of influencers (ie. the number of targets with influences > 0)
  24126. */
  24127. readonly numInfluencers: number;
  24128. /**
  24129. * Gets the list of influences (one per target)
  24130. */
  24131. readonly influences: Float32Array;
  24132. /**
  24133. * Gets the active target at specified index. An active target is a target with an influence > 0
  24134. * @param index defines the index to check
  24135. * @returns the requested target
  24136. */
  24137. getActiveTarget(index: number): MorphTarget;
  24138. /**
  24139. * Gets the target at specified index
  24140. * @param index defines the index to check
  24141. * @returns the requested target
  24142. */
  24143. getTarget(index: number): MorphTarget;
  24144. /**
  24145. * Add a new target to this manager
  24146. * @param target defines the target to add
  24147. */
  24148. addTarget(target: MorphTarget): void;
  24149. /**
  24150. * Removes a target from the manager
  24151. * @param target defines the target to remove
  24152. */
  24153. removeTarget(target: MorphTarget): void;
  24154. /**
  24155. * Serializes the current manager into a Serialization object
  24156. * @returns the serialized object
  24157. */
  24158. serialize(): any;
  24159. private _syncActiveTargets(needUpdate);
  24160. /**
  24161. * Syncrhonize the targets with all the meshes using this morph target manager
  24162. */
  24163. synchronize(): void;
  24164. /**
  24165. * Creates a new MorphTargetManager from serialized data
  24166. * @param serializationObject defines the serialized data
  24167. * @param scene defines the hosting scene
  24168. * @returns the new MorphTargetManager
  24169. */
  24170. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24171. }
  24172. }
  24173. declare module BABYLON {
  24174. interface PhysicsImpostorJoint {
  24175. mainImpostor: PhysicsImpostor;
  24176. connectedImpostor: PhysicsImpostor;
  24177. joint: PhysicsJoint;
  24178. }
  24179. class PhysicsEngine {
  24180. private _physicsPlugin;
  24181. gravity: Vector3;
  24182. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  24183. setGravity(gravity: Vector3): void;
  24184. /**
  24185. * Set the time step of the physics engine.
  24186. * default is 1/60.
  24187. * To slow it down, enter 1/600 for example.
  24188. * To speed it up, 1/30
  24189. * @param {number} newTimeStep the new timestep to apply to this world.
  24190. */
  24191. setTimeStep(newTimeStep?: number): void;
  24192. /**
  24193. * Get the time step of the physics engine.
  24194. */
  24195. getTimeStep(): number;
  24196. dispose(): void;
  24197. getPhysicsPluginName(): string;
  24198. static Epsilon: number;
  24199. private _impostors;
  24200. private _joints;
  24201. /**
  24202. * Adding a new impostor for the impostor tracking.
  24203. * This will be done by the impostor itself.
  24204. * @param {PhysicsImpostor} impostor the impostor to add
  24205. */
  24206. addImpostor(impostor: PhysicsImpostor): void;
  24207. /**
  24208. * Remove an impostor from the engine.
  24209. * This impostor and its mesh will not longer be updated by the physics engine.
  24210. * @param {PhysicsImpostor} impostor the impostor to remove
  24211. */
  24212. removeImpostor(impostor: PhysicsImpostor): void;
  24213. /**
  24214. * Add a joint to the physics engine
  24215. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  24216. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  24217. * @param {PhysicsJoint} the joint that will connect both impostors.
  24218. */
  24219. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24220. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24221. /**
  24222. * Called by the scene. no need to call it.
  24223. */
  24224. _step(delta: number): void;
  24225. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24226. getImpostors(): Array<PhysicsImpostor>;
  24227. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24228. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24229. }
  24230. interface IPhysicsEnginePlugin {
  24231. world: any;
  24232. name: string;
  24233. setGravity(gravity: Vector3): void;
  24234. setTimeStep(timeStep: number): void;
  24235. getTimeStep(): number;
  24236. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24237. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24238. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24239. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24240. removePhysicsBody(impostor: PhysicsImpostor): void;
  24241. generateJoint(joint: PhysicsImpostorJoint): void;
  24242. removeJoint(joint: PhysicsImpostorJoint): void;
  24243. isSupported(): boolean;
  24244. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24245. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24246. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24247. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24248. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24249. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24250. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24251. getBodyMass(impostor: PhysicsImpostor): number;
  24252. getBodyFriction(impostor: PhysicsImpostor): number;
  24253. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24254. getBodyRestitution(impostor: PhysicsImpostor): number;
  24255. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24256. sleepBody(impostor: PhysicsImpostor): void;
  24257. wakeUpBody(impostor: PhysicsImpostor): void;
  24258. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24259. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24260. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24261. getRadius(impostor: PhysicsImpostor): number;
  24262. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24263. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24264. dispose(): void;
  24265. }
  24266. }
  24267. declare module BABYLON {
  24268. class PhysicsHelper {
  24269. private _scene;
  24270. private _physicsEngine;
  24271. constructor(scene: Scene);
  24272. /**
  24273. * @param {Vector3} origin the origin of the explosion
  24274. * @param {number} radius the explosion radius
  24275. * @param {number} strength the explosion strength
  24276. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24277. */
  24278. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24279. /**
  24280. * @param {Vector3} origin the origin of the explosion
  24281. * @param {number} radius the explosion radius
  24282. * @param {number} strength the explosion strength
  24283. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24284. */
  24285. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24286. /**
  24287. * @param {Vector3} origin the origin of the explosion
  24288. * @param {number} radius the explosion radius
  24289. * @param {number} strength the explosion strength
  24290. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24291. */
  24292. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  24293. /**
  24294. * @param {Vector3} origin the origin of the updraft
  24295. * @param {number} radius the radius of the updraft
  24296. * @param {number} strength the strength of the updraft
  24297. * @param {number} height the height of the updraft
  24298. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  24299. */
  24300. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  24301. /**
  24302. * @param {Vector3} origin the of the vortex
  24303. * @param {number} radius the radius of the vortex
  24304. * @param {number} strength the strength of the vortex
  24305. * @param {number} height the height of the vortex
  24306. */
  24307. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  24308. }
  24309. /***** Radial explosion *****/
  24310. class PhysicsRadialExplosionEvent {
  24311. private _scene;
  24312. private _sphere;
  24313. private _sphereOptions;
  24314. private _rays;
  24315. private _dataFetched;
  24316. constructor(scene: Scene);
  24317. /**
  24318. * Returns the data related to the radial explosion event (sphere & rays).
  24319. * @returns {PhysicsRadialExplosionEventData}
  24320. */
  24321. getData(): PhysicsRadialExplosionEventData;
  24322. /**
  24323. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  24324. * @param impostor
  24325. * @param {Vector3} origin the origin of the explosion
  24326. * @param {number} radius the explosion radius
  24327. * @param {number} strength the explosion strength
  24328. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  24329. * @returns {Nullable<PhysicsForceAndContactPoint>}
  24330. */
  24331. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  24332. /**
  24333. * Disposes the sphere.
  24334. * @param {bolean} force
  24335. */
  24336. dispose(force?: boolean): void;
  24337. /*** Helpers ***/
  24338. private _prepareSphere();
  24339. private _intersectsWithSphere(impostor, origin, radius);
  24340. }
  24341. /***** Gravitational Field *****/
  24342. class PhysicsGravitationalFieldEvent {
  24343. private _physicsHelper;
  24344. private _scene;
  24345. private _origin;
  24346. private _radius;
  24347. private _strength;
  24348. private _falloff;
  24349. private _tickCallback;
  24350. private _sphere;
  24351. private _dataFetched;
  24352. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  24353. /**
  24354. * Returns the data related to the gravitational field event (sphere).
  24355. * @returns {PhysicsGravitationalFieldEventData}
  24356. */
  24357. getData(): PhysicsGravitationalFieldEventData;
  24358. /**
  24359. * Enables the gravitational field.
  24360. */
  24361. enable(): void;
  24362. /**
  24363. * Disables the gravitational field.
  24364. */
  24365. disable(): void;
  24366. /**
  24367. * Disposes the sphere.
  24368. * @param {bolean} force
  24369. */
  24370. dispose(force?: boolean): void;
  24371. private _tick();
  24372. }
  24373. /***** Updraft *****/
  24374. class PhysicsUpdraftEvent {
  24375. private _scene;
  24376. private _origin;
  24377. private _radius;
  24378. private _strength;
  24379. private _height;
  24380. private _updraftMode;
  24381. private _physicsEngine;
  24382. private _originTop;
  24383. private _originDirection;
  24384. private _tickCallback;
  24385. private _cylinder;
  24386. private _cylinderPosition;
  24387. private _dataFetched;
  24388. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  24389. /**
  24390. * Returns the data related to the updraft event (cylinder).
  24391. * @returns {PhysicsUpdraftEventData}
  24392. */
  24393. getData(): PhysicsUpdraftEventData;
  24394. /**
  24395. * Enables the updraft.
  24396. */
  24397. enable(): void;
  24398. /**
  24399. * Disables the cortex.
  24400. */
  24401. disable(): void;
  24402. /**
  24403. * Disposes the sphere.
  24404. * @param {bolean} force
  24405. */
  24406. dispose(force?: boolean): void;
  24407. private getImpostorForceAndContactPoint(impostor);
  24408. private _tick();
  24409. /*** Helpers ***/
  24410. private _prepareCylinder();
  24411. private _intersectsWithCylinder(impostor);
  24412. }
  24413. /***** Vortex *****/
  24414. class PhysicsVortexEvent {
  24415. private _scene;
  24416. private _origin;
  24417. private _radius;
  24418. private _strength;
  24419. private _height;
  24420. private _physicsEngine;
  24421. private _originTop;
  24422. private _centripetalForceThreshold;
  24423. private _updraftMultiplier;
  24424. private _tickCallback;
  24425. private _cylinder;
  24426. private _cylinderPosition;
  24427. private _dataFetched;
  24428. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  24429. /**
  24430. * Returns the data related to the vortex event (cylinder).
  24431. * @returns {PhysicsVortexEventData}
  24432. */
  24433. getData(): PhysicsVortexEventData;
  24434. /**
  24435. * Enables the vortex.
  24436. */
  24437. enable(): void;
  24438. /**
  24439. * Disables the cortex.
  24440. */
  24441. disable(): void;
  24442. /**
  24443. * Disposes the sphere.
  24444. * @param {bolean} force
  24445. */
  24446. dispose(force?: boolean): void;
  24447. private getImpostorForceAndContactPoint(impostor);
  24448. private _tick();
  24449. /*** Helpers ***/
  24450. private _prepareCylinder();
  24451. private _intersectsWithCylinder(impostor);
  24452. }
  24453. /***** Enums *****/
  24454. /**
  24455. * The strenght of the force in correspondence to the distance of the affected object
  24456. */
  24457. enum PhysicsRadialImpulseFalloff {
  24458. /** Defines that impulse is constant in strength across it's whole radius */
  24459. Constant = 0,
  24460. /** DEfines that impulse gets weaker if it's further from the origin */
  24461. Linear = 1,
  24462. }
  24463. /**
  24464. * The strenght of the force in correspondence to the distance of the affected object
  24465. */
  24466. enum PhysicsUpdraftMode {
  24467. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  24468. Center = 0,
  24469. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  24470. Perpendicular = 1,
  24471. }
  24472. /***** Data interfaces *****/
  24473. interface PhysicsForceAndContactPoint {
  24474. force: Vector3;
  24475. contactPoint: Vector3;
  24476. }
  24477. interface PhysicsRadialExplosionEventData {
  24478. sphere: Mesh;
  24479. rays: Array<Ray>;
  24480. }
  24481. interface PhysicsGravitationalFieldEventData {
  24482. sphere: Mesh;
  24483. }
  24484. interface PhysicsUpdraftEventData {
  24485. cylinder: Mesh;
  24486. }
  24487. interface PhysicsVortexEventData {
  24488. cylinder: Mesh;
  24489. }
  24490. }
  24491. declare module BABYLON {
  24492. interface PhysicsImpostorParameters {
  24493. mass: number;
  24494. friction?: number;
  24495. restitution?: number;
  24496. nativeOptions?: any;
  24497. ignoreParent?: boolean;
  24498. disableBidirectionalTransformation?: boolean;
  24499. }
  24500. interface IPhysicsEnabledObject {
  24501. position: Vector3;
  24502. rotationQuaternion: Nullable<Quaternion>;
  24503. scaling: Vector3;
  24504. rotation?: Vector3;
  24505. parent?: any;
  24506. getBoundingInfo(): BoundingInfo;
  24507. computeWorldMatrix(force: boolean): Matrix;
  24508. getWorldMatrix?(): Matrix;
  24509. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24510. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24511. getIndices?(): Nullable<IndicesArray>;
  24512. getScene?(): Scene;
  24513. getAbsolutePosition(): Vector3;
  24514. getAbsolutePivotPoint(): Vector3;
  24515. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24516. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24517. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24518. getClassName(): string;
  24519. }
  24520. class PhysicsImpostor {
  24521. object: IPhysicsEnabledObject;
  24522. type: number;
  24523. private _options;
  24524. private _scene;
  24525. static DEFAULT_OBJECT_SIZE: Vector3;
  24526. static IDENTITY_QUATERNION: Quaternion;
  24527. private _physicsEngine;
  24528. private _physicsBody;
  24529. private _bodyUpdateRequired;
  24530. private _onBeforePhysicsStepCallbacks;
  24531. private _onAfterPhysicsStepCallbacks;
  24532. private _onPhysicsCollideCallbacks;
  24533. private _deltaPosition;
  24534. private _deltaRotation;
  24535. private _deltaRotationConjugated;
  24536. private _parent;
  24537. private _isDisposed;
  24538. private static _tmpVecs;
  24539. private static _tmpQuat;
  24540. readonly isDisposed: boolean;
  24541. mass: number;
  24542. friction: number;
  24543. restitution: number;
  24544. uniqueId: number;
  24545. private _joints;
  24546. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24547. /**
  24548. * This function will completly initialize this impostor.
  24549. * It will create a new body - but only if this mesh has no parent.
  24550. * If it has, this impostor will not be used other than to define the impostor
  24551. * of the child mesh.
  24552. */
  24553. _init(): void;
  24554. private _getPhysicsParent();
  24555. /**
  24556. * Should a new body be generated.
  24557. */
  24558. isBodyInitRequired(): boolean;
  24559. setScalingUpdated(updated: boolean): void;
  24560. /**
  24561. * Force a regeneration of this or the parent's impostor's body.
  24562. * Use under cautious - This will remove all joints already implemented.
  24563. */
  24564. forceUpdate(): void;
  24565. /**
  24566. * Gets the body that holds this impostor. Either its own, or its parent.
  24567. */
  24568. /**
  24569. * Set the physics body. Used mainly by the physics engine/plugin
  24570. */
  24571. physicsBody: any;
  24572. parent: Nullable<PhysicsImpostor>;
  24573. resetUpdateFlags(): void;
  24574. getObjectExtendSize(): Vector3;
  24575. getObjectCenter(): Vector3;
  24576. /**
  24577. * Get a specific parametes from the options parameter.
  24578. */
  24579. getParam(paramName: string): any;
  24580. /**
  24581. * Sets a specific parameter in the options given to the physics plugin
  24582. */
  24583. setParam(paramName: string, value: number): void;
  24584. /**
  24585. * Specifically change the body's mass option. Won't recreate the physics body object
  24586. */
  24587. setMass(mass: number): void;
  24588. getLinearVelocity(): Nullable<Vector3>;
  24589. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24590. getAngularVelocity(): Nullable<Vector3>;
  24591. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24592. /**
  24593. * Execute a function with the physics plugin native code.
  24594. * Provide a function the will have two variables - the world object and the physics body object.
  24595. */
  24596. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24597. /**
  24598. * Register a function that will be executed before the physics world is stepping forward.
  24599. */
  24600. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24601. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24602. /**
  24603. * Register a function that will be executed after the physics step
  24604. */
  24605. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24606. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24607. /**
  24608. * register a function that will be executed when this impostor collides against a different body.
  24609. */
  24610. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24611. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24612. private _tmpQuat;
  24613. private _tmpQuat2;
  24614. getParentsRotation(): Quaternion;
  24615. /**
  24616. * this function is executed by the physics engine.
  24617. */
  24618. beforeStep: () => void;
  24619. /**
  24620. * this function is executed by the physics engine.
  24621. */
  24622. afterStep: () => void;
  24623. /**
  24624. * Legacy collision detection event support
  24625. */
  24626. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24627. onCollide: (e: {
  24628. body: any;
  24629. }) => void;
  24630. /**
  24631. * Apply a force
  24632. */
  24633. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24634. /**
  24635. * Apply an impulse
  24636. */
  24637. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24638. /**
  24639. * A help function to create a joint.
  24640. */
  24641. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24642. /**
  24643. * Add a joint to this impostor with a different impostor.
  24644. */
  24645. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24646. /**
  24647. * Will keep this body still, in a sleep mode.
  24648. */
  24649. sleep(): PhysicsImpostor;
  24650. /**
  24651. * Wake the body up.
  24652. */
  24653. wakeUp(): PhysicsImpostor;
  24654. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24655. dispose(): void;
  24656. setDeltaPosition(position: Vector3): void;
  24657. setDeltaRotation(rotation: Quaternion): void;
  24658. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24659. getRadius(): number;
  24660. /**
  24661. * Sync a bone with this impostor
  24662. * @param bone The bone to sync to the impostor.
  24663. * @param boneMesh The mesh that the bone is influencing.
  24664. * @param jointPivot The pivot of the joint / bone in local space.
  24665. * @param distToJoint Optional distance from the impostor to the joint.
  24666. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24667. */
  24668. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24669. /**
  24670. * Sync impostor to a bone
  24671. * @param bone The bone that the impostor will be synced to.
  24672. * @param boneMesh The mesh that the bone is influencing.
  24673. * @param jointPivot The pivot of the joint / bone in local space.
  24674. * @param distToJoint Optional distance from the impostor to the joint.
  24675. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24676. * @param boneAxis Optional vector3 axis the bone is aligned with
  24677. */
  24678. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24679. static NoImpostor: number;
  24680. static SphereImpostor: number;
  24681. static BoxImpostor: number;
  24682. static PlaneImpostor: number;
  24683. static MeshImpostor: number;
  24684. static CylinderImpostor: number;
  24685. static ParticleImpostor: number;
  24686. static HeightmapImpostor: number;
  24687. }
  24688. }
  24689. declare module BABYLON {
  24690. interface PhysicsJointData {
  24691. mainPivot?: Vector3;
  24692. connectedPivot?: Vector3;
  24693. mainAxis?: Vector3;
  24694. connectedAxis?: Vector3;
  24695. collision?: boolean;
  24696. nativeParams?: any;
  24697. }
  24698. /**
  24699. * This is a holder class for the physics joint created by the physics plugin.
  24700. * It holds a set of functions to control the underlying joint.
  24701. */
  24702. class PhysicsJoint {
  24703. type: number;
  24704. jointData: PhysicsJointData;
  24705. private _physicsJoint;
  24706. protected _physicsPlugin: IPhysicsEnginePlugin;
  24707. constructor(type: number, jointData: PhysicsJointData);
  24708. physicsJoint: any;
  24709. physicsPlugin: IPhysicsEnginePlugin;
  24710. /**
  24711. * Execute a function that is physics-plugin specific.
  24712. * @param {Function} func the function that will be executed.
  24713. * It accepts two parameters: the physics world and the physics joint.
  24714. */
  24715. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24716. static DistanceJoint: number;
  24717. static HingeJoint: number;
  24718. static BallAndSocketJoint: number;
  24719. static WheelJoint: number;
  24720. static SliderJoint: number;
  24721. static PrismaticJoint: number;
  24722. static UniversalJoint: number;
  24723. static Hinge2Joint: number;
  24724. static PointToPointJoint: number;
  24725. static SpringJoint: number;
  24726. static LockJoint: number;
  24727. }
  24728. /**
  24729. * A class representing a physics distance joint.
  24730. */
  24731. class DistanceJoint extends PhysicsJoint {
  24732. constructor(jointData: DistanceJointData);
  24733. /**
  24734. * Update the predefined distance.
  24735. */
  24736. updateDistance(maxDistance: number, minDistance?: number): void;
  24737. }
  24738. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24739. constructor(type: number, jointData: PhysicsJointData);
  24740. /**
  24741. * Set the motor values.
  24742. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24743. * @param {number} force the force to apply
  24744. * @param {number} maxForce max force for this motor.
  24745. */
  24746. setMotor(force?: number, maxForce?: number): void;
  24747. /**
  24748. * Set the motor's limits.
  24749. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24750. */
  24751. setLimit(upperLimit: number, lowerLimit?: number): void;
  24752. }
  24753. /**
  24754. * This class represents a single hinge physics joint
  24755. */
  24756. class HingeJoint extends MotorEnabledJoint {
  24757. constructor(jointData: PhysicsJointData);
  24758. /**
  24759. * Set the motor values.
  24760. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24761. * @param {number} force the force to apply
  24762. * @param {number} maxForce max force for this motor.
  24763. */
  24764. setMotor(force?: number, maxForce?: number): void;
  24765. /**
  24766. * Set the motor's limits.
  24767. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24768. */
  24769. setLimit(upperLimit: number, lowerLimit?: number): void;
  24770. }
  24771. /**
  24772. * This class represents a dual hinge physics joint (same as wheel joint)
  24773. */
  24774. class Hinge2Joint extends MotorEnabledJoint {
  24775. constructor(jointData: PhysicsJointData);
  24776. /**
  24777. * Set the motor values.
  24778. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24779. * @param {number} force the force to apply
  24780. * @param {number} maxForce max force for this motor.
  24781. * @param {motorIndex} the motor's index, 0 or 1.
  24782. */
  24783. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24784. /**
  24785. * Set the motor limits.
  24786. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24787. * @param {number} upperLimit the upper limit
  24788. * @param {number} lowerLimit lower limit
  24789. * @param {motorIndex} the motor's index, 0 or 1.
  24790. */
  24791. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24792. }
  24793. interface IMotorEnabledJoint {
  24794. physicsJoint: any;
  24795. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24796. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24797. }
  24798. interface DistanceJointData extends PhysicsJointData {
  24799. maxDistance: number;
  24800. }
  24801. interface SpringJointData extends PhysicsJointData {
  24802. length: number;
  24803. stiffness: number;
  24804. damping: number;
  24805. }
  24806. }
  24807. declare module BABYLON {
  24808. class ReflectionProbe {
  24809. name: string;
  24810. private _scene;
  24811. private _renderTargetTexture;
  24812. private _projectionMatrix;
  24813. private _viewMatrix;
  24814. private _target;
  24815. private _add;
  24816. private _attachedMesh;
  24817. private _invertYAxis;
  24818. position: Vector3;
  24819. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  24820. samples: number;
  24821. refreshRate: number;
  24822. getScene(): Scene;
  24823. readonly cubeTexture: RenderTargetTexture;
  24824. readonly renderList: Nullable<AbstractMesh[]>;
  24825. attachToMesh(mesh: AbstractMesh): void;
  24826. /**
  24827. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24828. *
  24829. * @param renderingGroupId The rendering group id corresponding to its index
  24830. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24831. */
  24832. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24833. dispose(): void;
  24834. }
  24835. }
  24836. declare module BABYLON {
  24837. class Sprite {
  24838. name: string;
  24839. position: Vector3;
  24840. color: Color4;
  24841. width: number;
  24842. height: number;
  24843. angle: number;
  24844. cellIndex: number;
  24845. invertU: number;
  24846. invertV: number;
  24847. disposeWhenFinishedAnimating: boolean;
  24848. animations: Animation[];
  24849. isPickable: boolean;
  24850. actionManager: ActionManager;
  24851. private _animationStarted;
  24852. private _loopAnimation;
  24853. private _fromIndex;
  24854. private _toIndex;
  24855. private _delay;
  24856. private _direction;
  24857. private _manager;
  24858. private _time;
  24859. private _onAnimationEnd;
  24860. size: number;
  24861. constructor(name: string, manager: SpriteManager);
  24862. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  24863. stopAnimation(): void;
  24864. _animate(deltaTime: number): void;
  24865. dispose(): void;
  24866. }
  24867. }
  24868. declare module BABYLON {
  24869. class SpriteManager {
  24870. name: string;
  24871. sprites: Sprite[];
  24872. renderingGroupId: number;
  24873. layerMask: number;
  24874. fogEnabled: boolean;
  24875. isPickable: boolean;
  24876. cellWidth: number;
  24877. cellHeight: number;
  24878. /**
  24879. * An event triggered when the manager is disposed.
  24880. */
  24881. onDisposeObservable: Observable<SpriteManager>;
  24882. private _onDisposeObserver;
  24883. onDispose: () => void;
  24884. private _capacity;
  24885. private _spriteTexture;
  24886. private _epsilon;
  24887. private _scene;
  24888. private _vertexData;
  24889. private _buffer;
  24890. private _vertexBuffers;
  24891. private _indexBuffer;
  24892. private _effectBase;
  24893. private _effectFog;
  24894. texture: Texture;
  24895. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  24896. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  24897. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24898. render(): void;
  24899. dispose(): void;
  24900. }
  24901. }
  24902. declare module BABYLON {
  24903. class BoundingBoxRenderer {
  24904. frontColor: Color3;
  24905. backColor: Color3;
  24906. showBackLines: boolean;
  24907. renderList: SmartArray<BoundingBox>;
  24908. private _scene;
  24909. private _colorShader;
  24910. private _vertexBuffers;
  24911. private _indexBuffer;
  24912. constructor(scene: Scene);
  24913. private _prepareRessources();
  24914. private _createIndexBuffer();
  24915. _rebuild(): void;
  24916. reset(): void;
  24917. render(): void;
  24918. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  24919. dispose(): void;
  24920. }
  24921. }
  24922. declare module BABYLON {
  24923. /**
  24924. * This represents a depth renderer in Babylon.
  24925. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  24926. */
  24927. class DepthRenderer {
  24928. private _scene;
  24929. private _depthMap;
  24930. private _effect;
  24931. private _cachedDefines;
  24932. private _camera;
  24933. /**
  24934. * Instantiates a depth renderer
  24935. * @param scene The scene the renderer belongs to
  24936. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  24937. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  24938. */
  24939. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  24940. /**
  24941. * Creates the depth rendering effect and checks if the effect is ready.
  24942. * @param subMesh The submesh to be used to render the depth map of
  24943. * @param useInstances If multiple world instances should be used
  24944. * @returns if the depth renderer is ready to render the depth map
  24945. */
  24946. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  24947. /**
  24948. * Gets the texture which the depth map will be written to.
  24949. * @returns The depth map texture
  24950. */
  24951. getDepthMap(): RenderTargetTexture;
  24952. /**
  24953. * Disposes of the depth renderer.
  24954. */
  24955. dispose(): void;
  24956. }
  24957. }
  24958. declare module BABYLON {
  24959. class EdgesRenderer {
  24960. edgesWidthScalerForOrthographic: number;
  24961. edgesWidthScalerForPerspective: number;
  24962. private _source;
  24963. private _linesPositions;
  24964. private _linesNormals;
  24965. private _linesIndices;
  24966. private _epsilon;
  24967. private _indicesCount;
  24968. private _lineShader;
  24969. private _ib;
  24970. private _buffers;
  24971. private _checkVerticesInsteadOfIndices;
  24972. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  24973. private _prepareRessources();
  24974. _rebuild(): void;
  24975. dispose(): void;
  24976. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  24977. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  24978. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  24979. _generateEdgesLines(): void;
  24980. render(): void;
  24981. }
  24982. }
  24983. declare module BABYLON {
  24984. /**
  24985. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  24986. */
  24987. class GeometryBufferRenderer {
  24988. private _scene;
  24989. private _multiRenderTarget;
  24990. private _ratio;
  24991. private _enablePosition;
  24992. protected _effect: Effect;
  24993. protected _cachedDefines: string;
  24994. /**
  24995. * Set the render list (meshes to be rendered) used in the G buffer.
  24996. */
  24997. renderList: Mesh[];
  24998. /**
  24999. * Gets wether or not G buffer are supported by the running hardware.
  25000. * This requires draw buffer supports
  25001. */
  25002. readonly isSupported: boolean;
  25003. /**
  25004. * Gets wether or not position are enabled for the G buffer.
  25005. */
  25006. /**
  25007. * Sets wether or not position are enabled for the G buffer.
  25008. */
  25009. enablePosition: boolean;
  25010. /**
  25011. * Gets the scene associated with the buffer.
  25012. */
  25013. readonly scene: Scene;
  25014. /**
  25015. * Gets the ratio used by the buffer during its creation.
  25016. * How big is the buffer related to the main canvas.
  25017. */
  25018. readonly ratio: number;
  25019. /**
  25020. * Creates a new G Buffer for the scene
  25021. * @param scene The scene the buffer belongs to
  25022. * @param ratio How big is the buffer related to the main canvas.
  25023. */
  25024. constructor(scene: Scene, ratio?: number);
  25025. /**
  25026. * Checks wether everything is ready to render a submesh to the G buffer.
  25027. * @param subMesh the submesh to check readiness for
  25028. * @param useInstances is the mesh drawn using instance or not
  25029. * @returns true if ready otherwise false
  25030. */
  25031. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25032. /**
  25033. * Gets the current underlying G Buffer.
  25034. * @returns the buffer
  25035. */
  25036. getGBuffer(): MultiRenderTarget;
  25037. /**
  25038. * Gets the number of samples used to render the buffer (anti aliasing).
  25039. */
  25040. /**
  25041. * Sets the number of samples used to render the buffer (anti aliasing).
  25042. */
  25043. samples: number;
  25044. /**
  25045. * Disposes the renderer and frees up associated resources.
  25046. */
  25047. dispose(): void;
  25048. protected _createRenderTargets(): void;
  25049. }
  25050. }
  25051. declare module BABYLON {
  25052. class OutlineRenderer {
  25053. private _scene;
  25054. private _effect;
  25055. private _cachedDefines;
  25056. zOffset: number;
  25057. constructor(scene: Scene);
  25058. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  25059. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25060. }
  25061. }
  25062. declare module BABYLON {
  25063. class RenderingGroup {
  25064. index: number;
  25065. private _scene;
  25066. private _opaqueSubMeshes;
  25067. private _transparentSubMeshes;
  25068. private _alphaTestSubMeshes;
  25069. private _depthOnlySubMeshes;
  25070. private _particleSystems;
  25071. private _spriteManagers;
  25072. private _opaqueSortCompareFn;
  25073. private _alphaTestSortCompareFn;
  25074. private _transparentSortCompareFn;
  25075. private _renderOpaque;
  25076. private _renderAlphaTest;
  25077. private _renderTransparent;
  25078. private _edgesRenderers;
  25079. onBeforeTransparentRendering: () => void;
  25080. /**
  25081. * Set the opaque sort comparison function.
  25082. * If null the sub meshes will be render in the order they were created
  25083. */
  25084. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  25085. /**
  25086. * Set the alpha test sort comparison function.
  25087. * If null the sub meshes will be render in the order they were created
  25088. */
  25089. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  25090. /**
  25091. * Set the transparent sort comparison function.
  25092. * If null the sub meshes will be render in the order they were created
  25093. */
  25094. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  25095. /**
  25096. * Creates a new rendering group.
  25097. * @param index The rendering group index
  25098. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  25099. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  25100. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  25101. */
  25102. 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>);
  25103. /**
  25104. * Render all the sub meshes contained in the group.
  25105. * @param customRenderFunction Used to override the default render behaviour of the group.
  25106. * @returns true if rendered some submeshes.
  25107. */
  25108. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  25109. /**
  25110. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  25111. * @param subMeshes The submeshes to render
  25112. */
  25113. private renderOpaqueSorted(subMeshes);
  25114. /**
  25115. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  25116. * @param subMeshes The submeshes to render
  25117. */
  25118. private renderAlphaTestSorted(subMeshes);
  25119. /**
  25120. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  25121. * @param subMeshes The submeshes to render
  25122. */
  25123. private renderTransparentSorted(subMeshes);
  25124. /**
  25125. * Renders the submeshes in a specified order.
  25126. * @param subMeshes The submeshes to sort before render
  25127. * @param sortCompareFn The comparison function use to sort
  25128. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  25129. * @param transparent Specifies to activate blending if true
  25130. */
  25131. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  25132. /**
  25133. * Renders the submeshes in the order they were dispatched (no sort applied).
  25134. * @param subMeshes The submeshes to render
  25135. */
  25136. private static renderUnsorted(subMeshes);
  25137. /**
  25138. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25139. * are rendered back to front if in the same alpha index.
  25140. *
  25141. * @param a The first submesh
  25142. * @param b The second submesh
  25143. * @returns The result of the comparison
  25144. */
  25145. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  25146. /**
  25147. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25148. * are rendered back to front.
  25149. *
  25150. * @param a The first submesh
  25151. * @param b The second submesh
  25152. * @returns The result of the comparison
  25153. */
  25154. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  25155. /**
  25156. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25157. * are rendered front to back (prevent overdraw).
  25158. *
  25159. * @param a The first submesh
  25160. * @param b The second submesh
  25161. * @returns The result of the comparison
  25162. */
  25163. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  25164. /**
  25165. * Resets the different lists of submeshes to prepare a new frame.
  25166. */
  25167. prepare(): void;
  25168. dispose(): void;
  25169. /**
  25170. * Inserts the submesh in its correct queue depending on its material.
  25171. * @param subMesh The submesh to dispatch
  25172. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  25173. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  25174. */
  25175. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  25176. dispatchSprites(spriteManager: SpriteManager): void;
  25177. dispatchParticles(particleSystem: IParticleSystem): void;
  25178. private _renderParticles(activeMeshes);
  25179. private _renderSprites();
  25180. }
  25181. }
  25182. declare module BABYLON {
  25183. class RenderingManager {
  25184. /**
  25185. * The max id used for rendering groups (not included)
  25186. */
  25187. static MAX_RENDERINGGROUPS: number;
  25188. /**
  25189. * The min id used for rendering groups (included)
  25190. */
  25191. static MIN_RENDERINGGROUPS: number;
  25192. /**
  25193. * Used to globally prevent autoclearing scenes.
  25194. */
  25195. static AUTOCLEAR: boolean;
  25196. private _scene;
  25197. private _renderingGroups;
  25198. private _depthStencilBufferAlreadyCleaned;
  25199. private _autoClearDepthStencil;
  25200. private _customOpaqueSortCompareFn;
  25201. private _customAlphaTestSortCompareFn;
  25202. private _customTransparentSortCompareFn;
  25203. private _renderinGroupInfo;
  25204. constructor(scene: Scene);
  25205. private _clearDepthStencilBuffer(depth?, stencil?);
  25206. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  25207. reset(): void;
  25208. dispose(): void;
  25209. /**
  25210. * Clear the info related to rendering groups preventing retention points during dispose.
  25211. */
  25212. freeRenderingGroups(): void;
  25213. private _prepareRenderingGroup(renderingGroupId);
  25214. dispatchSprites(spriteManager: SpriteManager): void;
  25215. dispatchParticles(particleSystem: IParticleSystem): void;
  25216. /**
  25217. * @param subMesh The submesh to dispatch
  25218. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  25219. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  25220. */
  25221. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  25222. /**
  25223. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  25224. * This allowed control for front to back rendering or reversly depending of the special needs.
  25225. *
  25226. * @param renderingGroupId The rendering group id corresponding to its index
  25227. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  25228. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  25229. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  25230. */
  25231. 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;
  25232. /**
  25233. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  25234. *
  25235. * @param renderingGroupId The rendering group id corresponding to its index
  25236. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  25237. * @param depth Automatically clears depth between groups if true and autoClear is true.
  25238. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  25239. */
  25240. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  25241. }
  25242. }
  25243. declare module BABYLON {
  25244. /**
  25245. * Postprocess used to generate anaglyphic rendering
  25246. */
  25247. class AnaglyphPostProcess extends PostProcess {
  25248. private _passedProcess;
  25249. /**
  25250. * Creates a new AnaglyphPostProcess
  25251. * @param name defines postprocess name
  25252. * @param options defines creation options or target ratio scale
  25253. * @param rigCameras defines cameras using this postprocess
  25254. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  25255. * @param engine defines hosting engine
  25256. * @param reusable defines if the postprocess will be reused multiple times per frame
  25257. */
  25258. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  25259. }
  25260. }
  25261. declare module BABYLON {
  25262. class BlackAndWhitePostProcess extends PostProcess {
  25263. degree: number;
  25264. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25265. }
  25266. }
  25267. declare module BABYLON {
  25268. /**
  25269. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  25270. */
  25271. class BloomEffect extends PostProcessRenderEffect {
  25272. private bloomScale;
  25273. /**
  25274. * Internal
  25275. */
  25276. _effects: Array<PostProcess>;
  25277. /**
  25278. * Internal
  25279. */
  25280. _downscale: ExtractHighlightsPostProcess;
  25281. private _blurX;
  25282. private _blurY;
  25283. private _merge;
  25284. /**
  25285. * The luminance threshold to find bright areas of the image to bloom.
  25286. */
  25287. threshold: number;
  25288. /**
  25289. * The strength of the bloom.
  25290. */
  25291. weight: number;
  25292. /**
  25293. * Specifies the size of the bloom blur kernel, relative to the final output size
  25294. */
  25295. kernel: number;
  25296. /**
  25297. * Creates a new instance of @see BloomEffect
  25298. * @param scene The scene the effect belongs to.
  25299. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  25300. * @param bloomKernel The size of the kernel to be used when applying the blur.
  25301. * @param bloomWeight The the strength of bloom.
  25302. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  25303. * @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)
  25304. */
  25305. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  25306. /**
  25307. * Disposes each of the internal effects for a given camera.
  25308. * @param camera The camera to dispose the effect on.
  25309. */
  25310. disposeEffects(camera: Camera): void;
  25311. /**
  25312. * Internal
  25313. */
  25314. _updateEffects(): void;
  25315. /**
  25316. * Internal
  25317. * @returns if all the contained post processes are ready.
  25318. */
  25319. _isReady(): boolean;
  25320. }
  25321. }
  25322. declare module BABYLON {
  25323. /**
  25324. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  25325. */
  25326. class BloomMergePostProcess extends PostProcess {
  25327. /** Weight of the bloom to be added to the original input. */ weight: number;
  25328. /**
  25329. * Creates a new instance of @see BloomMergePostProcess
  25330. * @param name The name of the effect.
  25331. * @param originalFromInput Post process which's input will be used for the merge.
  25332. * @param blurred Blurred highlights post process which's output will be used.
  25333. * @param weight Weight of the bloom to be added to the original input.
  25334. * @param options The required width/height ratio to downsize to before computing the render pass.
  25335. * @param camera The camera to apply the render pass to.
  25336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25337. * @param engine The engine which the post process will be applied. (default: current engine)
  25338. * @param reusable If the post process can be reused on the same frame. (default: false)
  25339. * @param textureType Type of textures used when performing the post process. (default: 0)
  25340. * @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)
  25341. */
  25342. 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);
  25343. }
  25344. }
  25345. declare module BABYLON {
  25346. /**
  25347. * The Blur Post Process which blurs an image based on a kernel and direction.
  25348. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  25349. */
  25350. class BlurPostProcess extends PostProcess {
  25351. /** The direction in which to blur the image. */ direction: Vector2;
  25352. private blockCompilation;
  25353. protected _kernel: number;
  25354. protected _idealKernel: number;
  25355. protected _packedFloat: boolean;
  25356. private _staticDefines;
  25357. /**
  25358. * Gets the length in pixels of the blur sample region
  25359. */
  25360. /**
  25361. * Sets the length in pixels of the blur sample region
  25362. */
  25363. kernel: number;
  25364. /**
  25365. * Gets wether or not the blur is unpacking/repacking floats
  25366. */
  25367. /**
  25368. * Sets wether or not the blur needs to unpack/repack floats
  25369. */
  25370. packedFloat: boolean;
  25371. /**
  25372. * Creates a new instance BlurPostProcess
  25373. * @param name The name of the effect.
  25374. * @param direction The direction in which to blur the image.
  25375. * @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.
  25376. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  25377. * @param camera The camera to apply the render pass to.
  25378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25379. * @param engine The engine which the post process will be applied. (default: current engine)
  25380. * @param reusable If the post process can be reused on the same frame. (default: false)
  25381. * @param textureType Type of textures used when performing the post process. (default: 0)
  25382. * @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)
  25383. */
  25384. 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);
  25385. /**
  25386. * Updates the effect with the current post process compile time values and recompiles the shader.
  25387. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25388. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25389. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25390. * @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
  25391. * @param onCompiled Called when the shader has been compiled.
  25392. * @param onError Called if there is an error when compiling a shader.
  25393. */
  25394. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25395. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25396. /**
  25397. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  25398. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  25399. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  25400. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  25401. * The gaps between physical kernels are compensated for in the weighting of the samples
  25402. * @param idealKernel Ideal blur kernel.
  25403. * @return Nearest best kernel.
  25404. */
  25405. protected _nearestBestKernel(idealKernel: number): number;
  25406. /**
  25407. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  25408. * @param x The point on the Gaussian distribution to sample.
  25409. * @return the value of the Gaussian function at x.
  25410. */
  25411. protected _gaussianWeight(x: number): number;
  25412. /**
  25413. * Generates a string that can be used as a floating point number in GLSL.
  25414. * @param x Value to print.
  25415. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  25416. * @return GLSL float string.
  25417. */
  25418. protected _glslFloat(x: number, decimalFigures?: number): string;
  25419. }
  25420. }
  25421. declare module BABYLON {
  25422. /**
  25423. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  25424. */
  25425. class ChromaticAberrationPostProcess extends PostProcess {
  25426. /**
  25427. * The amount of seperation of rgb channels (default: 30)
  25428. */
  25429. aberrationAmount: number;
  25430. /**
  25431. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  25432. */
  25433. radialIntensity: number;
  25434. /**
  25435. * 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))
  25436. */
  25437. direction: Vector2;
  25438. /**
  25439. * 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))
  25440. */
  25441. centerPosition: Vector2;
  25442. /**
  25443. * Creates a new instance ChromaticAberrationPostProcess
  25444. * @param name The name of the effect.
  25445. * @param screenWidth The width of the screen to apply the effect on.
  25446. * @param screenHeight The height of the screen to apply the effect on.
  25447. * @param options The required width/height ratio to downsize to before computing the render pass.
  25448. * @param camera The camera to apply the render pass to.
  25449. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25450. * @param engine The engine which the post process will be applied. (default: current engine)
  25451. * @param reusable If the post process can be reused on the same frame. (default: false)
  25452. * @param textureType Type of textures used when performing the post process. (default: 0)
  25453. * @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)
  25454. */
  25455. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25456. }
  25457. }
  25458. declare module BABYLON {
  25459. /**
  25460. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  25461. */
  25462. class CircleOfConfusionPostProcess extends PostProcess {
  25463. /**
  25464. * 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.
  25465. */
  25466. lensSize: number;
  25467. /**
  25468. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25469. */
  25470. fStop: number;
  25471. /**
  25472. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25473. */
  25474. focusDistance: number;
  25475. /**
  25476. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  25477. */
  25478. focalLength: number;
  25479. private _depthTexture;
  25480. /**
  25481. * Creates a new instance CircleOfConfusionPostProcess
  25482. * @param name The name of the effect.
  25483. * @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.
  25484. * @param options The required width/height ratio to downsize to before computing the render pass.
  25485. * @param camera The camera to apply the render pass to.
  25486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25487. * @param engine The engine which the post process will be applied. (default: current engine)
  25488. * @param reusable If the post process can be reused on the same frame. (default: false)
  25489. * @param textureType Type of textures used when performing the post process. (default: 0)
  25490. * @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)
  25491. */
  25492. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25493. /**
  25494. * 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.
  25495. */
  25496. depthTexture: RenderTargetTexture;
  25497. }
  25498. }
  25499. declare module BABYLON {
  25500. class ColorCorrectionPostProcess extends PostProcess {
  25501. private _colorTableTexture;
  25502. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25503. }
  25504. }
  25505. declare module BABYLON {
  25506. /**
  25507. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  25508. * input texture to perform effects such as edge detection or sharpening
  25509. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  25510. */
  25511. class ConvolutionPostProcess extends PostProcess {
  25512. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  25513. /**
  25514. * Creates a new instance ConvolutionPostProcess
  25515. * @param name The name of the effect.
  25516. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  25517. * @param options The required width/height ratio to downsize to before computing the render pass.
  25518. * @param camera The camera to apply the render pass to.
  25519. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25520. * @param engine The engine which the post process will be applied. (default: current engine)
  25521. * @param reusable If the post process can be reused on the same frame. (default: false)
  25522. * @param textureType Type of textures used when performing the post process. (default: 0)
  25523. */
  25524. 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);
  25525. /**
  25526. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25527. */
  25528. static EdgeDetect0Kernel: number[];
  25529. /**
  25530. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25531. */
  25532. static EdgeDetect1Kernel: number[];
  25533. /**
  25534. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25535. */
  25536. static EdgeDetect2Kernel: number[];
  25537. /**
  25538. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25539. */
  25540. static SharpenKernel: number[];
  25541. /**
  25542. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25543. */
  25544. static EmbossKernel: number[];
  25545. /**
  25546. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25547. */
  25548. static GaussianKernel: number[];
  25549. }
  25550. }
  25551. declare module BABYLON {
  25552. /**
  25553. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  25554. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  25555. * based on samples that have a large difference in distance than the center pixel.
  25556. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  25557. */
  25558. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  25559. direction: Vector2;
  25560. /**
  25561. * Creates a new instance CircleOfConfusionPostProcess
  25562. * @param name The name of the effect.
  25563. * @param scene The scene the effect belongs to.
  25564. * @param direction The direction the blur should be applied.
  25565. * @param kernel The size of the kernel used to blur.
  25566. * @param options The required width/height ratio to downsize to before computing the render pass.
  25567. * @param camera The camera to apply the render pass to.
  25568. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  25569. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  25570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25571. * @param engine The engine which the post process will be applied. (default: current engine)
  25572. * @param reusable If the post process can be reused on the same frame. (default: false)
  25573. * @param textureType Type of textures used when performing the post process. (default: 0)
  25574. * @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)
  25575. */
  25576. 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);
  25577. }
  25578. }
  25579. declare module BABYLON {
  25580. /**
  25581. * Specifies the level of max blur that should be applied when using the depth of field effect
  25582. */
  25583. enum DepthOfFieldEffectBlurLevel {
  25584. /**
  25585. * Subtle blur
  25586. */
  25587. Low = 0,
  25588. /**
  25589. * Medium blur
  25590. */
  25591. Medium = 1,
  25592. /**
  25593. * Large blur
  25594. */
  25595. High = 2,
  25596. }
  25597. /**
  25598. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  25599. */
  25600. class DepthOfFieldEffect extends PostProcessRenderEffect {
  25601. private _circleOfConfusion;
  25602. /**
  25603. * Internal, blurs from high to low
  25604. */
  25605. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  25606. private _depthOfFieldBlurY;
  25607. private _dofMerge;
  25608. /**
  25609. * Internal post processes in depth of field effect
  25610. */
  25611. _effects: Array<PostProcess>;
  25612. /**
  25613. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  25614. */
  25615. focalLength: number;
  25616. /**
  25617. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25618. */
  25619. fStop: number;
  25620. /**
  25621. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25622. */
  25623. focusDistance: number;
  25624. /**
  25625. * 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.
  25626. */
  25627. lensSize: number;
  25628. /**
  25629. * Creates a new instance DepthOfFieldEffect
  25630. * @param scene The scene the effect belongs to.
  25631. * @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.
  25632. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  25633. * @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)
  25634. */
  25635. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  25636. /**
  25637. * 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.
  25638. */
  25639. depthTexture: RenderTargetTexture;
  25640. /**
  25641. * Disposes each of the internal effects for a given camera.
  25642. * @param camera The camera to dispose the effect on.
  25643. */
  25644. disposeEffects(camera: Camera): void;
  25645. /**
  25646. * Internal
  25647. */
  25648. _updateEffects(): void;
  25649. /**
  25650. * Internal
  25651. * @returns if all the contained post processes are ready.
  25652. */
  25653. _isReady(): boolean;
  25654. }
  25655. }
  25656. declare module BABYLON {
  25657. /**
  25658. * Options to be set when merging outputs from the default pipeline.
  25659. */
  25660. class DepthOfFieldMergePostProcessOptions {
  25661. /**
  25662. * The original image to merge on top of
  25663. */
  25664. originalFromInput: PostProcess;
  25665. /**
  25666. * Parameters to perform the merge of the depth of field effect
  25667. */
  25668. depthOfField?: {
  25669. circleOfConfusion: PostProcess;
  25670. blurSteps: Array<PostProcess>;
  25671. };
  25672. /**
  25673. * Parameters to perform the merge of bloom effect
  25674. */
  25675. bloom?: {
  25676. blurred: PostProcess;
  25677. weight: number;
  25678. };
  25679. }
  25680. /**
  25681. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  25682. */
  25683. class DepthOfFieldMergePostProcess extends PostProcess {
  25684. private blurSteps;
  25685. /**
  25686. * Creates a new instance of DepthOfFieldMergePostProcess
  25687. * @param name The name of the effect.
  25688. * @param originalFromInput Post process which's input will be used for the merge.
  25689. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  25690. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  25691. * @param options The required width/height ratio to downsize to before computing the render pass.
  25692. * @param camera The camera to apply the render pass to.
  25693. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25694. * @param engine The engine which the post process will be applied. (default: current engine)
  25695. * @param reusable If the post process can be reused on the same frame. (default: false)
  25696. * @param textureType Type of textures used when performing the post process. (default: 0)
  25697. * @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)
  25698. */
  25699. 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);
  25700. /**
  25701. * Updates the effect with the current post process compile time values and recompiles the shader.
  25702. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25703. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25704. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25705. * @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
  25706. * @param onCompiled Called when the shader has been compiled.
  25707. * @param onError Called if there is an error when compiling a shader.
  25708. */
  25709. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25710. }
  25711. }
  25712. declare module BABYLON {
  25713. class DisplayPassPostProcess extends PostProcess {
  25714. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25715. }
  25716. }
  25717. declare module BABYLON {
  25718. /**
  25719. * 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.
  25720. */
  25721. class ExtractHighlightsPostProcess extends PostProcess {
  25722. /**
  25723. * The luminance threshold, pixels below this value will be set to black.
  25724. */
  25725. threshold: number;
  25726. /**
  25727. * Internal
  25728. */
  25729. _exposure: number;
  25730. /**
  25731. * Post process which has the input texture to be used when performing highlight extraction
  25732. */
  25733. _inputPostProcess: Nullable<PostProcess>;
  25734. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25735. }
  25736. }
  25737. declare module BABYLON {
  25738. class FilterPostProcess extends PostProcess {
  25739. kernelMatrix: Matrix;
  25740. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25741. }
  25742. }
  25743. declare module BABYLON {
  25744. class FxaaPostProcess extends PostProcess {
  25745. texelWidth: number;
  25746. texelHeight: number;
  25747. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25748. private _getDefines();
  25749. }
  25750. }
  25751. declare module BABYLON {
  25752. /**
  25753. * The GrainPostProcess adds noise to the image at mid luminance levels
  25754. */
  25755. class GrainPostProcess extends PostProcess {
  25756. /**
  25757. * The intensity of the grain added (default: 30)
  25758. */
  25759. intensity: number;
  25760. /**
  25761. * If the grain should be randomized on every frame
  25762. */
  25763. animated: boolean;
  25764. /**
  25765. * Creates a new instance of @see GrainPostProcess
  25766. * @param name The name of the effect.
  25767. * @param options The required width/height ratio to downsize to before computing the render pass.
  25768. * @param camera The camera to apply the render pass to.
  25769. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25770. * @param engine The engine which the post process will be applied. (default: current engine)
  25771. * @param reusable If the post process can be reused on the same frame. (default: false)
  25772. * @param textureType Type of textures used when performing the post process. (default: 0)
  25773. * @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)
  25774. */
  25775. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25776. }
  25777. }
  25778. declare module BABYLON {
  25779. class HighlightsPostProcess extends PostProcess {
  25780. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25781. }
  25782. }
  25783. declare module BABYLON {
  25784. class ImageProcessingPostProcess extends PostProcess {
  25785. /**
  25786. * Default configuration related to image processing available in the PBR Material.
  25787. */
  25788. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25789. /**
  25790. * Gets the image processing configuration used either in this material.
  25791. */
  25792. /**
  25793. * Sets the Default image processing configuration used either in the this material.
  25794. *
  25795. * If sets to null, the scene one is in use.
  25796. */
  25797. imageProcessingConfiguration: ImageProcessingConfiguration;
  25798. /**
  25799. * Keep track of the image processing observer to allow dispose and replace.
  25800. */
  25801. private _imageProcessingObserver;
  25802. /**
  25803. * Attaches a new image processing configuration to the PBR Material.
  25804. * @param configuration
  25805. */
  25806. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  25807. /**
  25808. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25809. */
  25810. /**
  25811. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25812. */
  25813. colorCurves: Nullable<ColorCurves>;
  25814. /**
  25815. * Gets wether the color curves effect is enabled.
  25816. */
  25817. /**
  25818. * Sets wether the color curves effect is enabled.
  25819. */
  25820. colorCurvesEnabled: boolean;
  25821. /**
  25822. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25823. */
  25824. /**
  25825. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25826. */
  25827. colorGradingTexture: Nullable<BaseTexture>;
  25828. /**
  25829. * Gets wether the color grading effect is enabled.
  25830. */
  25831. /**
  25832. * Gets wether the color grading effect is enabled.
  25833. */
  25834. colorGradingEnabled: boolean;
  25835. /**
  25836. * Gets exposure used in the effect.
  25837. */
  25838. /**
  25839. * Sets exposure used in the effect.
  25840. */
  25841. exposure: number;
  25842. /**
  25843. * Gets wether tonemapping is enabled or not.
  25844. */
  25845. /**
  25846. * Sets wether tonemapping is enabled or not
  25847. */
  25848. toneMappingEnabled: boolean;
  25849. /**
  25850. * Gets contrast used in the effect.
  25851. */
  25852. /**
  25853. * Sets contrast used in the effect.
  25854. */
  25855. contrast: number;
  25856. /**
  25857. * Gets Vignette stretch size.
  25858. */
  25859. /**
  25860. * Sets Vignette stretch size.
  25861. */
  25862. vignetteStretch: number;
  25863. /**
  25864. * Gets Vignette centre X Offset.
  25865. */
  25866. /**
  25867. * Sets Vignette centre X Offset.
  25868. */
  25869. vignetteCentreX: number;
  25870. /**
  25871. * Gets Vignette centre Y Offset.
  25872. */
  25873. /**
  25874. * Sets Vignette centre Y Offset.
  25875. */
  25876. vignetteCentreY: number;
  25877. /**
  25878. * Gets Vignette weight or intensity of the vignette effect.
  25879. */
  25880. /**
  25881. * Sets Vignette weight or intensity of the vignette effect.
  25882. */
  25883. vignetteWeight: number;
  25884. /**
  25885. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25886. * if vignetteEnabled is set to true.
  25887. */
  25888. /**
  25889. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25890. * if vignetteEnabled is set to true.
  25891. */
  25892. vignetteColor: Color4;
  25893. /**
  25894. * Gets Camera field of view used by the Vignette effect.
  25895. */
  25896. /**
  25897. * Sets Camera field of view used by the Vignette effect.
  25898. */
  25899. vignetteCameraFov: number;
  25900. /**
  25901. * Gets the vignette blend mode allowing different kind of effect.
  25902. */
  25903. /**
  25904. * Sets the vignette blend mode allowing different kind of effect.
  25905. */
  25906. vignetteBlendMode: number;
  25907. /**
  25908. * Gets wether the vignette effect is enabled.
  25909. */
  25910. /**
  25911. * Sets wether the vignette effect is enabled.
  25912. */
  25913. vignetteEnabled: boolean;
  25914. private _fromLinearSpace;
  25915. /**
  25916. * Gets wether the input of the processing is in Gamma or Linear Space.
  25917. */
  25918. /**
  25919. * Sets wether the input of the processing is in Gamma or Linear Space.
  25920. */
  25921. fromLinearSpace: boolean;
  25922. /**
  25923. * Defines cache preventing GC.
  25924. */
  25925. private _defines;
  25926. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25927. getClassName(): string;
  25928. protected _updateParameters(): void;
  25929. dispose(camera?: Camera): void;
  25930. }
  25931. }
  25932. declare module BABYLON {
  25933. class PassPostProcess extends PostProcess {
  25934. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25935. }
  25936. }
  25937. declare module BABYLON {
  25938. type PostProcessOptions = {
  25939. width: number;
  25940. height: number;
  25941. };
  25942. /**
  25943. * PostProcess can be used to apply a shader to a texture after it has been rendered
  25944. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  25945. */
  25946. class PostProcess {
  25947. /** Name of the PostProcess. */ name: string;
  25948. /**
  25949. * Width of the texture to apply the post process on
  25950. */
  25951. width: number;
  25952. /**
  25953. * Height of the texture to apply the post process on
  25954. */
  25955. height: number;
  25956. /**
  25957. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  25958. */
  25959. _outputTexture: Nullable<InternalTexture>;
  25960. /**
  25961. * Sampling mode used by the shader
  25962. * See https://doc.babylonjs.com/classes/3.1/texture
  25963. */
  25964. renderTargetSamplingMode: number;
  25965. /**
  25966. * Clear color to use when screen clearing
  25967. */
  25968. clearColor: Color4;
  25969. /**
  25970. * If the buffer needs to be cleared before applying the post process. (default: true)
  25971. * Should be set to false if shader will overwrite all previous pixels.
  25972. */
  25973. autoClear: boolean;
  25974. /**
  25975. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  25976. */
  25977. alphaMode: number;
  25978. /**
  25979. * Sets the setAlphaBlendConstants of the babylon engine
  25980. */
  25981. alphaConstants: Color4;
  25982. /**
  25983. * Animations to be used for the post processing
  25984. */
  25985. animations: Animation[];
  25986. /**
  25987. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  25988. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  25989. */
  25990. enablePixelPerfectMode: boolean;
  25991. /**
  25992. * Force the postprocess to be applied without taking in account viewport
  25993. */
  25994. forceFullscreenViewport: boolean;
  25995. /**
  25996. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  25997. */
  25998. scaleMode: number;
  25999. /**
  26000. * Force textures to be a power of two (default: false)
  26001. */
  26002. alwaysForcePOT: boolean;
  26003. /**
  26004. * Number of sample textures (default: 1)
  26005. */
  26006. samples: number;
  26007. /**
  26008. * Modify the scale of the post process to be the same as the viewport (default: false)
  26009. */
  26010. adaptScaleToCurrentViewport: boolean;
  26011. private _camera;
  26012. private _scene;
  26013. private _engine;
  26014. private _options;
  26015. private _reusable;
  26016. private _textureType;
  26017. /**
  26018. * Smart array of input and output textures for the post process.
  26019. */
  26020. _textures: SmartArray<InternalTexture>;
  26021. /**
  26022. * The index in _textures that corresponds to the output texture.
  26023. */
  26024. _currentRenderTextureInd: number;
  26025. private _effect;
  26026. private _samplers;
  26027. private _fragmentUrl;
  26028. private _vertexUrl;
  26029. private _parameters;
  26030. private _scaleRatio;
  26031. protected _indexParameters: any;
  26032. private _shareOutputWithPostProcess;
  26033. private _texelSize;
  26034. private _forcedOutputTexture;
  26035. /**
  26036. * An event triggered when the postprocess is activated.
  26037. */
  26038. onActivateObservable: Observable<Camera>;
  26039. private _onActivateObserver;
  26040. /**
  26041. * A function that is added to the onActivateObservable
  26042. */
  26043. onActivate: Nullable<(camera: Camera) => void>;
  26044. /**
  26045. * An event triggered when the postprocess changes its size.
  26046. */
  26047. onSizeChangedObservable: Observable<PostProcess>;
  26048. private _onSizeChangedObserver;
  26049. /**
  26050. * A function that is added to the onSizeChangedObservable
  26051. */
  26052. onSizeChanged: (postProcess: PostProcess) => void;
  26053. /**
  26054. * An event triggered when the postprocess applies its effect.
  26055. */
  26056. onApplyObservable: Observable<Effect>;
  26057. private _onApplyObserver;
  26058. /**
  26059. * A function that is added to the onApplyObservable
  26060. */
  26061. onApply: (effect: Effect) => void;
  26062. /**
  26063. * An event triggered before rendering the postprocess
  26064. */
  26065. onBeforeRenderObservable: Observable<Effect>;
  26066. private _onBeforeRenderObserver;
  26067. /**
  26068. * A function that is added to the onBeforeRenderObservable
  26069. */
  26070. onBeforeRender: (effect: Effect) => void;
  26071. /**
  26072. * An event triggered after rendering the postprocess
  26073. */
  26074. onAfterRenderObservable: Observable<Effect>;
  26075. private _onAfterRenderObserver;
  26076. /**
  26077. * A function that is added to the onAfterRenderObservable
  26078. */
  26079. onAfterRender: (efect: Effect) => void;
  26080. /**
  26081. * 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
  26082. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  26083. */
  26084. inputTexture: InternalTexture;
  26085. /**
  26086. * Gets the camera which post process is applied to.
  26087. * @returns The camera the post process is applied to.
  26088. */
  26089. getCamera(): Camera;
  26090. /**
  26091. * Gets the texel size of the postprocess.
  26092. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  26093. */
  26094. readonly texelSize: Vector2;
  26095. /**
  26096. * Creates a new instance PostProcess
  26097. * @param name The name of the PostProcess.
  26098. * @param fragmentUrl The url of the fragment shader to be used.
  26099. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  26100. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  26101. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  26102. * @param camera The camera to apply the render pass to.
  26103. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26104. * @param engine The engine which the post process will be applied. (default: current engine)
  26105. * @param reusable If the post process can be reused on the same frame. (default: false)
  26106. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  26107. * @param textureType Type of textures used when performing the post process. (default: 0)
  26108. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  26109. * @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
  26110. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  26111. */
  26112. 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);
  26113. /**
  26114. * Gets the engine which this post process belongs to.
  26115. * @returns The engine the post process was enabled with.
  26116. */
  26117. getEngine(): Engine;
  26118. /**
  26119. * The effect that is created when initializing the post process.
  26120. * @returns The created effect corrisponding the the postprocess.
  26121. */
  26122. getEffect(): Effect;
  26123. /**
  26124. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  26125. * @param postProcess The post process to share the output with.
  26126. * @returns This post process.
  26127. */
  26128. shareOutputWith(postProcess: PostProcess): PostProcess;
  26129. /**
  26130. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  26131. * This should be called if the post process that shares output with this post process is disabled/disposed.
  26132. */
  26133. useOwnOutput(): void;
  26134. /**
  26135. * Updates the effect with the current post process compile time values and recompiles the shader.
  26136. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26137. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26138. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26139. * @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
  26140. * @param onCompiled Called when the shader has been compiled.
  26141. * @param onError Called if there is an error when compiling a shader.
  26142. */
  26143. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26144. /**
  26145. * The post process is reusable if it can be used multiple times within one frame.
  26146. * @returns If the post process is reusable
  26147. */
  26148. isReusable(): boolean;
  26149. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  26150. markTextureDirty(): void;
  26151. /**
  26152. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  26153. * 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.
  26154. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  26155. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  26156. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  26157. * @returns The target texture that was bound to be written to.
  26158. */
  26159. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  26160. /**
  26161. * If the post process is supported.
  26162. */
  26163. readonly isSupported: boolean;
  26164. /**
  26165. * The aspect ratio of the output texture.
  26166. */
  26167. readonly aspectRatio: number;
  26168. /**
  26169. * Get a value indicating if the post-process is ready to be used
  26170. * @returns true if the post-process is ready (shader is compiled)
  26171. */
  26172. isReady(): boolean;
  26173. /**
  26174. * Binds all textures and uniforms to the shader, this will be run on every pass.
  26175. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  26176. */
  26177. apply(): Nullable<Effect>;
  26178. private _disposeTextures();
  26179. /**
  26180. * Disposes the post process.
  26181. * @param camera The camera to dispose the post process on.
  26182. */
  26183. dispose(camera?: Camera): void;
  26184. }
  26185. }
  26186. declare module BABYLON {
  26187. /**
  26188. * PostProcessManager is used to manage one or more post processes or post process pipelines
  26189. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  26190. */
  26191. class PostProcessManager {
  26192. private _scene;
  26193. private _indexBuffer;
  26194. private _vertexBuffers;
  26195. /**
  26196. * Creates a new instance PostProcess
  26197. * @param scene The scene that the post process is associated with.
  26198. */
  26199. constructor(scene: Scene);
  26200. private _prepareBuffers();
  26201. private _buildIndexBuffer();
  26202. /**
  26203. * Rebuilds the vertex buffers of the manager.
  26204. */
  26205. _rebuild(): void;
  26206. /**
  26207. * Prepares a frame to be run through a post process.
  26208. * @param sourceTexture The input texture to the post procesess. (default: null)
  26209. * @param postProcesses An array of post processes to be run. (default: null)
  26210. * @returns True if the post processes were able to be run.
  26211. */
  26212. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  26213. /**
  26214. * Manually render a set of post processes to a texture.
  26215. * @param postProcesses An array of post processes to be run.
  26216. * @param targetTexture The target texture to render to.
  26217. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  26218. */
  26219. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  26220. /**
  26221. * Finalize the result of the output of the postprocesses.
  26222. * @param doNotPresent If true the result will not be displayed to the screen.
  26223. * @param targetTexture The target texture to render to.
  26224. * @param faceIndex The index of the face to bind the target texture to.
  26225. * @param postProcesses The array of post processes to render.
  26226. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  26227. */
  26228. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  26229. /**
  26230. * Disposes of the post process manager.
  26231. */
  26232. dispose(): void;
  26233. }
  26234. }
  26235. declare module BABYLON {
  26236. class RefractionPostProcess extends PostProcess {
  26237. color: Color3;
  26238. depth: number;
  26239. colorLevel: number;
  26240. private _refTexture;
  26241. private _ownRefractionTexture;
  26242. /**
  26243. * Gets or sets the refraction texture
  26244. * Please note that you are responsible for disposing the texture if you set it manually
  26245. */
  26246. refractionTexture: Texture;
  26247. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26248. dispose(camera: Camera): void;
  26249. }
  26250. }
  26251. declare module BABYLON {
  26252. /**
  26253. * The SharpenPostProcess applies a sharpen kernel to every pixel
  26254. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  26255. */
  26256. class SharpenPostProcess extends PostProcess {
  26257. /**
  26258. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  26259. */
  26260. colorAmount: number;
  26261. /**
  26262. * How much sharpness should be applied (default: 0.3)
  26263. */
  26264. edgeAmount: number;
  26265. /**
  26266. * Creates a new instance ConvolutionPostProcess
  26267. * @param name The name of the effect.
  26268. * @param options The required width/height ratio to downsize to before computing the render pass.
  26269. * @param camera The camera to apply the render pass to.
  26270. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26271. * @param engine The engine which the post process will be applied. (default: current engine)
  26272. * @param reusable If the post process can be reused on the same frame. (default: false)
  26273. * @param textureType Type of textures used when performing the post process. (default: 0)
  26274. * @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)
  26275. */
  26276. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26277. }
  26278. }
  26279. declare module BABYLON {
  26280. class StereoscopicInterlacePostProcess extends PostProcess {
  26281. private _stepSize;
  26282. private _passedProcess;
  26283. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26284. }
  26285. }
  26286. declare module BABYLON {
  26287. /** Defines operator used for tonemapping */
  26288. enum TonemappingOperator {
  26289. /** Hable */
  26290. Hable = 0,
  26291. /** Reinhard */
  26292. Reinhard = 1,
  26293. /** HejiDawson */
  26294. HejiDawson = 2,
  26295. /** Photographic */
  26296. Photographic = 3,
  26297. }
  26298. /**
  26299. * Defines a post process to apply tone mapping
  26300. */
  26301. class TonemapPostProcess extends PostProcess {
  26302. private _operator;
  26303. /** Defines the required exposure adjustement */
  26304. exposureAdjustment: number;
  26305. /**
  26306. * Creates a new TonemapPostProcess
  26307. * @param name defines the name of the postprocess
  26308. * @param _operator defines the operator to use
  26309. * @param exposureAdjustment defines the required exposure adjustement
  26310. * @param camera defines the camera to use (can be null)
  26311. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  26312. * @param engine defines the hosting engine (can be ignore if camera is set)
  26313. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  26314. */
  26315. constructor(name: string, _operator: TonemappingOperator,
  26316. /** Defines the required exposure adjustement */
  26317. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  26318. }
  26319. }
  26320. declare module BABYLON {
  26321. class VolumetricLightScatteringPostProcess extends PostProcess {
  26322. private _volumetricLightScatteringPass;
  26323. private _volumetricLightScatteringRTT;
  26324. private _viewPort;
  26325. private _screenCoordinates;
  26326. private _cachedDefines;
  26327. /**
  26328. * If not undefined, the mesh position is computed from the attached node position
  26329. */
  26330. attachedNode: {
  26331. position: Vector3;
  26332. };
  26333. /**
  26334. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  26335. */
  26336. customMeshPosition: Vector3;
  26337. /**
  26338. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  26339. */
  26340. useCustomMeshPosition: boolean;
  26341. /**
  26342. * If the post-process should inverse the light scattering direction
  26343. */
  26344. invert: boolean;
  26345. /**
  26346. * The internal mesh used by the post-process
  26347. */
  26348. mesh: Mesh;
  26349. useDiffuseColor: boolean;
  26350. /**
  26351. * Array containing the excluded meshes not rendered in the internal pass
  26352. */
  26353. excludedMeshes: AbstractMesh[];
  26354. /**
  26355. * Controls the overall intensity of the post-process
  26356. */
  26357. exposure: number;
  26358. /**
  26359. * Dissipates each sample's contribution in range [0, 1]
  26360. */
  26361. decay: number;
  26362. /**
  26363. * Controls the overall intensity of each sample
  26364. */
  26365. weight: number;
  26366. /**
  26367. * Controls the density of each sample
  26368. */
  26369. density: number;
  26370. /**
  26371. * @constructor
  26372. * @param {string} name - The post-process name
  26373. * @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)
  26374. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  26375. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  26376. * @param {number} samples - The post-process quality, default 100
  26377. * @param {number} samplingMode - The post-process filtering mode
  26378. * @param {BABYLON.Engine} engine - The babylon engine
  26379. * @param {boolean} reusable - If the post-process is reusable
  26380. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  26381. */
  26382. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  26383. getClassName(): string;
  26384. private _isReady(subMesh, useInstances);
  26385. /**
  26386. * Sets the new light position for light scattering effect
  26387. * @param {BABYLON.Vector3} The new custom light position
  26388. */
  26389. setCustomMeshPosition(position: Vector3): void;
  26390. /**
  26391. * Returns the light position for light scattering effect
  26392. * @return {BABYLON.Vector3} The custom light position
  26393. */
  26394. getCustomMeshPosition(): Vector3;
  26395. /**
  26396. * Disposes the internal assets and detaches the post-process from the camera
  26397. */
  26398. dispose(camera: Camera): void;
  26399. /**
  26400. * Returns the render target texture used by the post-process
  26401. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  26402. */
  26403. getPass(): RenderTargetTexture;
  26404. private _meshExcluded(mesh);
  26405. private _createPass(scene, ratio);
  26406. private _updateMeshScreenCoordinates(scene);
  26407. /**
  26408. * Creates a default mesh for the Volumeric Light Scattering post-process
  26409. * @param {string} The mesh name
  26410. * @param {BABYLON.Scene} The scene where to create the mesh
  26411. * @return {BABYLON.Mesh} the default mesh
  26412. */
  26413. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  26414. }
  26415. }
  26416. declare module BABYLON {
  26417. class VRDistortionCorrectionPostProcess extends PostProcess {
  26418. private _isRightEye;
  26419. private _distortionFactors;
  26420. private _postProcessScaleFactor;
  26421. private _lensCenterOffset;
  26422. private _scaleIn;
  26423. private _scaleFactor;
  26424. private _lensCenter;
  26425. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  26426. }
  26427. }
  26428. declare module BABYLON {
  26429. /**
  26430. * @hidden
  26431. **/
  26432. class _AlphaState {
  26433. private _isAlphaBlendDirty;
  26434. private _isBlendFunctionParametersDirty;
  26435. private _isBlendEquationParametersDirty;
  26436. private _isBlendConstantsDirty;
  26437. private _alphaBlend;
  26438. private _blendFunctionParameters;
  26439. private _blendEquationParameters;
  26440. private _blendConstants;
  26441. /**
  26442. * Initializes the state.
  26443. */
  26444. constructor();
  26445. readonly isDirty: boolean;
  26446. alphaBlend: boolean;
  26447. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  26448. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  26449. setAlphaEquationParameters(rgb: number, alpha: number): void;
  26450. reset(): void;
  26451. apply(gl: WebGLRenderingContext): void;
  26452. }
  26453. }
  26454. declare module BABYLON {
  26455. /**
  26456. * @hidden
  26457. **/
  26458. class _DepthCullingState {
  26459. private _isDepthTestDirty;
  26460. private _isDepthMaskDirty;
  26461. private _isDepthFuncDirty;
  26462. private _isCullFaceDirty;
  26463. private _isCullDirty;
  26464. private _isZOffsetDirty;
  26465. private _isFrontFaceDirty;
  26466. private _depthTest;
  26467. private _depthMask;
  26468. private _depthFunc;
  26469. private _cull;
  26470. private _cullFace;
  26471. private _zOffset;
  26472. private _frontFace;
  26473. /**
  26474. * Initializes the state.
  26475. */
  26476. constructor();
  26477. readonly isDirty: boolean;
  26478. zOffset: number;
  26479. cullFace: Nullable<number>;
  26480. cull: Nullable<boolean>;
  26481. depthFunc: Nullable<number>;
  26482. depthMask: boolean;
  26483. depthTest: boolean;
  26484. frontFace: Nullable<number>;
  26485. reset(): void;
  26486. apply(gl: WebGLRenderingContext): void;
  26487. }
  26488. }
  26489. declare module BABYLON {
  26490. /**
  26491. * @hidden
  26492. **/
  26493. class _StencilState {
  26494. private _isStencilTestDirty;
  26495. private _isStencilMaskDirty;
  26496. private _isStencilFuncDirty;
  26497. private _isStencilOpDirty;
  26498. private _stencilTest;
  26499. private _stencilMask;
  26500. private _stencilFunc;
  26501. private _stencilFuncRef;
  26502. private _stencilFuncMask;
  26503. private _stencilOpStencilFail;
  26504. private _stencilOpDepthFail;
  26505. private _stencilOpStencilDepthPass;
  26506. readonly isDirty: boolean;
  26507. stencilFunc: number;
  26508. stencilFuncRef: number;
  26509. stencilFuncMask: number;
  26510. stencilOpStencilFail: number;
  26511. stencilOpDepthFail: number;
  26512. stencilOpStencilDepthPass: number;
  26513. stencilMask: number;
  26514. stencilTest: boolean;
  26515. constructor();
  26516. reset(): void;
  26517. apply(gl: WebGLRenderingContext): void;
  26518. }
  26519. }
  26520. declare module BABYLON {
  26521. /**
  26522. * Class used to evalaute queries containing `and` and `or` operators
  26523. */
  26524. class AndOrNotEvaluator {
  26525. /**
  26526. * Evaluate a query
  26527. * @param query defines the query to evaluate
  26528. * @param evaluateCallback defines the callback used to filter result
  26529. * @returns true if the query matches
  26530. */
  26531. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  26532. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  26533. private static _SimplifyNegation(booleanString);
  26534. }
  26535. }
  26536. declare module BABYLON {
  26537. /**
  26538. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  26539. */
  26540. enum AssetTaskState {
  26541. /**
  26542. * Initialization
  26543. */
  26544. INIT = 0,
  26545. /**
  26546. * Running
  26547. */
  26548. RUNNING = 1,
  26549. /**
  26550. * Done
  26551. */
  26552. DONE = 2,
  26553. /**
  26554. * Error
  26555. */
  26556. ERROR = 3,
  26557. }
  26558. /**
  26559. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  26560. */
  26561. abstract class AbstractAssetTask {
  26562. /**
  26563. * Task name
  26564. */ name: string;
  26565. /**
  26566. * Callback called when the task is successful
  26567. */
  26568. onSuccess: (task: any) => void;
  26569. /**
  26570. * Callback called when the task is not successful
  26571. */
  26572. onError: (task: any, message?: string, exception?: any) => void;
  26573. /**
  26574. * Creates a new {BABYLON.AssetsManager}
  26575. * @param name defines the name of the task
  26576. */
  26577. constructor(
  26578. /**
  26579. * Task name
  26580. */ name: string);
  26581. private _isCompleted;
  26582. private _taskState;
  26583. private _errorObject;
  26584. /**
  26585. * Get if the task is completed
  26586. */
  26587. readonly isCompleted: boolean;
  26588. /**
  26589. * Gets the current state of the task
  26590. */
  26591. readonly taskState: AssetTaskState;
  26592. /**
  26593. * Gets the current error object (if task is in error)
  26594. */
  26595. readonly errorObject: {
  26596. message?: string;
  26597. exception?: any;
  26598. };
  26599. /**
  26600. * Internal only
  26601. * @hidden
  26602. */
  26603. _setErrorObject(message?: string, exception?: any): void;
  26604. /**
  26605. * Execute the current task
  26606. * @param scene defines the scene where you want your assets to be loaded
  26607. * @param onSuccess is a callback called when the task is successfully executed
  26608. * @param onError is a callback called if an error occurs
  26609. */
  26610. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26611. /**
  26612. * Execute the current task
  26613. * @param scene defines the scene where you want your assets to be loaded
  26614. * @param onSuccess is a callback called when the task is successfully executed
  26615. * @param onError is a callback called if an error occurs
  26616. */
  26617. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26618. private onErrorCallback(onError, message?, exception?);
  26619. private onDoneCallback(onSuccess, onError);
  26620. }
  26621. /**
  26622. * Define the interface used by progress events raised during assets loading
  26623. */
  26624. interface IAssetsProgressEvent {
  26625. /**
  26626. * Defines the number of remaining tasks to process
  26627. */
  26628. remainingCount: number;
  26629. /**
  26630. * Defines the total number of tasks
  26631. */
  26632. totalCount: number;
  26633. /**
  26634. * Defines the task that was just processed
  26635. */
  26636. task: AbstractAssetTask;
  26637. }
  26638. /**
  26639. * Class used to share progress information about assets loading
  26640. */
  26641. class AssetsProgressEvent implements IAssetsProgressEvent {
  26642. /**
  26643. * Defines the number of remaining tasks to process
  26644. */
  26645. remainingCount: number;
  26646. /**
  26647. * Defines the total number of tasks
  26648. */
  26649. totalCount: number;
  26650. /**
  26651. * Defines the task that was just processed
  26652. */
  26653. task: AbstractAssetTask;
  26654. /**
  26655. * Creates a {BABYLON.AssetsProgressEvent}
  26656. * @param remainingCount defines the number of remaining tasks to process
  26657. * @param totalCount defines the total number of tasks
  26658. * @param task defines the task that was just processed
  26659. */
  26660. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  26661. }
  26662. /**
  26663. * Define a task used by {BABYLON.AssetsManager} to load meshes
  26664. */
  26665. class MeshAssetTask extends AbstractAssetTask {
  26666. /**
  26667. * Defines the name of the task
  26668. */
  26669. name: string;
  26670. /**
  26671. * Defines the list of mesh's names you want to load
  26672. */
  26673. meshesNames: any;
  26674. /**
  26675. * Defines the root url to use as a base to load your meshes and associated resources
  26676. */
  26677. rootUrl: string;
  26678. /**
  26679. * Defines the filename of the scene to load from
  26680. */
  26681. sceneFilename: string;
  26682. /**
  26683. * Gets the list of loaded meshes
  26684. */
  26685. loadedMeshes: Array<AbstractMesh>;
  26686. /**
  26687. * Gets the list of loaded particle systems
  26688. */
  26689. loadedParticleSystems: Array<ParticleSystem>;
  26690. /**
  26691. * Gets the list of loaded skeletons
  26692. */
  26693. loadedSkeletons: Array<Skeleton>;
  26694. /**
  26695. * Callback called when the task is successful
  26696. */
  26697. onSuccess: (task: MeshAssetTask) => void;
  26698. /**
  26699. * Callback called when the task is successful
  26700. */
  26701. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  26702. /**
  26703. * Creates a new {BABYLON.MeshAssetTask}
  26704. * @param name defines the name of the task
  26705. * @param meshesNames defines the list of mesh's names you want to load
  26706. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  26707. * @param sceneFilename defines the filename of the scene to load from
  26708. */
  26709. constructor(
  26710. /**
  26711. * Defines the name of the task
  26712. */
  26713. name: string,
  26714. /**
  26715. * Defines the list of mesh's names you want to load
  26716. */
  26717. meshesNames: any,
  26718. /**
  26719. * Defines the root url to use as a base to load your meshes and associated resources
  26720. */
  26721. rootUrl: string,
  26722. /**
  26723. * Defines the filename of the scene to load from
  26724. */
  26725. sceneFilename: string);
  26726. /**
  26727. * Execute the current task
  26728. * @param scene defines the scene where you want your assets to be loaded
  26729. * @param onSuccess is a callback called when the task is successfully executed
  26730. * @param onError is a callback called if an error occurs
  26731. */
  26732. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26733. }
  26734. /**
  26735. * Define a task used by {BABYLON.AssetsManager} to load text content
  26736. */
  26737. class TextFileAssetTask extends AbstractAssetTask {
  26738. /**
  26739. * Defines the name of the task
  26740. */
  26741. name: string;
  26742. /**
  26743. * Defines the location of the file to load
  26744. */
  26745. url: string;
  26746. /**
  26747. * Gets the loaded text string
  26748. */
  26749. text: string;
  26750. /**
  26751. * Callback called when the task is successful
  26752. */
  26753. onSuccess: (task: TextFileAssetTask) => void;
  26754. /**
  26755. * Callback called when the task is successful
  26756. */
  26757. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  26758. /**
  26759. * Creates a new TextFileAssetTask object
  26760. * @param name defines the name of the task
  26761. * @param url defines the location of the file to load
  26762. */
  26763. constructor(
  26764. /**
  26765. * Defines the name of the task
  26766. */
  26767. name: string,
  26768. /**
  26769. * Defines the location of the file to load
  26770. */
  26771. url: string);
  26772. /**
  26773. * Execute the current task
  26774. * @param scene defines the scene where you want your assets to be loaded
  26775. * @param onSuccess is a callback called when the task is successfully executed
  26776. * @param onError is a callback called if an error occurs
  26777. */
  26778. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26779. }
  26780. /**
  26781. * Define a task used by {BABYLON.AssetsManager} to load binary data
  26782. */
  26783. class BinaryFileAssetTask extends AbstractAssetTask {
  26784. /**
  26785. * Defines the name of the task
  26786. */
  26787. name: string;
  26788. /**
  26789. * Defines the location of the file to load
  26790. */
  26791. url: string;
  26792. /**
  26793. * Gets the lodaded data (as an array buffer)
  26794. */
  26795. data: ArrayBuffer;
  26796. /**
  26797. * Callback called when the task is successful
  26798. */
  26799. onSuccess: (task: BinaryFileAssetTask) => void;
  26800. /**
  26801. * Callback called when the task is successful
  26802. */
  26803. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  26804. /**
  26805. * Creates a new BinaryFileAssetTask object
  26806. * @param name defines the name of the new task
  26807. * @param url defines the location of the file to load
  26808. */
  26809. constructor(
  26810. /**
  26811. * Defines the name of the task
  26812. */
  26813. name: string,
  26814. /**
  26815. * Defines the location of the file to load
  26816. */
  26817. url: string);
  26818. /**
  26819. * Execute the current task
  26820. * @param scene defines the scene where you want your assets to be loaded
  26821. * @param onSuccess is a callback called when the task is successfully executed
  26822. * @param onError is a callback called if an error occurs
  26823. */
  26824. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26825. }
  26826. /**
  26827. * Define a task used by {BABYLON.AssetsManager} to load images
  26828. */
  26829. class ImageAssetTask extends AbstractAssetTask {
  26830. /**
  26831. * Defines the name of the task
  26832. */
  26833. name: string;
  26834. /**
  26835. * Defines the location of the image to load
  26836. */
  26837. url: string;
  26838. /**
  26839. * Gets the loaded images
  26840. */
  26841. image: HTMLImageElement;
  26842. /**
  26843. * Callback called when the task is successful
  26844. */
  26845. onSuccess: (task: ImageAssetTask) => void;
  26846. /**
  26847. * Callback called when the task is successful
  26848. */
  26849. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  26850. /**
  26851. * Creates a new ImageAssetTask
  26852. * @param name defines the name of the task
  26853. * @param url defines the location of the image to load
  26854. */
  26855. constructor(
  26856. /**
  26857. * Defines the name of the task
  26858. */
  26859. name: string,
  26860. /**
  26861. * Defines the location of the image to load
  26862. */
  26863. url: string);
  26864. /**
  26865. * Execute the current task
  26866. * @param scene defines the scene where you want your assets to be loaded
  26867. * @param onSuccess is a callback called when the task is successfully executed
  26868. * @param onError is a callback called if an error occurs
  26869. */
  26870. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26871. }
  26872. /**
  26873. * Defines the interface used by texture loading tasks
  26874. */
  26875. interface ITextureAssetTask<TEX extends BaseTexture> {
  26876. /**
  26877. * Gets the loaded texture
  26878. */
  26879. texture: TEX;
  26880. }
  26881. /**
  26882. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  26883. */
  26884. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  26885. /**
  26886. * Defines the name of the task
  26887. */
  26888. name: string;
  26889. /**
  26890. * Defines the location of the file to load
  26891. */
  26892. url: string;
  26893. /**
  26894. * Defines if mipmap should not be generated (default is false)
  26895. */
  26896. noMipmap: boolean | undefined;
  26897. /**
  26898. * Defines if texture must be inverted on Y axis (default is false)
  26899. */
  26900. invertY: boolean | undefined;
  26901. /**
  26902. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  26903. */
  26904. samplingMode: number;
  26905. /**
  26906. * Gets the loaded texture
  26907. */
  26908. texture: Texture;
  26909. /**
  26910. * Callback called when the task is successful
  26911. */
  26912. onSuccess: (task: TextureAssetTask) => void;
  26913. /**
  26914. * Callback called when the task is successful
  26915. */
  26916. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  26917. /**
  26918. * Creates a new TextureAssetTask object
  26919. * @param name defines the name of the task
  26920. * @param url defines the location of the file to load
  26921. * @param noMipmap defines if mipmap should not be generated (default is false)
  26922. * @param invertY defines if texture must be inverted on Y axis (default is false)
  26923. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  26924. */
  26925. constructor(
  26926. /**
  26927. * Defines the name of the task
  26928. */
  26929. name: string,
  26930. /**
  26931. * Defines the location of the file to load
  26932. */
  26933. url: string,
  26934. /**
  26935. * Defines if mipmap should not be generated (default is false)
  26936. */
  26937. noMipmap?: boolean | undefined,
  26938. /**
  26939. * Defines if texture must be inverted on Y axis (default is false)
  26940. */
  26941. invertY?: boolean | undefined,
  26942. /**
  26943. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  26944. */
  26945. samplingMode?: number);
  26946. /**
  26947. * Execute the current task
  26948. * @param scene defines the scene where you want your assets to be loaded
  26949. * @param onSuccess is a callback called when the task is successfully executed
  26950. * @param onError is a callback called if an error occurs
  26951. */
  26952. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26953. }
  26954. /**
  26955. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  26956. */
  26957. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  26958. /**
  26959. * Defines the name of the task
  26960. */
  26961. name: string;
  26962. /**
  26963. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  26964. */
  26965. url: string;
  26966. /**
  26967. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  26968. */
  26969. extensions: string[] | undefined;
  26970. /**
  26971. * Defines if mipmaps should not be generated (default is false)
  26972. */
  26973. noMipmap: boolean | undefined;
  26974. /**
  26975. * Defines the explicit list of files (undefined by default)
  26976. */
  26977. files: string[] | undefined;
  26978. /**
  26979. * Gets the loaded texture
  26980. */
  26981. texture: CubeTexture;
  26982. /**
  26983. * Callback called when the task is successful
  26984. */
  26985. onSuccess: (task: CubeTextureAssetTask) => void;
  26986. /**
  26987. * Callback called when the task is successful
  26988. */
  26989. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  26990. /**
  26991. * Creates a new CubeTextureAssetTask
  26992. * @param name defines the name of the task
  26993. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  26994. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  26995. * @param noMipmap defines if mipmaps should not be generated (default is false)
  26996. * @param files defines the explicit list of files (undefined by default)
  26997. */
  26998. constructor(
  26999. /**
  27000. * Defines the name of the task
  27001. */
  27002. name: string,
  27003. /**
  27004. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27005. */
  27006. url: string,
  27007. /**
  27008. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27009. */
  27010. extensions?: string[] | undefined,
  27011. /**
  27012. * Defines if mipmaps should not be generated (default is false)
  27013. */
  27014. noMipmap?: boolean | undefined,
  27015. /**
  27016. * Defines the explicit list of files (undefined by default)
  27017. */
  27018. files?: string[] | undefined);
  27019. /**
  27020. * Execute the current task
  27021. * @param scene defines the scene where you want your assets to be loaded
  27022. * @param onSuccess is a callback called when the task is successfully executed
  27023. * @param onError is a callback called if an error occurs
  27024. */
  27025. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27026. }
  27027. /**
  27028. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  27029. */
  27030. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  27031. /**
  27032. * Defines the name of the task
  27033. */
  27034. name: string;
  27035. /**
  27036. * Defines the location of the file to load
  27037. */
  27038. url: string;
  27039. /**
  27040. * Defines the desired size (the more it increases the longer the generation will be)
  27041. */
  27042. size: number;
  27043. /**
  27044. * Defines if mipmaps should not be generated (default is false)
  27045. */
  27046. noMipmap: boolean;
  27047. /**
  27048. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27049. */
  27050. generateHarmonics: boolean;
  27051. /**
  27052. * 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)
  27053. */
  27054. gammaSpace: boolean;
  27055. /**
  27056. * Internal Use Only
  27057. */
  27058. reserved: boolean;
  27059. /**
  27060. * Gets the loaded texture
  27061. */
  27062. texture: HDRCubeTexture;
  27063. /**
  27064. * Callback called when the task is successful
  27065. */
  27066. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  27067. /**
  27068. * Callback called when the task is successful
  27069. */
  27070. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  27071. /**
  27072. * Creates a new HDRCubeTextureAssetTask object
  27073. * @param name defines the name of the task
  27074. * @param url defines the location of the file to load
  27075. * @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.
  27076. * @param noMipmap defines if mipmaps should not be generated (default is false)
  27077. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27078. * @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)
  27079. * @param reserved Internal use only
  27080. */
  27081. constructor(
  27082. /**
  27083. * Defines the name of the task
  27084. */
  27085. name: string,
  27086. /**
  27087. * Defines the location of the file to load
  27088. */
  27089. url: string,
  27090. /**
  27091. * Defines the desired size (the more it increases the longer the generation will be)
  27092. */
  27093. size: number,
  27094. /**
  27095. * Defines if mipmaps should not be generated (default is false)
  27096. */
  27097. noMipmap?: boolean,
  27098. /**
  27099. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27100. */
  27101. generateHarmonics?: boolean,
  27102. /**
  27103. * 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)
  27104. */
  27105. gammaSpace?: boolean,
  27106. /**
  27107. * Internal Use Only
  27108. */
  27109. reserved?: boolean);
  27110. /**
  27111. * Execute the current task
  27112. * @param scene defines the scene where you want your assets to be loaded
  27113. * @param onSuccess is a callback called when the task is successfully executed
  27114. * @param onError is a callback called if an error occurs
  27115. */
  27116. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27117. }
  27118. /**
  27119. * This class can be used to easily import assets into a scene
  27120. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  27121. */
  27122. class AssetsManager {
  27123. private _scene;
  27124. private _isLoading;
  27125. protected _tasks: AbstractAssetTask[];
  27126. protected _waitingTasksCount: number;
  27127. protected _totalTasksCount: number;
  27128. /**
  27129. * Callback called when all tasks are processed
  27130. */
  27131. onFinish: (tasks: AbstractAssetTask[]) => void;
  27132. /**
  27133. * Callback called when a task is successful
  27134. */
  27135. onTaskSuccess: (task: AbstractAssetTask) => void;
  27136. /**
  27137. * Callback called when a task had an error
  27138. */
  27139. onTaskError: (task: AbstractAssetTask) => void;
  27140. /**
  27141. * Callback called when a task is done (whatever the result is)
  27142. */
  27143. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  27144. /**
  27145. * Observable called when all tasks are processed
  27146. */
  27147. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  27148. /**
  27149. * Observable called when a task had an error
  27150. */
  27151. onTaskErrorObservable: Observable<AbstractAssetTask>;
  27152. /**
  27153. * Observable called when a task is successful
  27154. */
  27155. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  27156. /**
  27157. * Observable called when a task is done (whatever the result is)
  27158. */
  27159. onProgressObservable: Observable<IAssetsProgressEvent>;
  27160. /**
  27161. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  27162. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27163. */
  27164. useDefaultLoadingScreen: boolean;
  27165. /**
  27166. * Creates a new AssetsManager
  27167. * @param scene defines the scene to work on
  27168. */
  27169. constructor(scene: Scene);
  27170. /**
  27171. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  27172. * @param taskName defines the name of the new task
  27173. * @param meshesNames defines the name of meshes to load
  27174. * @param rootUrl defines the root url to use to locate files
  27175. * @param sceneFilename defines the filename of the scene file
  27176. * @returns a new {BABYLON.MeshAssetTask} object
  27177. */
  27178. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  27179. /**
  27180. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  27181. * @param taskName defines the name of the new task
  27182. * @param url defines the url of the file to load
  27183. * @returns a new {BABYLON.TextFileAssetTask} object
  27184. */
  27185. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  27186. /**
  27187. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  27188. * @param taskName defines the name of the new task
  27189. * @param url defines the url of the file to load
  27190. * @returns a new {BABYLON.BinaryFileAssetTask} object
  27191. */
  27192. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  27193. /**
  27194. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  27195. * @param taskName defines the name of the new task
  27196. * @param url defines the url of the file to load
  27197. * @returns a new {BABYLON.ImageAssetTask} object
  27198. */
  27199. addImageTask(taskName: string, url: string): ImageAssetTask;
  27200. /**
  27201. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  27202. * @param taskName defines the name of the new task
  27203. * @param url defines the url of the file to load
  27204. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27205. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  27206. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  27207. * @returns a new {BABYLON.TextureAssetTask} object
  27208. */
  27209. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  27210. /**
  27211. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  27212. * @param taskName defines the name of the new task
  27213. * @param url defines the url of the file to load
  27214. * @param extensions defines the extension to use to load the cube map (can be null)
  27215. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27216. * @param files defines the list of files to load (can be null)
  27217. * @returns a new {BABYLON.CubeTextureAssetTask} object
  27218. */
  27219. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  27220. /**
  27221. *
  27222. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  27223. * @param taskName defines the name of the new task
  27224. * @param url defines the url of the file to load
  27225. * @param size defines the size you want for the cubemap (can be null)
  27226. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27227. * @param generateHarmonics defines if you want to automatically generate (true by default)
  27228. * @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)
  27229. * @param reserved Internal use only
  27230. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  27231. */
  27232. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  27233. private _decreaseWaitingTasksCount(task);
  27234. private _runTask(task);
  27235. /**
  27236. * Reset the {BABYLON.AssetsManager} and remove all tasks
  27237. * @return the current instance of the {BABYLON.AssetsManager}
  27238. */
  27239. reset(): AssetsManager;
  27240. /**
  27241. * Start the loading process
  27242. * @return the current instance of the {BABYLON.AssetsManager}
  27243. */
  27244. load(): AssetsManager;
  27245. }
  27246. }
  27247. declare module BABYLON {
  27248. /**
  27249. * Class used to enable access to IndexedDB
  27250. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  27251. */
  27252. class Database {
  27253. private callbackManifestChecked;
  27254. private currentSceneUrl;
  27255. private db;
  27256. private _enableSceneOffline;
  27257. private _enableTexturesOffline;
  27258. private manifestVersionFound;
  27259. private mustUpdateRessources;
  27260. private hasReachedQuota;
  27261. private isSupported;
  27262. private idbFactory;
  27263. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  27264. static IsUASupportingBlobStorage: boolean;
  27265. /** Gets a boolean indicating if Database storate is enabled */
  27266. static IDBStorageEnabled: boolean;
  27267. /**
  27268. * Gets a boolean indicating if scene must be saved in the database
  27269. */
  27270. readonly enableSceneOffline: boolean;
  27271. /**
  27272. * Gets a boolean indicating if textures must be saved in the database
  27273. */
  27274. readonly enableTexturesOffline: boolean;
  27275. /**
  27276. * Creates a new Database
  27277. * @param urlToScene defines the url to load the scene
  27278. * @param callbackManifestChecked defines the callback to use when manifest is checked
  27279. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  27280. */
  27281. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  27282. private static _ParseURL;
  27283. private static _ReturnFullUrlLocation;
  27284. private _checkManifestFile();
  27285. /**
  27286. * Open the database and make it available
  27287. * @param successCallback defines the callback to call on success
  27288. * @param errorCallback defines the callback to call on error
  27289. */
  27290. openAsync(successCallback: () => void, errorCallback: () => void): void;
  27291. /**
  27292. * Loads an image from the database
  27293. * @param url defines the url to load from
  27294. * @param image defines the target DOM image
  27295. */
  27296. loadImageFromDB(url: string, image: HTMLImageElement): void;
  27297. private _loadImageFromDBAsync(url, image, notInDBCallback);
  27298. private _saveImageIntoDBAsync(url, image);
  27299. private _checkVersionFromDB(url, versionLoaded);
  27300. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  27301. private _saveVersionIntoDBAsync(url, callback);
  27302. /**
  27303. * Loads a file from database
  27304. * @param url defines the URL to load from
  27305. * @param sceneLoaded defines a callback to call on success
  27306. * @param progressCallBack defines a callback to call when progress changed
  27307. * @param errorCallback defines a callback to call on error
  27308. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  27309. */
  27310. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  27311. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  27312. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  27313. }
  27314. }
  27315. declare module BABYLON {
  27316. interface DDSInfo {
  27317. width: number;
  27318. height: number;
  27319. mipmapCount: number;
  27320. isFourCC: boolean;
  27321. isRGB: boolean;
  27322. isLuminance: boolean;
  27323. isCube: boolean;
  27324. isCompressed: boolean;
  27325. dxgiFormat: number;
  27326. textureType: number;
  27327. /** Sphericle polynomial created for the dds texture */
  27328. sphericalPolynomial?: SphericalPolynomial;
  27329. }
  27330. class DDSTools {
  27331. static StoreLODInAlphaChannel: boolean;
  27332. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  27333. private static _FloatView;
  27334. private static _Int32View;
  27335. private static _ToHalfFloat(value);
  27336. private static _FromHalfFloat(value);
  27337. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27338. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27339. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27340. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27341. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27342. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  27343. private static _ExtractLongWordOrder(value);
  27344. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  27345. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  27346. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  27347. }
  27348. }
  27349. declare module BABYLON {
  27350. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27351. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27352. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27353. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27354. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27355. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27356. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27357. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27358. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27359. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27360. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27361. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27362. /**
  27363. * Decorator used to define property that can be serialized as reference to a camera
  27364. * @param sourceName defines the name of the property to decorate
  27365. */
  27366. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27367. class SerializationHelper {
  27368. static Serialize<T>(entity: T, serializationObject?: any): any;
  27369. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27370. static Clone<T>(creationFunction: () => T, source: T): T;
  27371. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27372. }
  27373. }
  27374. declare module BABYLON {
  27375. /**
  27376. * Wrapper class for promise with external resolve and reject.
  27377. */
  27378. class Deferred<T> {
  27379. /**
  27380. * The promise associated with this deferred object.
  27381. */
  27382. readonly promise: Promise<T>;
  27383. private _resolve;
  27384. private _reject;
  27385. /**
  27386. * The resolve method of the promise associated with this deferred object.
  27387. */
  27388. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  27389. /**
  27390. * The reject method of the promise associated with this deferred object.
  27391. */
  27392. readonly reject: (reason?: any) => void;
  27393. /**
  27394. * Constructor for this deferred object.
  27395. */
  27396. constructor();
  27397. }
  27398. }
  27399. declare module BABYLON {
  27400. class FilesInput {
  27401. static FilesToLoad: {
  27402. [key: string]: File;
  27403. };
  27404. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  27405. private _engine;
  27406. private _currentScene;
  27407. private _sceneLoadedCallback;
  27408. private _progressCallback;
  27409. private _additionalRenderLoopLogicCallback;
  27410. private _textureLoadingCallback;
  27411. private _startingProcessingFilesCallback;
  27412. private _onReloadCallback;
  27413. private _errorCallback;
  27414. private _elementToMonitor;
  27415. private _sceneFileToLoad;
  27416. private _filesToLoad;
  27417. 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);
  27418. private _dragEnterHandler;
  27419. private _dragOverHandler;
  27420. private _dropHandler;
  27421. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  27422. dispose(): void;
  27423. private renderFunction();
  27424. private drag(e);
  27425. private drop(eventDrop);
  27426. private _traverseFolder(folder, files, remaining, callback);
  27427. private _processFiles(files);
  27428. loadFiles(event: any): void;
  27429. private _processReload();
  27430. reload(): void;
  27431. }
  27432. }
  27433. declare module BABYLON {
  27434. /**
  27435. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  27436. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  27437. */
  27438. class KhronosTextureContainer {
  27439. arrayBuffer: any;
  27440. static HEADER_LEN: number;
  27441. static COMPRESSED_2D: number;
  27442. static COMPRESSED_3D: number;
  27443. static TEX_2D: number;
  27444. static TEX_3D: number;
  27445. glType: number;
  27446. glTypeSize: number;
  27447. glFormat: number;
  27448. glInternalFormat: number;
  27449. glBaseInternalFormat: number;
  27450. pixelWidth: number;
  27451. pixelHeight: number;
  27452. pixelDepth: number;
  27453. numberOfArrayElements: number;
  27454. numberOfFaces: number;
  27455. numberOfMipmapLevels: number;
  27456. bytesOfKeyValueData: number;
  27457. loadType: number;
  27458. /**
  27459. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  27460. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  27461. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  27462. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  27463. */
  27464. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  27465. switchEndainness(val: number): number;
  27466. /**
  27467. * It is assumed that the texture has already been created & is currently bound
  27468. */
  27469. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  27470. private _upload2DCompressedLevels(gl, loadMipmaps);
  27471. }
  27472. }
  27473. declare module BABYLON {
  27474. /**
  27475. * A class serves as a medium between the observable and its observers
  27476. */
  27477. class EventState {
  27478. /**
  27479. * Create a new EventState
  27480. * @param mask defines the mask associated with this state
  27481. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  27482. * @param target defines the original target of the state
  27483. * @param currentTarget defines the current target of the state
  27484. */
  27485. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  27486. /**
  27487. * Initialize the current event state
  27488. * @param mask defines the mask associated with this state
  27489. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  27490. * @param target defines the original target of the state
  27491. * @param currentTarget defines the current target of the state
  27492. * @returns the current event state
  27493. */
  27494. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  27495. /**
  27496. * An Observer can set this property to true to prevent subsequent observers of being notified
  27497. */
  27498. skipNextObservers: boolean;
  27499. /**
  27500. * Get the mask value that were used to trigger the event corresponding to this EventState object
  27501. */
  27502. mask: number;
  27503. /**
  27504. * The object that originally notified the event
  27505. */
  27506. target?: any;
  27507. /**
  27508. * The current object in the bubbling phase
  27509. */
  27510. currentTarget?: any;
  27511. /**
  27512. * This will be populated with the return value of the last function that was executed.
  27513. * If it is the first function in the callback chain it will be the event data.
  27514. */
  27515. lastReturnValue?: any;
  27516. }
  27517. /**
  27518. * Represent an Observer registered to a given Observable object.
  27519. */
  27520. class Observer<T> {
  27521. /**
  27522. * Defines the callback to call when the observer is notified
  27523. */
  27524. callback: (eventData: T, eventState: EventState) => void;
  27525. /**
  27526. * Defines the mask of the observer (used to filter notifications)
  27527. */
  27528. mask: number;
  27529. /**
  27530. * Defines the current scope used to restore the JS context
  27531. */
  27532. scope: any;
  27533. /** @hidden */
  27534. _willBeUnregistered: boolean;
  27535. /**
  27536. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  27537. */
  27538. unregisterOnNextCall: boolean;
  27539. /**
  27540. * Creates a new observer
  27541. * @param callback defines the callback to call when the observer is notified
  27542. * @param mask defines the mask of the observer (used to filter notifications)
  27543. * @param scope defines the current scope used to restore the JS context
  27544. */
  27545. constructor(
  27546. /**
  27547. * Defines the callback to call when the observer is notified
  27548. */
  27549. callback: (eventData: T, eventState: EventState) => void,
  27550. /**
  27551. * Defines the mask of the observer (used to filter notifications)
  27552. */
  27553. mask: number,
  27554. /**
  27555. * Defines the current scope used to restore the JS context
  27556. */
  27557. scope?: any);
  27558. }
  27559. /**
  27560. * Represent a list of observers registered to multiple Observables object.
  27561. */
  27562. class MultiObserver<T> {
  27563. private _observers;
  27564. private _observables;
  27565. /**
  27566. * Release associated resources
  27567. */
  27568. dispose(): void;
  27569. /**
  27570. * Raise a callback when one of the observable will notify
  27571. * @param observables defines a list of observables to watch
  27572. * @param callback defines the callback to call on notification
  27573. * @param mask defines the mask used to filter notifications
  27574. * @param scope defines the current scope used to restore the JS context
  27575. * @returns the new MultiObserver
  27576. */
  27577. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  27578. }
  27579. /**
  27580. * The Observable class is a simple implementation of the Observable pattern.
  27581. *
  27582. * 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.
  27583. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  27584. * 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).
  27585. * 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.
  27586. */
  27587. class Observable<T> {
  27588. private _observers;
  27589. private _eventState;
  27590. private _onObserverAdded;
  27591. /**
  27592. * Creates a new observable
  27593. * @param onObserverAdded defines a callback to call when a new observer is added
  27594. */
  27595. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  27596. /**
  27597. * Create a new Observer with the specified callback
  27598. * @param callback the callback that will be executed for that Observer
  27599. * @param mask the mask used to filter observers
  27600. * @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.
  27601. * @param scope optional scope for the callback to be called from
  27602. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  27603. * @returns the new observer created for the callback
  27604. */
  27605. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  27606. /**
  27607. * Remove an Observer from the Observable object
  27608. * @param observer the instance of the Observer to remove
  27609. * @returns false if it doesn't belong to this Observable
  27610. */
  27611. remove(observer: Nullable<Observer<T>>): boolean;
  27612. /**
  27613. * Remove a callback from the Observable object
  27614. * @param callback the callback to remove
  27615. * @param scope optional scope. If used only the callbacks with this scope will be removed
  27616. * @returns false if it doesn't belong to this Observable
  27617. */
  27618. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  27619. private _deferUnregister(observer);
  27620. /**
  27621. * Notify all Observers by calling their respective callback with the given data
  27622. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  27623. * @param eventData defines the data to send to all observers
  27624. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  27625. * @param target defines the original target of the state
  27626. * @param currentTarget defines the current target of the state
  27627. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  27628. */
  27629. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  27630. /**
  27631. * Calling this will execute each callback, expecting it to be a promise or return a value.
  27632. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  27633. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  27634. * and it is crucial that all callbacks will be executed.
  27635. * The order of the callbacks is kept, callbacks are not executed parallel.
  27636. *
  27637. * @param eventData The data to be sent to each callback
  27638. * @param mask is used to filter observers defaults to -1
  27639. * @param target defines the callback target (see EventState)
  27640. * @param currentTarget defines he current object in the bubbling phase
  27641. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  27642. */
  27643. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  27644. /**
  27645. * Notify a specific observer
  27646. * @param observer defines the observer to notify
  27647. * @param eventData defines the data to be sent to each callback
  27648. * @param mask is used to filter observers defaults to -1
  27649. */
  27650. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  27651. /**
  27652. * Gets a boolean indicating if the observable has at least one observer
  27653. * @returns true is the Observable has at least one Observer registered
  27654. */
  27655. hasObservers(): boolean;
  27656. /**
  27657. * Clear the list of observers
  27658. */
  27659. clear(): void;
  27660. /**
  27661. * Clone the current observable
  27662. * @returns a new observable
  27663. */
  27664. clone(): Observable<T>;
  27665. /**
  27666. * Does this observable handles observer registered with a given mask
  27667. * @param mask defines the mask to be tested
  27668. * @return whether or not one observer registered with the given mask is handeled
  27669. **/
  27670. hasSpecificMask(mask?: number): boolean;
  27671. }
  27672. }
  27673. declare module BABYLON {
  27674. /**
  27675. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  27676. */
  27677. class PerformanceMonitor {
  27678. private _enabled;
  27679. private _rollingFrameTime;
  27680. private _lastFrameTimeMs;
  27681. /**
  27682. * constructor
  27683. * @param frameSampleSize The number of samples required to saturate the sliding window
  27684. */
  27685. constructor(frameSampleSize?: number);
  27686. /**
  27687. * Samples current frame
  27688. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  27689. */
  27690. sampleFrame(timeMs?: number): void;
  27691. /**
  27692. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  27693. * @return Average frame time in milliseconds
  27694. */
  27695. readonly averageFrameTime: number;
  27696. /**
  27697. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  27698. * @return Frame time variance in milliseconds squared
  27699. */
  27700. readonly averageFrameTimeVariance: number;
  27701. /**
  27702. * Returns the frame time of the most recent frame
  27703. * @return Frame time in milliseconds
  27704. */
  27705. readonly instantaneousFrameTime: number;
  27706. /**
  27707. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  27708. * @return Framerate in frames per second
  27709. */
  27710. readonly averageFPS: number;
  27711. /**
  27712. * Returns the average framerate in frames per second using the most recent frame time
  27713. * @return Framerate in frames per second
  27714. */
  27715. readonly instantaneousFPS: number;
  27716. /**
  27717. * Returns true if enough samples have been taken to completely fill the sliding window
  27718. * @return true if saturated
  27719. */
  27720. readonly isSaturated: boolean;
  27721. /**
  27722. * Enables contributions to the sliding window sample set
  27723. */
  27724. enable(): void;
  27725. /**
  27726. * Disables contributions to the sliding window sample set
  27727. * Samples will not be interpolated over the disabled period
  27728. */
  27729. disable(): void;
  27730. /**
  27731. * Returns true if sampling is enabled
  27732. * @return true if enabled
  27733. */
  27734. readonly isEnabled: boolean;
  27735. /**
  27736. * Resets performance monitor
  27737. */
  27738. reset(): void;
  27739. }
  27740. /**
  27741. * RollingAverage
  27742. *
  27743. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  27744. */
  27745. class RollingAverage {
  27746. /**
  27747. * Current average
  27748. */
  27749. average: number;
  27750. /**
  27751. * Current variance
  27752. */
  27753. variance: number;
  27754. protected _samples: Array<number>;
  27755. protected _sampleCount: number;
  27756. protected _pos: number;
  27757. protected _m2: number;
  27758. /**
  27759. * constructor
  27760. * @param length The number of samples required to saturate the sliding window
  27761. */
  27762. constructor(length: number);
  27763. /**
  27764. * Adds a sample to the sample set
  27765. * @param v The sample value
  27766. */
  27767. add(v: number): void;
  27768. /**
  27769. * Returns previously added values or null if outside of history or outside the sliding window domain
  27770. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  27771. * @return Value previously recorded with add() or null if outside of range
  27772. */
  27773. history(i: number): number;
  27774. /**
  27775. * Returns true if enough samples have been taken to completely fill the sliding window
  27776. * @return true if sample-set saturated
  27777. */
  27778. isSaturated(): boolean;
  27779. /**
  27780. * Resets the rolling average (equivalent to 0 samples taken so far)
  27781. */
  27782. reset(): void;
  27783. /**
  27784. * Wraps a value around the sample range boundaries
  27785. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  27786. * @return Wrapped position in sample range
  27787. */
  27788. protected _wrapPosition(i: number): number;
  27789. }
  27790. }
  27791. declare module BABYLON {
  27792. /**
  27793. * Helper class that provides a small promise polyfill
  27794. */
  27795. class PromisePolyfill {
  27796. /**
  27797. * Static function used to check if the polyfill is required
  27798. * If this is the case then the function will inject the polyfill to window.Promise
  27799. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  27800. */
  27801. static Apply(force?: boolean): void;
  27802. }
  27803. }
  27804. declare module BABYLON {
  27805. /**
  27806. * Defines the root class used to create scene optimization to use with SceneOptimizer
  27807. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27808. */
  27809. class SceneOptimization {
  27810. /**
  27811. * Defines the priority of this optimization (0 by default which means first in the list)
  27812. */
  27813. priority: number;
  27814. /**
  27815. * Gets a string describing the action executed by the current optimization
  27816. * @returns description string
  27817. */
  27818. getDescription(): string;
  27819. /**
  27820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27821. * @param scene defines the current scene where to apply this optimization
  27822. * @param optimizer defines the current optimizer
  27823. * @returns true if everything that can be done was applied
  27824. */
  27825. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27826. /**
  27827. * Creates the SceneOptimization object
  27828. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  27829. * @param desc defines the description associated with the optimization
  27830. */
  27831. constructor(
  27832. /**
  27833. * Defines the priority of this optimization (0 by default which means first in the list)
  27834. */
  27835. priority?: number);
  27836. }
  27837. /**
  27838. * Defines an optimization used to reduce the size of render target textures
  27839. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27840. */
  27841. class TextureOptimization extends SceneOptimization {
  27842. /**
  27843. * Defines the priority of this optimization (0 by default which means first in the list)
  27844. */
  27845. priority: number;
  27846. /**
  27847. * 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
  27848. */
  27849. maximumSize: number;
  27850. /**
  27851. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  27852. */
  27853. step: number;
  27854. /**
  27855. * Gets a string describing the action executed by the current optimization
  27856. * @returns description string
  27857. */
  27858. getDescription(): string;
  27859. /**
  27860. * Creates the TextureOptimization object
  27861. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  27862. * @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
  27863. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  27864. */
  27865. constructor(
  27866. /**
  27867. * Defines the priority of this optimization (0 by default which means first in the list)
  27868. */
  27869. priority?: number,
  27870. /**
  27871. * 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
  27872. */
  27873. maximumSize?: number,
  27874. /**
  27875. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  27876. */
  27877. step?: number);
  27878. /**
  27879. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27880. * @param scene defines the current scene where to apply this optimization
  27881. * @param optimizer defines the current optimizer
  27882. * @returns true if everything that can be done was applied
  27883. */
  27884. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27885. }
  27886. /**
  27887. * Defines an optimization used to increase or decrease the rendering resolution
  27888. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27889. */
  27890. class HardwareScalingOptimization extends SceneOptimization {
  27891. /**
  27892. * Defines the priority of this optimization (0 by default which means first in the list)
  27893. */
  27894. priority: number;
  27895. /**
  27896. * Defines the maximum scale to use (2 by default)
  27897. */
  27898. maximumScale: number;
  27899. /**
  27900. * Defines the step to use between two passes (0.5 by default)
  27901. */
  27902. step: number;
  27903. private _currentScale;
  27904. private _directionOffset;
  27905. /**
  27906. * Gets a string describing the action executed by the current optimization
  27907. * @return description string
  27908. */
  27909. getDescription(): string;
  27910. /**
  27911. * Creates the HardwareScalingOptimization object
  27912. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  27913. * @param maximumScale defines the maximum scale to use (2 by default)
  27914. * @param step defines the step to use between two passes (0.5 by default)
  27915. */
  27916. constructor(
  27917. /**
  27918. * Defines the priority of this optimization (0 by default which means first in the list)
  27919. */
  27920. priority?: number,
  27921. /**
  27922. * Defines the maximum scale to use (2 by default)
  27923. */
  27924. maximumScale?: number,
  27925. /**
  27926. * Defines the step to use between two passes (0.5 by default)
  27927. */
  27928. step?: number);
  27929. /**
  27930. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27931. * @param scene defines the current scene where to apply this optimization
  27932. * @param optimizer defines the current optimizer
  27933. * @returns true if everything that can be done was applied
  27934. */
  27935. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27936. }
  27937. /**
  27938. * Defines an optimization used to remove shadows
  27939. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27940. */
  27941. class ShadowsOptimization extends SceneOptimization {
  27942. /**
  27943. * Gets a string describing the action executed by the current optimization
  27944. * @return description string
  27945. */
  27946. getDescription(): string;
  27947. /**
  27948. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27949. * @param scene defines the current scene where to apply this optimization
  27950. * @param optimizer defines the current optimizer
  27951. * @returns true if everything that can be done was applied
  27952. */
  27953. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27954. }
  27955. /**
  27956. * Defines an optimization used to turn post-processes off
  27957. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27958. */
  27959. class PostProcessesOptimization extends SceneOptimization {
  27960. /**
  27961. * Gets a string describing the action executed by the current optimization
  27962. * @return description string
  27963. */
  27964. getDescription(): string;
  27965. /**
  27966. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27967. * @param scene defines the current scene where to apply this optimization
  27968. * @param optimizer defines the current optimizer
  27969. * @returns true if everything that can be done was applied
  27970. */
  27971. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27972. }
  27973. /**
  27974. * Defines an optimization used to turn lens flares off
  27975. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27976. */
  27977. class LensFlaresOptimization extends SceneOptimization {
  27978. /**
  27979. * Gets a string describing the action executed by the current optimization
  27980. * @return description string
  27981. */
  27982. getDescription(): string;
  27983. /**
  27984. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27985. * @param scene defines the current scene where to apply this optimization
  27986. * @param optimizer defines the current optimizer
  27987. * @returns true if everything that can be done was applied
  27988. */
  27989. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27990. }
  27991. /**
  27992. * Defines an optimization based on user defined callback.
  27993. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27994. */
  27995. class CustomOptimization extends SceneOptimization {
  27996. /**
  27997. * Callback called to apply the custom optimization.
  27998. */
  27999. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  28000. /**
  28001. * Callback called to get custom description
  28002. */
  28003. onGetDescription: () => string;
  28004. /**
  28005. * Gets a string describing the action executed by the current optimization
  28006. * @returns description string
  28007. */
  28008. getDescription(): string;
  28009. /**
  28010. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28011. * @param scene defines the current scene where to apply this optimization
  28012. * @param optimizer defines the current optimizer
  28013. * @returns true if everything that can be done was applied
  28014. */
  28015. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28016. }
  28017. /**
  28018. * Defines an optimization used to turn particles off
  28019. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28020. */
  28021. class ParticlesOptimization extends SceneOptimization {
  28022. /**
  28023. * Gets a string describing the action executed by the current optimization
  28024. * @return description string
  28025. */
  28026. getDescription(): string;
  28027. /**
  28028. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28029. * @param scene defines the current scene where to apply this optimization
  28030. * @param optimizer defines the current optimizer
  28031. * @returns true if everything that can be done was applied
  28032. */
  28033. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28034. }
  28035. /**
  28036. * Defines an optimization used to turn render targets off
  28037. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28038. */
  28039. class RenderTargetsOptimization extends SceneOptimization {
  28040. /**
  28041. * Gets a string describing the action executed by the current optimization
  28042. * @return description string
  28043. */
  28044. getDescription(): string;
  28045. /**
  28046. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28047. * @param scene defines the current scene where to apply this optimization
  28048. * @param optimizer defines the current optimizer
  28049. * @returns true if everything that can be done was applied
  28050. */
  28051. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28052. }
  28053. /**
  28054. * Defines an optimization used to merge meshes with compatible materials
  28055. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28056. */
  28057. class MergeMeshesOptimization extends SceneOptimization {
  28058. private static _UpdateSelectionTree;
  28059. /**
  28060. * Gets or sets a boolean which defines if optimization octree has to be updated
  28061. */
  28062. /**
  28063. * Gets or sets a boolean which defines if optimization octree has to be updated
  28064. */
  28065. static UpdateSelectionTree: boolean;
  28066. /**
  28067. * Gets a string describing the action executed by the current optimization
  28068. * @return description string
  28069. */
  28070. getDescription(): string;
  28071. private _canBeMerged;
  28072. /**
  28073. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28074. * @param scene defines the current scene where to apply this optimization
  28075. * @param optimizer defines the current optimizer
  28076. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  28077. * @returns true if everything that can be done was applied
  28078. */
  28079. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  28080. }
  28081. /**
  28082. * Defines a list of options used by SceneOptimizer
  28083. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28084. */
  28085. class SceneOptimizerOptions {
  28086. /**
  28087. * Defines the target frame rate to reach (60 by default)
  28088. */
  28089. targetFrameRate: number;
  28090. /**
  28091. * Defines the interval between two checkes (2000ms by default)
  28092. */
  28093. trackerDuration: number;
  28094. /**
  28095. * Gets the list of optimizations to apply
  28096. */
  28097. optimizations: SceneOptimization[];
  28098. /**
  28099. * Creates a new list of options used by SceneOptimizer
  28100. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  28101. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  28102. */
  28103. constructor(
  28104. /**
  28105. * Defines the target frame rate to reach (60 by default)
  28106. */
  28107. targetFrameRate?: number,
  28108. /**
  28109. * Defines the interval between two checkes (2000ms by default)
  28110. */
  28111. trackerDuration?: number);
  28112. /**
  28113. * Add a new optimization
  28114. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  28115. * @returns the current SceneOptimizerOptions
  28116. */
  28117. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  28118. /**
  28119. * Add a new custom optimization
  28120. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  28121. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  28122. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28123. * @returns the current SceneOptimizerOptions
  28124. */
  28125. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  28126. /**
  28127. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  28128. * @param targetFrameRate defines the target frame rate (60 by default)
  28129. * @returns a SceneOptimizerOptions object
  28130. */
  28131. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28132. /**
  28133. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  28134. * @param targetFrameRate defines the target frame rate (60 by default)
  28135. * @returns a SceneOptimizerOptions object
  28136. */
  28137. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28138. /**
  28139. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  28140. * @param targetFrameRate defines the target frame rate (60 by default)
  28141. * @returns a SceneOptimizerOptions object
  28142. */
  28143. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28144. }
  28145. /**
  28146. * Class used to run optimizations in order to reach a target frame rate
  28147. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28148. */
  28149. class SceneOptimizer implements IDisposable {
  28150. private _isRunning;
  28151. private _options;
  28152. private _scene;
  28153. private _currentPriorityLevel;
  28154. private _targetFrameRate;
  28155. private _trackerDuration;
  28156. private _currentFrameRate;
  28157. private _sceneDisposeObserver;
  28158. private _improvementMode;
  28159. /**
  28160. * Defines an observable called when the optimizer reaches the target frame rate
  28161. */
  28162. onSuccessObservable: Observable<SceneOptimizer>;
  28163. /**
  28164. * Defines an observable called when the optimizer enables an optimization
  28165. */
  28166. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  28167. /**
  28168. * Defines an observable called when the optimizer is not able to reach the target frame rate
  28169. */
  28170. onFailureObservable: Observable<SceneOptimizer>;
  28171. /**
  28172. * Gets a boolean indicating if the optimizer is in improvement mode
  28173. */
  28174. readonly isInImprovementMode: boolean;
  28175. /**
  28176. * Gets the current priority level (0 at start)
  28177. */
  28178. readonly currentPriorityLevel: number;
  28179. /**
  28180. * Gets the current frame rate checked by the SceneOptimizer
  28181. */
  28182. readonly currentFrameRate: number;
  28183. /**
  28184. * Gets or sets the current target frame rate (60 by default)
  28185. */
  28186. /**
  28187. * Gets or sets the current target frame rate (60 by default)
  28188. */
  28189. targetFrameRate: number;
  28190. /**
  28191. * Gets or sets the current interval between two checks (every 2000ms by default)
  28192. */
  28193. /**
  28194. * Gets or sets the current interval between two checks (every 2000ms by default)
  28195. */
  28196. trackerDuration: number;
  28197. /**
  28198. * Gets the list of active optimizations
  28199. */
  28200. readonly optimizations: SceneOptimization[];
  28201. /**
  28202. * Creates a new SceneOptimizer
  28203. * @param scene defines the scene to work on
  28204. * @param options defines the options to use with the SceneOptimizer
  28205. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  28206. * @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)
  28207. */
  28208. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  28209. /**
  28210. * Stops the current optimizer
  28211. */
  28212. stop(): void;
  28213. /**
  28214. * Reset the optimizer to initial step (current priority level = 0)
  28215. */
  28216. reset(): void;
  28217. /**
  28218. * Start the optimizer. By default it will try to reach a specific framerate
  28219. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  28220. */
  28221. start(): void;
  28222. private _checkCurrentState();
  28223. /**
  28224. * Release all resources
  28225. */
  28226. dispose(): void;
  28227. /**
  28228. * Helper function to create a SceneOptimizer with one single line of code
  28229. * @param scene defines the scene to work on
  28230. * @param options defines the options to use with the SceneOptimizer
  28231. * @param onSuccess defines a callback to call on success
  28232. * @param onFailure defines a callback to call on failure
  28233. * @returns the new SceneOptimizer object
  28234. */
  28235. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  28236. }
  28237. }
  28238. declare module BABYLON {
  28239. class SceneSerializer {
  28240. static ClearCache(): void;
  28241. static Serialize(scene: Scene): any;
  28242. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  28243. }
  28244. }
  28245. declare module BABYLON {
  28246. class SmartArray<T> {
  28247. data: Array<T>;
  28248. length: number;
  28249. protected _id: number;
  28250. [index: number]: T;
  28251. constructor(capacity: number);
  28252. push(value: T): void;
  28253. forEach(func: (content: T) => void): void;
  28254. sort(compareFn: (a: T, b: T) => number): void;
  28255. reset(): void;
  28256. dispose(): void;
  28257. concat(array: any): void;
  28258. indexOf(value: T): number;
  28259. contains(value: T): boolean;
  28260. private static _GlobalId;
  28261. }
  28262. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  28263. private _duplicateId;
  28264. [index: number]: T;
  28265. push(value: T): void;
  28266. pushNoDuplicate(value: T): boolean;
  28267. reset(): void;
  28268. concatWithNoDuplicate(array: any): void;
  28269. }
  28270. }
  28271. declare module BABYLON {
  28272. /**
  28273. * This class implement a typical dictionary using a string as key and the generic type T as value.
  28274. * The underlying implementation relies on an associative array to ensure the best performances.
  28275. * The value can be anything including 'null' but except 'undefined'
  28276. */
  28277. class StringDictionary<T> {
  28278. /**
  28279. * This will clear this dictionary and copy the content from the 'source' one.
  28280. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  28281. * @param source the dictionary to take the content from and copy to this dictionary
  28282. */
  28283. copyFrom(source: StringDictionary<T>): void;
  28284. /**
  28285. * Get a value based from its key
  28286. * @param key the given key to get the matching value from
  28287. * @return the value if found, otherwise undefined is returned
  28288. */
  28289. get(key: string): T | undefined;
  28290. /**
  28291. * Get a value from its key or add it if it doesn't exist.
  28292. * This method will ensure you that a given key/data will be present in the dictionary.
  28293. * @param key the given key to get the matching value from
  28294. * @param factory the factory that will create the value if the key is not present in the dictionary.
  28295. * The factory will only be invoked if there's no data for the given key.
  28296. * @return the value corresponding to the key.
  28297. */
  28298. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  28299. /**
  28300. * Get a value from its key if present in the dictionary otherwise add it
  28301. * @param key the key to get the value from
  28302. * @param val if there's no such key/value pair in the dictionary add it with this value
  28303. * @return the value corresponding to the key
  28304. */
  28305. getOrAdd(key: string, val: T): T;
  28306. /**
  28307. * Check if there's a given key in the dictionary
  28308. * @param key the key to check for
  28309. * @return true if the key is present, false otherwise
  28310. */
  28311. contains(key: string): boolean;
  28312. /**
  28313. * Add a new key and its corresponding value
  28314. * @param key the key to add
  28315. * @param value the value corresponding to the key
  28316. * @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
  28317. */
  28318. add(key: string, value: T): boolean;
  28319. set(key: string, value: T): boolean;
  28320. /**
  28321. * Get the element of the given key and remove it from the dictionary
  28322. * @param key
  28323. */
  28324. getAndRemove(key: string): Nullable<T>;
  28325. /**
  28326. * Remove a key/value from the dictionary.
  28327. * @param key the key to remove
  28328. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  28329. */
  28330. remove(key: string): boolean;
  28331. /**
  28332. * Clear the whole content of the dictionary
  28333. */
  28334. clear(): void;
  28335. readonly count: number;
  28336. /**
  28337. * Execute a callback on each key/val of the dictionary.
  28338. * Note that you can remove any element in this dictionary in the callback implementation
  28339. * @param callback the callback to execute on a given key/value pair
  28340. */
  28341. forEach(callback: (key: string, val: T) => void): void;
  28342. /**
  28343. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  28344. * If the callback returns null or undefined the method will iterate to the next key/value pair
  28345. * Note that you can remove any element in this dictionary in the callback implementation
  28346. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  28347. */
  28348. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  28349. private _count;
  28350. private _data;
  28351. }
  28352. }
  28353. declare module BABYLON {
  28354. class Tags {
  28355. static EnableFor(obj: any): void;
  28356. static DisableFor(obj: any): void;
  28357. static HasTags(obj: any): boolean;
  28358. static GetTags(obj: any, asString?: boolean): any;
  28359. static AddTagsTo(obj: any, tagsString: string): void;
  28360. static _AddTagTo(obj: any, tag: string): void;
  28361. static RemoveTagsFrom(obj: any, tagsString: string): void;
  28362. static _RemoveTagFrom(obj: any, tag: string): void;
  28363. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  28364. }
  28365. }
  28366. declare module BABYLON {
  28367. class TextureTools {
  28368. /**
  28369. * Uses the GPU to create a copy texture rescaled at a given size
  28370. * @param texture Texture to copy from
  28371. * @param width Desired width
  28372. * @param height Desired height
  28373. * @return Generated texture
  28374. */
  28375. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  28376. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  28377. private static _environmentBRDFBase64Texture;
  28378. }
  28379. }
  28380. declare module BABYLON {
  28381. class TGATools {
  28382. private static _TYPE_INDEXED;
  28383. private static _TYPE_RGB;
  28384. private static _TYPE_GREY;
  28385. private static _TYPE_RLE_INDEXED;
  28386. private static _TYPE_RLE_RGB;
  28387. private static _TYPE_RLE_GREY;
  28388. private static _ORIGIN_MASK;
  28389. private static _ORIGIN_SHIFT;
  28390. private static _ORIGIN_BL;
  28391. private static _ORIGIN_BR;
  28392. private static _ORIGIN_UL;
  28393. private static _ORIGIN_UR;
  28394. static GetTGAHeader(data: Uint8Array): any;
  28395. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  28396. 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;
  28397. 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;
  28398. 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;
  28399. 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;
  28400. 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;
  28401. 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;
  28402. }
  28403. }
  28404. declare module BABYLON {
  28405. interface IAnimatable {
  28406. animations: Array<Animation>;
  28407. }
  28408. class LoadFileError extends Error {
  28409. request: XMLHttpRequest | undefined;
  28410. private static _setPrototypeOf;
  28411. constructor(message: string, request?: XMLHttpRequest | undefined);
  28412. }
  28413. class RetryStrategy {
  28414. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  28415. }
  28416. interface IFileRequest {
  28417. /**
  28418. * Raised when the request is complete (success or error).
  28419. */
  28420. onCompleteObservable: Observable<IFileRequest>;
  28421. /**
  28422. * Aborts the request for a file.
  28423. */
  28424. abort: () => void;
  28425. }
  28426. class Tools {
  28427. static BaseUrl: string;
  28428. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  28429. /**
  28430. * Default behaviour for cors in the application.
  28431. * It can be a string if the expected behavior is identical in the entire app.
  28432. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  28433. */
  28434. static CorsBehavior: string | ((url: string | string[]) => string);
  28435. static UseFallbackTexture: boolean;
  28436. /**
  28437. * Use this object to register external classes like custom textures or material
  28438. * to allow the laoders to instantiate them
  28439. */
  28440. static RegisteredExternalClasses: {
  28441. [key: string]: Object;
  28442. };
  28443. static fallbackTexture: string;
  28444. /**
  28445. * Interpolates between a and b via alpha
  28446. * @param a The lower value (returned when alpha = 0)
  28447. * @param b The upper value (returned when alpha = 1)
  28448. * @param alpha The interpolation-factor
  28449. * @return The mixed value
  28450. */
  28451. static Mix(a: number, b: number, alpha: number): number;
  28452. static Instantiate(className: string): any;
  28453. /**
  28454. * Provides a slice function that will work even on IE
  28455. * @param data defines the array to slice
  28456. * @param start defines the start of the data (optional)
  28457. * @param end defines the end of the data (optional)
  28458. * @returns the new sliced array
  28459. */
  28460. static Slice<T>(data: T, start?: number, end?: number): T;
  28461. static SetImmediate(action: () => void): void;
  28462. static IsExponentOfTwo(value: number): boolean;
  28463. private static _tmpFloatArray;
  28464. /**
  28465. * Returns the nearest 32-bit single precision float representation of a Number
  28466. * @param value A Number. If the parameter is of a different type, it will get converted
  28467. * to a number or to NaN if it cannot be converted
  28468. * @returns number
  28469. */
  28470. static FloatRound(value: number): number;
  28471. /**
  28472. * Find the next highest power of two.
  28473. * @param x Number to start search from.
  28474. * @return Next highest power of two.
  28475. */
  28476. static CeilingPOT(x: number): number;
  28477. /**
  28478. * Find the next lowest power of two.
  28479. * @param x Number to start search from.
  28480. * @return Next lowest power of two.
  28481. */
  28482. static FloorPOT(x: number): number;
  28483. /**
  28484. * Find the nearest power of two.
  28485. * @param x Number to start search from.
  28486. * @return Next nearest power of two.
  28487. */
  28488. static NearestPOT(x: number): number;
  28489. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  28490. static GetFilename(path: string): string;
  28491. /**
  28492. * Extracts the "folder" part of a path (everything before the filename).
  28493. * @param uri The URI to extract the info from
  28494. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  28495. * @returns The "folder" part of the path
  28496. */
  28497. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  28498. static GetDOMTextContent(element: HTMLElement): string;
  28499. static ToDegrees(angle: number): number;
  28500. static ToRadians(angle: number): number;
  28501. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  28502. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  28503. minimum: Vector3;
  28504. maximum: Vector3;
  28505. };
  28506. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  28507. minimum: Vector3;
  28508. maximum: Vector3;
  28509. };
  28510. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  28511. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  28512. minimum: Vector2;
  28513. maximum: Vector2;
  28514. };
  28515. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  28516. static GetPointerPrefix(): string;
  28517. /**
  28518. * @param func - the function to be called
  28519. * @param requester - the object that will request the next frame. Falls back to window.
  28520. */
  28521. static QueueNewFrame(func: () => void, requester?: any): number;
  28522. static RequestFullscreen(element: HTMLElement): void;
  28523. static ExitFullscreen(): void;
  28524. static SetCorsBehavior(url: string | string[], element: {
  28525. crossOrigin: string | null;
  28526. }): void;
  28527. static CleanUrl(url: string): string;
  28528. static PreprocessUrl: (url: string) => string;
  28529. /**
  28530. * Loads an image as an HTMLImageElement.
  28531. * @param input url string, ArrayBuffer, or Blob to load
  28532. * @param onLoad callback called when the image successfully loads
  28533. * @param onError callback called when the image fails to load
  28534. * @param database database for caching
  28535. * @returns the HTMLImageElement of the loaded image
  28536. */
  28537. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  28538. 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;
  28539. /**
  28540. * Load a script (identified by an url). When the url returns, the
  28541. * content of this file is added into a new script element, attached to the DOM (body element)
  28542. */
  28543. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  28544. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  28545. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  28546. static FileAsURL(content: string): string;
  28547. static Format(value: number, decimals?: number): string;
  28548. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  28549. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  28550. static IsEmpty(obj: any): boolean;
  28551. static RegisterTopRootEvents(events: {
  28552. name: string;
  28553. handler: Nullable<(e: FocusEvent) => any>;
  28554. }[]): void;
  28555. static UnregisterTopRootEvents(events: {
  28556. name: string;
  28557. handler: Nullable<(e: FocusEvent) => any>;
  28558. }[]): void;
  28559. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  28560. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  28561. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  28562. /**
  28563. * Generates an image screenshot from the specified camera.
  28564. *
  28565. * @param engine The engine to use for rendering
  28566. * @param camera The camera to use for rendering
  28567. * @param size This parameter can be set to a single number or to an object with the
  28568. * following (optional) properties: precision, width, height. If a single number is passed,
  28569. * it will be used for both width and height. If an object is passed, the screenshot size
  28570. * will be derived from the parameters. The precision property is a multiplier allowing
  28571. * rendering at a higher or lower resolution.
  28572. * @param successCallback The callback receives a single parameter which contains the
  28573. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  28574. * src parameter of an <img> to display it.
  28575. * @param mimeType The MIME type of the screenshot image (default: image/png).
  28576. * Check your browser for supported MIME types.
  28577. * @param samples Texture samples (default: 1)
  28578. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  28579. * @param fileName A name for for the downloaded file.
  28580. * @constructor
  28581. */
  28582. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  28583. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  28584. /**
  28585. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28586. * Be aware Math.random() could cause collisions, but:
  28587. * "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"
  28588. */
  28589. static RandomId(): string;
  28590. /**
  28591. * Test if the given uri is a base64 string.
  28592. * @param uri The uri to test
  28593. * @return True if the uri is a base64 string or false otherwise.
  28594. */
  28595. static IsBase64(uri: string): boolean;
  28596. /**
  28597. * Decode the given base64 uri.
  28598. * @param uri The uri to decode
  28599. * @return The decoded base64 data.
  28600. */
  28601. static DecodeBase64(uri: string): ArrayBuffer;
  28602. private static _NoneLogLevel;
  28603. private static _MessageLogLevel;
  28604. private static _WarningLogLevel;
  28605. private static _ErrorLogLevel;
  28606. private static _LogCache;
  28607. static errorsCount: number;
  28608. static OnNewCacheEntry: (entry: string) => void;
  28609. static readonly NoneLogLevel: number;
  28610. static readonly MessageLogLevel: number;
  28611. static readonly WarningLogLevel: number;
  28612. static readonly ErrorLogLevel: number;
  28613. static readonly AllLogLevel: number;
  28614. private static _AddLogEntry(entry);
  28615. private static _FormatMessage(message);
  28616. private static _LogDisabled(message);
  28617. private static _LogEnabled(message);
  28618. private static _WarnDisabled(message);
  28619. private static _WarnEnabled(message);
  28620. private static _ErrorDisabled(message);
  28621. private static _ErrorEnabled(message);
  28622. static Log: (message: string) => void;
  28623. static Warn: (message: string) => void;
  28624. static Error: (message: string) => void;
  28625. static readonly LogCache: string;
  28626. static ClearLogCache(): void;
  28627. static LogLevels: number;
  28628. static IsWindowObjectExist(): boolean;
  28629. private static _PerformanceNoneLogLevel;
  28630. private static _PerformanceUserMarkLogLevel;
  28631. private static _PerformanceConsoleLogLevel;
  28632. private static _performance;
  28633. static readonly PerformanceNoneLogLevel: number;
  28634. static readonly PerformanceUserMarkLogLevel: number;
  28635. static readonly PerformanceConsoleLogLevel: number;
  28636. static PerformanceLogLevel: number;
  28637. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  28638. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  28639. static _StartUserMark(counterName: string, condition?: boolean): void;
  28640. static _EndUserMark(counterName: string, condition?: boolean): void;
  28641. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  28642. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  28643. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  28644. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  28645. static readonly Now: number;
  28646. /**
  28647. * This method will return the name of the class used to create the instance of the given object.
  28648. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  28649. * @param object the object to get the class name from
  28650. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  28651. */
  28652. static GetClassName(object: any, isType?: boolean): string;
  28653. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  28654. /**
  28655. * This method will return the name of the full name of the class, including its owning module (if any).
  28656. * 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).
  28657. * @param object the object to get the class name from
  28658. * @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.
  28659. */
  28660. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  28661. /**
  28662. * 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.
  28663. * @param array
  28664. */
  28665. static arrayOrStringFeeder(array: any): (i: number) => number;
  28666. /**
  28667. * Compute the hashCode of a stream of number
  28668. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  28669. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  28670. * @return the hash code computed
  28671. */
  28672. static hashCodeFromStream(feeder: (index: number) => number): number;
  28673. /**
  28674. * Returns a promise that resolves after the given amount of time.
  28675. * @param delay Number of milliseconds to delay
  28676. * @returns Promise that resolves after the given amount of time
  28677. */
  28678. static DelayAsync(delay: number): Promise<void>;
  28679. }
  28680. /**
  28681. * This class is used to track a performance counter which is number based.
  28682. * The user has access to many properties which give statistics of different nature
  28683. *
  28684. * The implementer can track two kinds of Performance Counter: time and count
  28685. * 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.
  28686. * 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.
  28687. */
  28688. class PerfCounter {
  28689. static Enabled: boolean;
  28690. /**
  28691. * Returns the smallest value ever
  28692. */
  28693. readonly min: number;
  28694. /**
  28695. * Returns the biggest value ever
  28696. */
  28697. readonly max: number;
  28698. /**
  28699. * Returns the average value since the performance counter is running
  28700. */
  28701. readonly average: number;
  28702. /**
  28703. * Returns the average value of the last second the counter was monitored
  28704. */
  28705. readonly lastSecAverage: number;
  28706. /**
  28707. * Returns the current value
  28708. */
  28709. readonly current: number;
  28710. readonly total: number;
  28711. readonly count: number;
  28712. constructor();
  28713. /**
  28714. * Call this method to start monitoring a new frame.
  28715. * 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.
  28716. */
  28717. fetchNewFrame(): void;
  28718. /**
  28719. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28720. * @param newCount the count value to add to the monitored count
  28721. * @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.
  28722. */
  28723. addCount(newCount: number, fetchResult: boolean): void;
  28724. /**
  28725. * Start monitoring this performance counter
  28726. */
  28727. beginMonitoring(): void;
  28728. /**
  28729. * Compute the time lapsed since the previous beginMonitoring() call.
  28730. * @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
  28731. */
  28732. endMonitoring(newFrame?: boolean): void;
  28733. private _fetchResult();
  28734. private _startMonitoringTime;
  28735. private _min;
  28736. private _max;
  28737. private _average;
  28738. private _current;
  28739. private _totalValueCount;
  28740. private _totalAccumulated;
  28741. private _lastSecAverage;
  28742. private _lastSecAccumulated;
  28743. private _lastSecTime;
  28744. private _lastSecValueCount;
  28745. }
  28746. /**
  28747. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  28748. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  28749. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  28750. * @param name The name of the class, case should be preserved
  28751. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  28752. */
  28753. function className(name: string, module?: string): (target: Object) => void;
  28754. /**
  28755. * An implementation of a loop for asynchronous functions.
  28756. */
  28757. class AsyncLoop {
  28758. iterations: number;
  28759. private _fn;
  28760. private _successCallback;
  28761. index: number;
  28762. private _done;
  28763. /**
  28764. * Constroctor.
  28765. * @param iterations the number of iterations.
  28766. * @param _fn the function to run each iteration
  28767. * @param _successCallback the callback that will be called upon succesful execution
  28768. * @param offset starting offset.
  28769. */
  28770. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  28771. /**
  28772. * Execute the next iteration. Must be called after the last iteration was finished.
  28773. */
  28774. executeNext(): void;
  28775. /**
  28776. * Break the loop and run the success callback.
  28777. */
  28778. breakLoop(): void;
  28779. /**
  28780. * Helper function
  28781. */
  28782. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  28783. /**
  28784. * A for-loop that will run a given number of iterations synchronous and the rest async.
  28785. * @param iterations total number of iterations
  28786. * @param syncedIterations number of synchronous iterations in each async iteration.
  28787. * @param fn the function to call each iteration.
  28788. * @param callback a success call back that will be called when iterating stops.
  28789. * @param breakFunction a break condition (optional)
  28790. * @param timeout timeout settings for the setTimeout function. default - 0.
  28791. * @constructor
  28792. */
  28793. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  28794. }
  28795. }
  28796. declare module BABYLON {
  28797. /**
  28798. * Defines the potential axis of a Joystick
  28799. */
  28800. enum JoystickAxis {
  28801. /** X axis */
  28802. X = 0,
  28803. /** Y axis */
  28804. Y = 1,
  28805. /** Z axis */
  28806. Z = 2,
  28807. }
  28808. /**
  28809. * Class used to define virtual joystick (used in touch mode)
  28810. */
  28811. class VirtualJoystick {
  28812. /**
  28813. * Gets or sets a boolean indicating that left and right values must be inverted
  28814. */
  28815. reverseLeftRight: boolean;
  28816. /**
  28817. * Gets or sets a boolean indicating that up and down values must be inverted
  28818. */
  28819. reverseUpDown: boolean;
  28820. /**
  28821. * Gets the offset value for the position (ie. the change of the position value)
  28822. */
  28823. deltaPosition: Vector3;
  28824. /**
  28825. * Gets a boolean indicating if the virtual joystick was pressed
  28826. */
  28827. pressed: boolean;
  28828. private static _globalJoystickIndex;
  28829. private static vjCanvas;
  28830. private static vjCanvasContext;
  28831. private static vjCanvasWidth;
  28832. private static vjCanvasHeight;
  28833. private static halfWidth;
  28834. private _action;
  28835. private _axisTargetedByLeftAndRight;
  28836. private _axisTargetedByUpAndDown;
  28837. private _joystickSensibility;
  28838. private _inversedSensibility;
  28839. private _joystickPointerID;
  28840. private _joystickColor;
  28841. private _joystickPointerPos;
  28842. private _joystickPreviousPointerPos;
  28843. private _joystickPointerStartPos;
  28844. private _deltaJoystickVector;
  28845. private _leftJoystick;
  28846. private _touches;
  28847. private _onPointerDownHandlerRef;
  28848. private _onPointerMoveHandlerRef;
  28849. private _onPointerUpHandlerRef;
  28850. private _onResize;
  28851. /**
  28852. * Creates a new virtual joystick
  28853. * @param leftJoystick defines that the joystick is for left hand (false by default)
  28854. */
  28855. constructor(leftJoystick?: boolean);
  28856. /**
  28857. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  28858. * @param newJoystickSensibility defines the new sensibility
  28859. */
  28860. setJoystickSensibility(newJoystickSensibility: number): void;
  28861. private _onPointerDown(e);
  28862. private _onPointerMove(e);
  28863. private _onPointerUp(e);
  28864. /**
  28865. * Change the color of the virtual joystick
  28866. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  28867. */
  28868. setJoystickColor(newColor: string): void;
  28869. /**
  28870. * Defines a callback to call when the joystick is touched
  28871. * @param action defines the callback
  28872. */
  28873. setActionOnTouch(action: () => any): void;
  28874. /**
  28875. * Defines which axis you'd like to control for left & right
  28876. * @param axis defines the axis to use
  28877. */
  28878. setAxisForLeftRight(axis: JoystickAxis): void;
  28879. /**
  28880. * Defines which axis you'd like to control for up & down
  28881. * @param axis defines the axis to use
  28882. */
  28883. setAxisForUpDown(axis: JoystickAxis): void;
  28884. private _drawVirtualJoystick();
  28885. /**
  28886. * Release internal HTML canvas
  28887. */
  28888. releaseCanvas(): void;
  28889. }
  28890. }
  28891. declare module BABYLON {
  28892. /**
  28893. * Helper class to push actions to a pool of workers.
  28894. */
  28895. class WorkerPool implements IDisposable {
  28896. private _workerInfos;
  28897. private _pendingActions;
  28898. /**
  28899. * Constructor
  28900. * @param workers Array of workers to use for actions
  28901. */
  28902. constructor(workers: Array<Worker>);
  28903. /**
  28904. * Terminates all workers and clears any pending actions.
  28905. */
  28906. dispose(): void;
  28907. /**
  28908. * Pushes an action to the worker pool. If all the workers are active, the action will be
  28909. * pended until a worker has completed its action.
  28910. * @param action The action to perform. Call onComplete when the action is complete.
  28911. */
  28912. push(action: (worker: Worker, onComplete: () => void) => void): void;
  28913. private _execute(workerInfo, action);
  28914. }
  28915. }
  28916. declare module BABYLON {
  28917. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  28918. readonly name: string;
  28919. private _zoomStopsAnimation;
  28920. private _idleRotationSpeed;
  28921. private _idleRotationWaitTime;
  28922. private _idleRotationSpinupTime;
  28923. /**
  28924. * Gets the flag that indicates if user zooming should stop animation.
  28925. */
  28926. /**
  28927. * Sets the flag that indicates if user zooming should stop animation.
  28928. */
  28929. zoomStopsAnimation: boolean;
  28930. /**
  28931. * Gets the default speed at which the camera rotates around the model.
  28932. */
  28933. /**
  28934. * Sets the default speed at which the camera rotates around the model.
  28935. */
  28936. idleRotationSpeed: number;
  28937. /**
  28938. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  28939. */
  28940. /**
  28941. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  28942. */
  28943. idleRotationWaitTime: number;
  28944. /**
  28945. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  28946. */
  28947. /**
  28948. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  28949. */
  28950. idleRotationSpinupTime: number;
  28951. /**
  28952. * Gets a value indicating if the camera is currently rotating because of this behavior
  28953. */
  28954. readonly rotationInProgress: boolean;
  28955. private _onPrePointerObservableObserver;
  28956. private _onAfterCheckInputsObserver;
  28957. private _attachedCamera;
  28958. private _isPointerDown;
  28959. private _lastFrameTime;
  28960. private _lastInteractionTime;
  28961. private _cameraRotationSpeed;
  28962. init(): void;
  28963. attach(camera: ArcRotateCamera): void;
  28964. detach(): void;
  28965. /**
  28966. * Returns true if user is scrolling.
  28967. * @return true if user is scrolling.
  28968. */
  28969. private _userIsZooming();
  28970. private _lastFrameRadius;
  28971. private _shouldAnimationStopForInteraction();
  28972. /**
  28973. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  28974. */
  28975. private _applyUserInteraction();
  28976. private _userIsMoving();
  28977. }
  28978. }
  28979. declare module BABYLON {
  28980. /**
  28981. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  28982. */
  28983. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  28984. readonly name: string;
  28985. /**
  28986. * The easing function used by animations
  28987. */
  28988. static EasingFunction: BackEase;
  28989. /**
  28990. * The easing mode used by animations
  28991. */
  28992. static EasingMode: number;
  28993. /**
  28994. * The duration of the animation, in milliseconds
  28995. */
  28996. transitionDuration: number;
  28997. /**
  28998. * Length of the distance animated by the transition when lower radius is reached
  28999. */
  29000. lowerRadiusTransitionRange: number;
  29001. /**
  29002. * Length of the distance animated by the transition when upper radius is reached
  29003. */
  29004. upperRadiusTransitionRange: number;
  29005. private _autoTransitionRange;
  29006. /**
  29007. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  29008. */
  29009. /**
  29010. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  29011. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  29012. */
  29013. autoTransitionRange: boolean;
  29014. private _attachedCamera;
  29015. private _onAfterCheckInputsObserver;
  29016. private _onMeshTargetChangedObserver;
  29017. init(): void;
  29018. attach(camera: ArcRotateCamera): void;
  29019. detach(): void;
  29020. private _radiusIsAnimating;
  29021. private _radiusBounceTransition;
  29022. private _animatables;
  29023. private _cachedWheelPrecision;
  29024. /**
  29025. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  29026. * @param radiusLimit The limit to check against.
  29027. * @return Bool to indicate if at limit.
  29028. */
  29029. private _isRadiusAtLimit(radiusLimit);
  29030. /**
  29031. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  29032. * @param radiusDelta The delta by which to animate to. Can be negative.
  29033. */
  29034. private _applyBoundRadiusAnimation(radiusDelta);
  29035. /**
  29036. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  29037. */
  29038. protected _clearAnimationLocks(): void;
  29039. /**
  29040. * Stops and removes all animations that have been applied to the camera
  29041. */
  29042. stopAllAnimations(): void;
  29043. }
  29044. }
  29045. declare module BABYLON {
  29046. class FramingBehavior implements Behavior<ArcRotateCamera> {
  29047. readonly name: string;
  29048. private _mode;
  29049. private _radiusScale;
  29050. private _positionScale;
  29051. private _defaultElevation;
  29052. private _elevationReturnTime;
  29053. private _elevationReturnWaitTime;
  29054. private _zoomStopsAnimation;
  29055. private _framingTime;
  29056. /**
  29057. * The easing function used by animations
  29058. */
  29059. static EasingFunction: ExponentialEase;
  29060. /**
  29061. * The easing mode used by animations
  29062. */
  29063. static EasingMode: number;
  29064. /**
  29065. * Gets current mode used by the behavior.
  29066. */
  29067. /**
  29068. * Sets the current mode used by the behavior
  29069. */
  29070. mode: number;
  29071. /**
  29072. * Gets the scale applied to the radius
  29073. */
  29074. /**
  29075. * Sets the scale applied to the radius (1 by default)
  29076. */
  29077. radiusScale: number;
  29078. /**
  29079. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  29080. */
  29081. /**
  29082. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  29083. */
  29084. positionScale: number;
  29085. /**
  29086. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29087. * behaviour is triggered, in radians.
  29088. */
  29089. /**
  29090. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29091. * behaviour is triggered, in radians.
  29092. */
  29093. defaultElevation: number;
  29094. /**
  29095. * Gets the time (in milliseconds) taken to return to the default beta position.
  29096. * Negative value indicates camera should not return to default.
  29097. */
  29098. /**
  29099. * Sets the time (in milliseconds) taken to return to the default beta position.
  29100. * Negative value indicates camera should not return to default.
  29101. */
  29102. elevationReturnTime: number;
  29103. /**
  29104. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29105. */
  29106. /**
  29107. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29108. */
  29109. elevationReturnWaitTime: number;
  29110. /**
  29111. * Gets the flag that indicates if user zooming should stop animation.
  29112. */
  29113. /**
  29114. * Sets the flag that indicates if user zooming should stop animation.
  29115. */
  29116. zoomStopsAnimation: boolean;
  29117. /**
  29118. * Gets the transition time when framing the mesh, in milliseconds
  29119. */
  29120. /**
  29121. * Sets the transition time when framing the mesh, in milliseconds
  29122. */
  29123. framingTime: number;
  29124. private _onPrePointerObservableObserver;
  29125. private _onAfterCheckInputsObserver;
  29126. private _onMeshTargetChangedObserver;
  29127. private _attachedCamera;
  29128. private _isPointerDown;
  29129. private _lastInteractionTime;
  29130. init(): void;
  29131. attach(camera: ArcRotateCamera): void;
  29132. detach(): void;
  29133. private _animatables;
  29134. private _betaIsAnimating;
  29135. private _betaTransition;
  29136. private _radiusTransition;
  29137. private _vectorTransition;
  29138. /**
  29139. * Targets the given mesh and updates zoom level accordingly.
  29140. * @param mesh The mesh to target.
  29141. * @param radius Optional. If a cached radius position already exists, overrides default.
  29142. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29143. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29144. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29145. */
  29146. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29147. /**
  29148. * Targets the given mesh with its children and updates zoom level accordingly.
  29149. * @param mesh The mesh to target.
  29150. * @param radius Optional. If a cached radius position already exists, overrides default.
  29151. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29152. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29153. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29154. */
  29155. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29156. /**
  29157. * Targets the given meshes with their children and updates zoom level accordingly.
  29158. * @param meshes The mesh to target.
  29159. * @param radius Optional. If a cached radius position already exists, overrides default.
  29160. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29161. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29162. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29163. */
  29164. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29165. /**
  29166. * Targets the given mesh and updates zoom level accordingly.
  29167. * @param mesh The mesh to target.
  29168. * @param radius Optional. If a cached radius position already exists, overrides default.
  29169. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29170. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29171. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29172. */
  29173. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29174. /**
  29175. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  29176. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  29177. * frustum width.
  29178. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  29179. * to fully enclose the mesh in the viewing frustum.
  29180. */
  29181. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  29182. /**
  29183. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  29184. * is automatically returned to its default position (expected to be above ground plane).
  29185. */
  29186. private _maintainCameraAboveGround();
  29187. /**
  29188. * Returns the frustum slope based on the canvas ratio and camera FOV
  29189. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  29190. */
  29191. private _getFrustumSlope();
  29192. /**
  29193. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  29194. */
  29195. private _clearAnimationLocks();
  29196. /**
  29197. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  29198. */
  29199. private _applyUserInteraction();
  29200. /**
  29201. * Stops and removes all animations that have been applied to the camera
  29202. */
  29203. stopAllAnimations(): void;
  29204. /**
  29205. * Gets a value indicating if the user is moving the camera
  29206. */
  29207. readonly isUserIsMoving: boolean;
  29208. /**
  29209. * The camera can move all the way towards the mesh.
  29210. */
  29211. static IgnoreBoundsSizeMode: number;
  29212. /**
  29213. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  29214. */
  29215. static FitFrustumSidesMode: number;
  29216. }
  29217. }
  29218. declare module BABYLON {
  29219. interface IOctreeContainer<T> {
  29220. blocks: Array<OctreeBlock<T>>;
  29221. }
  29222. class Octree<T> {
  29223. maxDepth: number;
  29224. blocks: Array<OctreeBlock<T>>;
  29225. dynamicContent: T[];
  29226. private _maxBlockCapacity;
  29227. private _selectionContent;
  29228. private _creationFunc;
  29229. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  29230. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  29231. addMesh(entry: T): void;
  29232. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  29233. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  29234. intersectsRay(ray: Ray): SmartArray<T>;
  29235. 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;
  29236. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  29237. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  29238. }
  29239. }
  29240. declare module BABYLON {
  29241. class OctreeBlock<T> {
  29242. entries: T[];
  29243. blocks: Array<OctreeBlock<T>>;
  29244. private _depth;
  29245. private _maxDepth;
  29246. private _capacity;
  29247. private _minPoint;
  29248. private _maxPoint;
  29249. private _boundingVectors;
  29250. private _creationFunc;
  29251. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  29252. readonly capacity: number;
  29253. readonly minPoint: Vector3;
  29254. readonly maxPoint: Vector3;
  29255. addEntry(entry: T): void;
  29256. addEntries(entries: T[]): void;
  29257. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  29258. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  29259. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  29260. createInnerBlocks(): void;
  29261. }
  29262. }
  29263. declare module BABYLON {
  29264. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  29265. camera: ArcRotateCamera;
  29266. gamepad: Nullable<Gamepad>;
  29267. private _onGamepadConnectedObserver;
  29268. private _onGamepadDisconnectedObserver;
  29269. gamepadRotationSensibility: number;
  29270. gamepadMoveSensibility: number;
  29271. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29272. detachControl(element: Nullable<HTMLElement>): void;
  29273. checkInputs(): void;
  29274. getClassName(): string;
  29275. getSimpleName(): string;
  29276. }
  29277. }
  29278. declare module BABYLON {
  29279. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  29280. camera: ArcRotateCamera;
  29281. private _keys;
  29282. keysUp: number[];
  29283. keysDown: number[];
  29284. keysLeft: number[];
  29285. keysRight: number[];
  29286. keysReset: number[];
  29287. panningSensibility: number;
  29288. zoomingSensibility: number;
  29289. useAltToZoom: boolean;
  29290. private _ctrlPressed;
  29291. private _altPressed;
  29292. private _onCanvasBlurObserver;
  29293. private _onKeyboardObserver;
  29294. private _engine;
  29295. private _scene;
  29296. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29297. detachControl(element: Nullable<HTMLElement>): void;
  29298. checkInputs(): void;
  29299. getClassName(): string;
  29300. getSimpleName(): string;
  29301. }
  29302. }
  29303. declare module BABYLON {
  29304. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  29305. camera: ArcRotateCamera;
  29306. private _wheel;
  29307. private _observer;
  29308. wheelPrecision: number;
  29309. /**
  29310. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  29311. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  29312. */
  29313. wheelDeltaPercentage: number;
  29314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29315. detachControl(element: Nullable<HTMLElement>): void;
  29316. getClassName(): string;
  29317. getSimpleName(): string;
  29318. }
  29319. }
  29320. declare module BABYLON {
  29321. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  29322. camera: ArcRotateCamera;
  29323. buttons: number[];
  29324. angularSensibilityX: number;
  29325. angularSensibilityY: number;
  29326. pinchPrecision: number;
  29327. /**
  29328. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  29329. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  29330. */
  29331. pinchDeltaPercentage: number;
  29332. panningSensibility: number;
  29333. multiTouchPanning: boolean;
  29334. multiTouchPanAndZoom: boolean;
  29335. private _isPanClick;
  29336. pinchInwards: boolean;
  29337. private _pointerInput;
  29338. private _observer;
  29339. private _onMouseMove;
  29340. private _onGestureStart;
  29341. private _onGesture;
  29342. private _MSGestureHandler;
  29343. private _onLostFocus;
  29344. private _onContextMenu;
  29345. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29346. detachControl(element: Nullable<HTMLElement>): void;
  29347. getClassName(): string;
  29348. getSimpleName(): string;
  29349. }
  29350. }
  29351. declare module BABYLON {
  29352. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  29353. camera: ArcRotateCamera;
  29354. alphaCorrection: number;
  29355. betaCorrection: number;
  29356. gammaCorrection: number;
  29357. private _alpha;
  29358. private _gamma;
  29359. private _dirty;
  29360. private _deviceOrientationHandler;
  29361. constructor();
  29362. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29363. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  29364. checkInputs(): void;
  29365. detachControl(element: Nullable<HTMLElement>): void;
  29366. getClassName(): string;
  29367. getSimpleName(): string;
  29368. }
  29369. }
  29370. declare module BABYLON {
  29371. /**
  29372. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  29373. * Screen rotation is taken into account.
  29374. */
  29375. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  29376. private _camera;
  29377. private _screenOrientationAngle;
  29378. private _constantTranform;
  29379. private _screenQuaternion;
  29380. private _alpha;
  29381. private _beta;
  29382. private _gamma;
  29383. constructor();
  29384. camera: FreeCamera;
  29385. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29386. private _orientationChanged;
  29387. private _deviceOrientation;
  29388. detachControl(element: Nullable<HTMLElement>): void;
  29389. checkInputs(): void;
  29390. getClassName(): string;
  29391. getSimpleName(): string;
  29392. }
  29393. }
  29394. declare module BABYLON {
  29395. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  29396. camera: FreeCamera;
  29397. gamepad: Nullable<Gamepad>;
  29398. private _onGamepadConnectedObserver;
  29399. private _onGamepadDisconnectedObserver;
  29400. gamepadAngularSensibility: number;
  29401. gamepadMoveSensibility: number;
  29402. private _cameraTransform;
  29403. private _deltaTransform;
  29404. private _vector3;
  29405. private _vector2;
  29406. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29407. detachControl(element: Nullable<HTMLElement>): void;
  29408. checkInputs(): void;
  29409. getClassName(): string;
  29410. getSimpleName(): string;
  29411. }
  29412. }
  29413. declare module BABYLON {
  29414. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  29415. camera: FreeCamera;
  29416. private _keys;
  29417. private _onCanvasBlurObserver;
  29418. private _onKeyboardObserver;
  29419. private _engine;
  29420. private _scene;
  29421. keysUp: number[];
  29422. keysDown: number[];
  29423. keysLeft: number[];
  29424. keysRight: number[];
  29425. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29426. detachControl(element: Nullable<HTMLElement>): void;
  29427. checkInputs(): void;
  29428. getClassName(): string;
  29429. _onLostFocus(e: FocusEvent): void;
  29430. getSimpleName(): string;
  29431. }
  29432. }
  29433. declare module BABYLON {
  29434. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  29435. touchEnabled: boolean;
  29436. camera: FreeCamera;
  29437. buttons: number[];
  29438. angularSensibility: number;
  29439. private _pointerInput;
  29440. private _onMouseMove;
  29441. private _observer;
  29442. private previousPosition;
  29443. constructor(touchEnabled?: boolean);
  29444. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29445. detachControl(element: Nullable<HTMLElement>): void;
  29446. getClassName(): string;
  29447. getSimpleName(): string;
  29448. }
  29449. }
  29450. declare module BABYLON {
  29451. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  29452. camera: FreeCamera;
  29453. private _offsetX;
  29454. private _offsetY;
  29455. private _pointerPressed;
  29456. private _pointerInput;
  29457. private _observer;
  29458. private _onLostFocus;
  29459. touchAngularSensibility: number;
  29460. touchMoveSensibility: number;
  29461. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29462. detachControl(element: Nullable<HTMLElement>): void;
  29463. checkInputs(): void;
  29464. getClassName(): string;
  29465. getSimpleName(): string;
  29466. }
  29467. }
  29468. declare module BABYLON {
  29469. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  29470. camera: FreeCamera;
  29471. private _leftjoystick;
  29472. private _rightjoystick;
  29473. getLeftJoystick(): VirtualJoystick;
  29474. getRightJoystick(): VirtualJoystick;
  29475. checkInputs(): void;
  29476. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29477. detachControl(element: Nullable<HTMLElement>): void;
  29478. getClassName(): string;
  29479. getSimpleName(): string;
  29480. }
  29481. }
  29482. declare module BABYLON {
  29483. class VRCameraMetrics {
  29484. hResolution: number;
  29485. vResolution: number;
  29486. hScreenSize: number;
  29487. vScreenSize: number;
  29488. vScreenCenter: number;
  29489. eyeToScreenDistance: number;
  29490. lensSeparationDistance: number;
  29491. interpupillaryDistance: number;
  29492. distortionK: number[];
  29493. chromaAbCorrection: number[];
  29494. postProcessScaleFactor: number;
  29495. lensCenterOffset: number;
  29496. compensateDistortion: boolean;
  29497. readonly aspectRatio: number;
  29498. readonly aspectRatioFov: number;
  29499. readonly leftHMatrix: Matrix;
  29500. readonly rightHMatrix: Matrix;
  29501. readonly leftPreViewMatrix: Matrix;
  29502. readonly rightPreViewMatrix: Matrix;
  29503. static GetDefault(): VRCameraMetrics;
  29504. }
  29505. }
  29506. declare module BABYLON {
  29507. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  29508. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29509. getClassName(): string;
  29510. }
  29511. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  29512. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29513. getClassName(): string;
  29514. }
  29515. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  29516. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29517. getClassName(): string;
  29518. }
  29519. }
  29520. declare module BABYLON {
  29521. /**
  29522. * Options to modify the vr teleportation behavior.
  29523. */
  29524. interface VRTeleportationOptions {
  29525. /**
  29526. * The name of the mesh which should be used as the teleportation floor. (default: null)
  29527. */
  29528. floorMeshName?: string;
  29529. /**
  29530. * A list of meshes to be used as the teleportation floor. (default: empty)
  29531. */
  29532. floorMeshes?: Mesh[];
  29533. }
  29534. /**
  29535. * Options to modify the vr experience helper's behavior.
  29536. */
  29537. interface VRExperienceHelperOptions extends WebVROptions {
  29538. /**
  29539. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  29540. */
  29541. createDeviceOrientationCamera?: boolean;
  29542. /**
  29543. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  29544. */
  29545. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  29546. /**
  29547. * Uses the main button on the controller to toggle the laser casted. (default: true)
  29548. */
  29549. laserToggle?: boolean;
  29550. /**
  29551. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  29552. */
  29553. floorMeshes?: Mesh[];
  29554. }
  29555. /**
  29556. * Helps to quickly add VR support to an existing scene.
  29557. * See http://doc.babylonjs.com/how_to/webvr_helper
  29558. */
  29559. class VRExperienceHelper {
  29560. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  29561. private _scene;
  29562. private _position;
  29563. private _btnVR;
  29564. private _btnVRDisplayed;
  29565. private _webVRsupported;
  29566. private _webVRready;
  29567. private _webVRrequesting;
  29568. private _webVRpresenting;
  29569. private _fullscreenVRpresenting;
  29570. private _canvas;
  29571. private _webVRCamera;
  29572. private _vrDeviceOrientationCamera;
  29573. private _deviceOrientationCamera;
  29574. private _existingCamera;
  29575. private _onKeyDown;
  29576. private _onVrDisplayPresentChange;
  29577. private _onVRDisplayChanged;
  29578. private _onVRRequestPresentStart;
  29579. private _onVRRequestPresentComplete;
  29580. /**
  29581. * Observable raised when entering VR.
  29582. */
  29583. onEnteringVRObservable: Observable<VRExperienceHelper>;
  29584. /**
  29585. * Observable raised when exiting VR.
  29586. */
  29587. onExitingVRObservable: Observable<VRExperienceHelper>;
  29588. /**
  29589. * Observable raised when controller mesh is loaded.
  29590. */
  29591. onControllerMeshLoadedObservable: Observable<WebVRController>;
  29592. /** Return this.onEnteringVRObservable
  29593. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  29594. */
  29595. readonly onEnteringVR: Observable<VRExperienceHelper>;
  29596. /** Return this.onExitingVRObservable
  29597. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  29598. */
  29599. readonly onExitingVR: Observable<VRExperienceHelper>;
  29600. /** Return this.onControllerMeshLoadedObservable
  29601. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  29602. */
  29603. readonly onControllerMeshLoaded: Observable<WebVRController>;
  29604. private _rayLength;
  29605. private _useCustomVRButton;
  29606. private _teleportationRequested;
  29607. private _teleportActive;
  29608. private _floorMeshName;
  29609. private _floorMeshesCollection;
  29610. private _rotationAllowed;
  29611. private _teleportBackwardsVector;
  29612. private _teleportationTarget;
  29613. private _isDefaultTeleportationTarget;
  29614. private _postProcessMove;
  29615. private _teleportationFillColor;
  29616. private _teleportationBorderColor;
  29617. private _rotationAngle;
  29618. private _haloCenter;
  29619. private _cameraGazer;
  29620. private _padSensibilityUp;
  29621. private _padSensibilityDown;
  29622. private leftController;
  29623. private rightController;
  29624. /**
  29625. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  29626. */
  29627. onNewMeshSelected: Observable<AbstractMesh>;
  29628. /**
  29629. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  29630. */
  29631. onNewMeshPicked: Observable<PickingInfo>;
  29632. private _circleEase;
  29633. /**
  29634. * Observable raised before camera teleportation
  29635. */
  29636. onBeforeCameraTeleport: Observable<Vector3>;
  29637. /**
  29638. * Observable raised after camera teleportation
  29639. */
  29640. onAfterCameraTeleport: Observable<Vector3>;
  29641. /**
  29642. * Observable raised when current selected mesh gets unselected
  29643. */
  29644. onSelectedMeshUnselected: Observable<AbstractMesh>;
  29645. private _raySelectionPredicate;
  29646. /**
  29647. * To be optionaly changed by user to define custom ray selection
  29648. */
  29649. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  29650. /**
  29651. * To be optionaly changed by user to define custom selection logic (after ray selection)
  29652. */
  29653. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  29654. /**
  29655. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  29656. */
  29657. teleportationEnabled: boolean;
  29658. private _defaultHeight;
  29659. private _teleportationInitialized;
  29660. private _interactionsEnabled;
  29661. private _interactionsRequested;
  29662. private _displayGaze;
  29663. private _displayLaserPointer;
  29664. /**
  29665. * The mesh used to display where the user is going to teleport.
  29666. */
  29667. /**
  29668. * Sets the mesh to be used to display where the user is going to teleport.
  29669. */
  29670. teleportationTarget: Mesh;
  29671. /**
  29672. * The mesh used to display where the user is selecting,
  29673. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  29674. * See http://doc.babylonjs.com/resources/baking_transformations
  29675. */
  29676. gazeTrackerMesh: Mesh;
  29677. /**
  29678. * If the ray of the gaze should be displayed.
  29679. */
  29680. /**
  29681. * Sets if the ray of the gaze should be displayed.
  29682. */
  29683. displayGaze: boolean;
  29684. /**
  29685. * If the ray of the LaserPointer should be displayed.
  29686. */
  29687. /**
  29688. * Sets if the ray of the LaserPointer should be displayed.
  29689. */
  29690. displayLaserPointer: boolean;
  29691. /**
  29692. * The deviceOrientationCamera used as the camera when not in VR.
  29693. */
  29694. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  29695. /**
  29696. * Based on the current WebVR support, returns the current VR camera used.
  29697. */
  29698. readonly currentVRCamera: Nullable<Camera>;
  29699. /**
  29700. * The webVRCamera which is used when in VR.
  29701. */
  29702. readonly webVRCamera: WebVRFreeCamera;
  29703. /**
  29704. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  29705. */
  29706. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  29707. private readonly _teleportationRequestInitiated;
  29708. /**
  29709. * Instantiates a VRExperienceHelper.
  29710. * Helps to quickly add VR support to an existing scene.
  29711. * @param scene The scene the VRExperienceHelper belongs to.
  29712. * @param webVROptions Options to modify the vr experience helper's behavior.
  29713. */
  29714. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  29715. private _onDefaultMeshLoaded(webVRController);
  29716. private _onResize;
  29717. private _onFullscreenChange;
  29718. /**
  29719. * Gets a value indicating if we are currently in VR mode.
  29720. */
  29721. readonly isInVRMode: boolean;
  29722. private onVrDisplayPresentChange();
  29723. private onVRDisplayChanged(eventArgs);
  29724. private moveButtonToBottomRight();
  29725. private displayVRButton();
  29726. private updateButtonVisibility();
  29727. /**
  29728. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  29729. * Otherwise, will use the fullscreen API.
  29730. */
  29731. enterVR(): void;
  29732. /**
  29733. * Attempt to exit VR, or fullscreen.
  29734. */
  29735. exitVR(): void;
  29736. /**
  29737. * The position of the vr experience helper.
  29738. */
  29739. /**
  29740. * Sets the position of the vr experience helper.
  29741. */
  29742. position: Vector3;
  29743. /**
  29744. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  29745. */
  29746. enableInteractions(): void;
  29747. private beforeRender;
  29748. private _isTeleportationFloor(mesh);
  29749. /**
  29750. * Adds a floor mesh to be used for teleportation.
  29751. * @param floorMesh the mesh to be used for teleportation.
  29752. */
  29753. addFloorMesh(floorMesh: Mesh): void;
  29754. /**
  29755. * Removes a floor mesh from being used for teleportation.
  29756. * @param floorMesh the mesh to be removed.
  29757. */
  29758. removeFloorMesh(floorMesh: Mesh): void;
  29759. /**
  29760. * Enables interactions and teleportation using the VR controllers and gaze.
  29761. * @param vrTeleportationOptions options to modify teleportation behavior.
  29762. */
  29763. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  29764. private _onNewGamepadConnected;
  29765. private _tryEnableInteractionOnController;
  29766. private _onNewGamepadDisconnected;
  29767. private _enableInteractionOnController(controller);
  29768. private _checkTeleportWithRay(stateObject, gazer);
  29769. private _checkRotate(stateObject, gazer);
  29770. private _checkTeleportBackwards(stateObject, gazer);
  29771. private _enableTeleportationOnController(controller);
  29772. private _createTeleportationCircles();
  29773. private _displayTeleportationTarget();
  29774. private _hideTeleportationTarget();
  29775. private _rotateCamera(right);
  29776. private _moveTeleportationSelectorTo(hit, gazer, ray);
  29777. private _workingVector;
  29778. private _workingQuaternion;
  29779. private _workingMatrix;
  29780. private _teleportCamera(location);
  29781. private _convertNormalToDirectionOfRay(normal, ray);
  29782. private _castRayAndSelectObject(gazer);
  29783. private _notifySelectedMeshUnselected(mesh);
  29784. /**
  29785. * Sets the color of the laser ray from the vr controllers.
  29786. * @param color new color for the ray.
  29787. */
  29788. changeLaserColor(color: Color3): void;
  29789. /**
  29790. * Sets the color of the ray from the vr headsets gaze.
  29791. * @param color new color for the ray.
  29792. */
  29793. changeGazeColor(color: Color3): void;
  29794. /**
  29795. * Exits VR and disposes of the vr experience helper
  29796. */
  29797. dispose(): void;
  29798. /**
  29799. * Gets the name of the VRExperienceHelper class
  29800. * @returns "VRExperienceHelper"
  29801. */
  29802. getClassName(): string;
  29803. }
  29804. }
  29805. declare module BABYLON {
  29806. /**
  29807. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  29808. * IMPORTANT!! The data is right-hand data.
  29809. * @export
  29810. * @interface DevicePose
  29811. */
  29812. interface DevicePose {
  29813. /**
  29814. * The position of the device, values in array are [x,y,z].
  29815. */
  29816. readonly position: Nullable<Float32Array>;
  29817. /**
  29818. * The linearVelocity of the device, values in array are [x,y,z].
  29819. */
  29820. readonly linearVelocity: Nullable<Float32Array>;
  29821. /**
  29822. * The linearAcceleration of the device, values in array are [x,y,z].
  29823. */
  29824. readonly linearAcceleration: Nullable<Float32Array>;
  29825. /**
  29826. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  29827. */
  29828. readonly orientation: Nullable<Float32Array>;
  29829. /**
  29830. * The angularVelocity of the device, values in array are [x,y,z].
  29831. */
  29832. readonly angularVelocity: Nullable<Float32Array>;
  29833. /**
  29834. * The angularAcceleration of the device, values in array are [x,y,z].
  29835. */
  29836. readonly angularAcceleration: Nullable<Float32Array>;
  29837. }
  29838. /**
  29839. * Interface representing a pose controlled object in Babylon.
  29840. * A pose controlled object has both regular pose values as well as pose values
  29841. * from an external device such as a VR head mounted display
  29842. */
  29843. interface PoseControlled {
  29844. /**
  29845. * The position of the object in babylon space.
  29846. */
  29847. position: Vector3;
  29848. /**
  29849. * The rotation quaternion of the object in babylon space.
  29850. */
  29851. rotationQuaternion: Quaternion;
  29852. /**
  29853. * The position of the device in babylon space.
  29854. */
  29855. devicePosition?: Vector3;
  29856. /**
  29857. * The rotation quaternion of the device in babylon space.
  29858. */
  29859. deviceRotationQuaternion: Quaternion;
  29860. /**
  29861. * The raw pose coming from the device.
  29862. */
  29863. rawPose: Nullable<DevicePose>;
  29864. /**
  29865. * The scale of the device to be used when translating from device space to babylon space.
  29866. */
  29867. deviceScaleFactor: number;
  29868. /**
  29869. * Updates the poseControlled values based on the input device pose.
  29870. * @param poseData the pose data to update the object with
  29871. */
  29872. updateFromDevice(poseData: DevicePose): void;
  29873. }
  29874. /**
  29875. * Set of options to customize the webVRCamera
  29876. */
  29877. interface WebVROptions {
  29878. /**
  29879. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  29880. */
  29881. trackPosition?: boolean;
  29882. /**
  29883. * Sets the scale of the vrDevice in babylon space. (default: 1)
  29884. */
  29885. positionScale?: number;
  29886. /**
  29887. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  29888. */
  29889. displayName?: string;
  29890. /**
  29891. * Should the native controller meshes be initialized. (default: true)
  29892. */
  29893. controllerMeshes?: boolean;
  29894. /**
  29895. * Creating a default HemiLight only on controllers. (default: true)
  29896. */
  29897. defaultLightingOnControllers?: boolean;
  29898. /**
  29899. * If you don't want to use the default VR button of the helper. (default: false)
  29900. */
  29901. useCustomVRButton?: boolean;
  29902. /**
  29903. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  29904. */
  29905. customVRButton?: HTMLButtonElement;
  29906. /**
  29907. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  29908. */
  29909. rayLength?: number;
  29910. /**
  29911. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  29912. */
  29913. defaultHeight?: number;
  29914. }
  29915. /**
  29916. * This represents a WebVR camera.
  29917. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  29918. * @example http://doc.babylonjs.com/how_to/webvr_camera
  29919. */
  29920. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  29921. private webVROptions;
  29922. /**
  29923. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  29924. */
  29925. _vrDevice: any;
  29926. /**
  29927. * The rawPose of the vrDevice.
  29928. */
  29929. rawPose: Nullable<DevicePose>;
  29930. private _onVREnabled;
  29931. private _specsVersion;
  29932. private _attached;
  29933. private _frameData;
  29934. protected _descendants: Array<Node>;
  29935. private _deviceRoomPosition;
  29936. private _deviceRoomRotationQuaternion;
  29937. private _standingMatrix;
  29938. /**
  29939. * Represents device position in babylon space.
  29940. */
  29941. devicePosition: Vector3;
  29942. /**
  29943. * Represents device rotation in babylon space.
  29944. */
  29945. deviceRotationQuaternion: Quaternion;
  29946. /**
  29947. * The scale of the device to be used when translating from device space to babylon space.
  29948. */
  29949. deviceScaleFactor: number;
  29950. private _deviceToWorld;
  29951. private _worldToDevice;
  29952. /**
  29953. * References to the webVR controllers for the vrDevice.
  29954. */
  29955. controllers: Array<WebVRController>;
  29956. /**
  29957. * Emits an event when a controller is attached.
  29958. */
  29959. onControllersAttachedObservable: Observable<WebVRController[]>;
  29960. /**
  29961. * Emits an event when a controller's mesh has been loaded;
  29962. */
  29963. onControllerMeshLoadedObservable: Observable<WebVRController>;
  29964. /**
  29965. * If the rig cameras be used as parent instead of this camera.
  29966. */
  29967. rigParenting: boolean;
  29968. private _lightOnControllers;
  29969. private _defaultHeight?;
  29970. /**
  29971. * Instantiates a WebVRFreeCamera.
  29972. * @param name The name of the WebVRFreeCamera
  29973. * @param position The starting anchor position for the camera
  29974. * @param scene The scene the camera belongs to
  29975. * @param webVROptions a set of customizable options for the webVRCamera
  29976. */
  29977. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  29978. /**
  29979. * Gets the device distance from the ground in meters.
  29980. * @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.
  29981. */
  29982. deviceDistanceToRoomGround(): number;
  29983. /**
  29984. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  29985. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  29986. */
  29987. useStandingMatrix(callback?: (bool: boolean) => void): void;
  29988. /**
  29989. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  29990. * @returns A promise with a boolean set to if the standing matrix is supported.
  29991. */
  29992. useStandingMatrixAsync(): Promise<boolean>;
  29993. /**
  29994. * Disposes the camera
  29995. */
  29996. dispose(): void;
  29997. /**
  29998. * Gets a vrController by name.
  29999. * @param name The name of the controller to retreive
  30000. * @returns the controller matching the name specified or null if not found
  30001. */
  30002. getControllerByName(name: string): Nullable<WebVRController>;
  30003. private _leftController;
  30004. /**
  30005. * The controller corrisponding to the users left hand.
  30006. */
  30007. readonly leftController: Nullable<WebVRController>;
  30008. private _rightController;
  30009. /**
  30010. * The controller corrisponding to the users right hand.
  30011. */
  30012. readonly rightController: Nullable<WebVRController>;
  30013. /**
  30014. * Casts a ray forward from the vrCamera's gaze.
  30015. * @param length Length of the ray (default: 100)
  30016. * @returns the ray corrisponding to the gaze
  30017. */
  30018. getForwardRay(length?: number): Ray;
  30019. /**
  30020. * Updates the camera based on device's frame data
  30021. */
  30022. _checkInputs(): void;
  30023. /**
  30024. * Updates the poseControlled values based on the input device pose.
  30025. * @param poseData Pose coming from the device
  30026. */
  30027. updateFromDevice(poseData: DevicePose): void;
  30028. /**
  30029. * WebVR's attach control will start broadcasting frames to the device.
  30030. * Note that in certain browsers (chrome for example) this function must be called
  30031. * within a user-interaction callback. Example:
  30032. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  30033. *
  30034. * @param element html element to attach the vrDevice to
  30035. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  30036. */
  30037. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30038. /**
  30039. * Detaches the camera from the html element and disables VR
  30040. *
  30041. * @param element html element to detach from
  30042. */
  30043. detachControl(element: HTMLElement): void;
  30044. /**
  30045. * @returns the name of this class
  30046. */
  30047. getClassName(): string;
  30048. /**
  30049. * Calls resetPose on the vrDisplay
  30050. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  30051. */
  30052. resetToCurrentRotation(): void;
  30053. /**
  30054. * Updates the rig cameras (left and right eye)
  30055. */
  30056. _updateRigCameras(): void;
  30057. private _workingVector;
  30058. private _oneVector;
  30059. private _workingMatrix;
  30060. private updateCacheCalled;
  30061. /**
  30062. * Updates the cached values of the camera
  30063. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  30064. */
  30065. _updateCache(ignoreParentClass?: boolean): void;
  30066. /**
  30067. * Updates the current device position and rotation in the babylon world
  30068. */
  30069. update(): void;
  30070. /**
  30071. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  30072. * @returns an identity matrix
  30073. */
  30074. _getViewMatrix(): Matrix;
  30075. /**
  30076. * This function is called by the two RIG cameras.
  30077. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  30078. */
  30079. protected _getWebVRViewMatrix(): Matrix;
  30080. protected _getWebVRProjectionMatrix(): Matrix;
  30081. private _onGamepadConnectedObserver;
  30082. private _onGamepadDisconnectedObserver;
  30083. /**
  30084. * Initializes the controllers and their meshes
  30085. */
  30086. initControllers(): void;
  30087. }
  30088. }
  30089. declare module BABYLON {
  30090. /**
  30091. * Google Daydream controller
  30092. */
  30093. class DaydreamController extends WebVRController {
  30094. /**
  30095. * Base Url for the controller model.
  30096. */
  30097. static MODEL_BASE_URL: string;
  30098. /**
  30099. * File name for the controller model.
  30100. */
  30101. static MODEL_FILENAME: string;
  30102. /**
  30103. * Gamepad Id prefix used to identify Daydream Controller.
  30104. */
  30105. static readonly GAMEPAD_ID_PREFIX: string;
  30106. /**
  30107. * Creates a new DaydreamController 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. * Gear VR Controller
  30129. */
  30130. class GearVRController extends WebVRController {
  30131. /**
  30132. * Base Url for the controller model.
  30133. */
  30134. static MODEL_BASE_URL: string;
  30135. /**
  30136. * File name for the controller model.
  30137. */
  30138. static MODEL_FILENAME: string;
  30139. /**
  30140. * Gamepad Id prefix used to identify this controller.
  30141. */
  30142. static readonly GAMEPAD_ID_PREFIX: string;
  30143. private readonly _buttonIndexToObservableNameMap;
  30144. /**
  30145. * Creates a new GearVRController from a gamepad
  30146. * @param vrGamepad the gamepad that the controller should be created from
  30147. */
  30148. constructor(vrGamepad: any);
  30149. /**
  30150. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30151. * @param scene scene in which to add meshes
  30152. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30153. */
  30154. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30155. /**
  30156. * Called once for each button that changed state since the last frame
  30157. * @param buttonIdx Which button index changed
  30158. * @param state New state of the button
  30159. * @param changes Which properties on the state changed since last frame
  30160. */
  30161. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30162. }
  30163. }
  30164. declare module BABYLON {
  30165. /**
  30166. * Generic Controller
  30167. */
  30168. class GenericController extends WebVRController {
  30169. /**
  30170. * Base Url for the controller model.
  30171. */
  30172. static readonly MODEL_BASE_URL: string;
  30173. /**
  30174. * File name for the controller model.
  30175. */
  30176. static readonly MODEL_FILENAME: string;
  30177. /**
  30178. * Creates a new GenericController from a gamepad
  30179. * @param vrGamepad the gamepad that the controller should be created from
  30180. */
  30181. constructor(vrGamepad: any);
  30182. /**
  30183. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30184. * @param scene scene in which to add meshes
  30185. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30186. */
  30187. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30188. /**
  30189. * Called once for each button that changed state since the last frame
  30190. * @param buttonIdx Which button index changed
  30191. * @param state New state of the button
  30192. * @param changes Which properties on the state changed since last frame
  30193. */
  30194. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30195. }
  30196. }
  30197. declare module BABYLON {
  30198. /**
  30199. * Oculus Touch Controller
  30200. */
  30201. class OculusTouchController extends WebVRController {
  30202. /**
  30203. * Base Url for the controller model.
  30204. */
  30205. static MODEL_BASE_URL: string;
  30206. /**
  30207. * File name for the left controller model.
  30208. */
  30209. static MODEL_LEFT_FILENAME: string;
  30210. /**
  30211. * File name for the right controller model.
  30212. */
  30213. static MODEL_RIGHT_FILENAME: string;
  30214. /**
  30215. * Fired when the secondary trigger on this controller is modified
  30216. */
  30217. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  30218. /**
  30219. * Fired when the thumb rest on this controller is modified
  30220. */
  30221. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  30222. /**
  30223. * Creates a new OculusTouchController from a gamepad
  30224. * @param vrGamepad the gamepad that the controller should be created from
  30225. */
  30226. constructor(vrGamepad: any);
  30227. /**
  30228. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30229. * @param scene scene in which to add meshes
  30230. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30231. */
  30232. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30233. /**
  30234. * Fired when the A button on this controller is modified
  30235. */
  30236. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30237. /**
  30238. * Fired when the B button on this controller is modified
  30239. */
  30240. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30241. /**
  30242. * Fired when the X button on this controller is modified
  30243. */
  30244. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30245. /**
  30246. * Fired when the Y button on this controller is modified
  30247. */
  30248. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30249. /**
  30250. * Called once for each button that changed state since the last frame
  30251. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  30252. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  30253. * 2) secondary trigger (same)
  30254. * 3) A (right) X (left), touch, pressed = value
  30255. * 4) B / Y
  30256. * 5) thumb rest
  30257. * @param buttonIdx Which button index changed
  30258. * @param state New state of the button
  30259. * @param changes Which properties on the state changed since last frame
  30260. */
  30261. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30262. }
  30263. }
  30264. declare module BABYLON {
  30265. /**
  30266. * Defines the types of pose enabled controllers that are supported
  30267. */
  30268. enum PoseEnabledControllerType {
  30269. /**
  30270. * HTC Vive
  30271. */
  30272. VIVE = 0,
  30273. /**
  30274. * Oculus Rift
  30275. */
  30276. OCULUS = 1,
  30277. /**
  30278. * Windows mixed reality
  30279. */
  30280. WINDOWS = 2,
  30281. /**
  30282. * Samsung gear VR
  30283. */
  30284. GEAR_VR = 3,
  30285. /**
  30286. * Google Daydream
  30287. */
  30288. DAYDREAM = 4,
  30289. /**
  30290. * Generic
  30291. */
  30292. GENERIC = 5,
  30293. }
  30294. /**
  30295. * Defines the MutableGamepadButton interface for the state of a gamepad button
  30296. */
  30297. interface MutableGamepadButton {
  30298. /**
  30299. * Value of the button/trigger
  30300. */
  30301. value: number;
  30302. /**
  30303. * If the button/trigger is currently touched
  30304. */
  30305. touched: boolean;
  30306. /**
  30307. * If the button/trigger is currently pressed
  30308. */
  30309. pressed: boolean;
  30310. }
  30311. /**
  30312. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  30313. * @hidden
  30314. */
  30315. interface ExtendedGamepadButton extends GamepadButton {
  30316. /**
  30317. * If the button/trigger is currently pressed
  30318. */
  30319. readonly pressed: boolean;
  30320. /**
  30321. * If the button/trigger is currently touched
  30322. */
  30323. readonly touched: boolean;
  30324. /**
  30325. * Value of the button/trigger
  30326. */
  30327. readonly value: number;
  30328. }
  30329. /**
  30330. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30331. */
  30332. class PoseEnabledControllerHelper {
  30333. /**
  30334. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30335. * @param vrGamepad the gamepad to initialized
  30336. * @returns a vr controller of the type the gamepad identified as
  30337. */
  30338. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  30339. }
  30340. /**
  30341. * Defines the PoseEnabledController object that contains state of a vr capable controller
  30342. */
  30343. class PoseEnabledController extends Gamepad implements PoseControlled {
  30344. private _deviceRoomPosition;
  30345. private _deviceRoomRotationQuaternion;
  30346. /**
  30347. * The device position in babylon space
  30348. */
  30349. devicePosition: Vector3;
  30350. /**
  30351. * The device rotation in babylon space
  30352. */
  30353. deviceRotationQuaternion: Quaternion;
  30354. /**
  30355. * The scale factor of the device in babylon space
  30356. */
  30357. deviceScaleFactor: number;
  30358. /**
  30359. * (Likely devicePosition should be used instead) The device position in its room space
  30360. */
  30361. position: Vector3;
  30362. /**
  30363. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  30364. */
  30365. rotationQuaternion: Quaternion;
  30366. /**
  30367. * The type of controller (Eg. Windows mixed reality)
  30368. */
  30369. controllerType: PoseEnabledControllerType;
  30370. protected _calculatedPosition: Vector3;
  30371. private _calculatedRotation;
  30372. /**
  30373. * The raw pose from the device
  30374. */
  30375. rawPose: DevicePose;
  30376. /**
  30377. * Internal, the mesh attached to the controller
  30378. */
  30379. _mesh: Nullable<AbstractMesh>;
  30380. private _poseControlledCamera;
  30381. private _leftHandSystemQuaternion;
  30382. /**
  30383. * Internal, matrix used to convert room space to babylon space
  30384. */
  30385. _deviceToWorld: Matrix;
  30386. /**
  30387. * Node to be used when casting a ray from the controller
  30388. */
  30389. _pointingPoseNode: Nullable<AbstractMesh>;
  30390. /**
  30391. * Name of the child mesh that can be used to cast a ray from the controller
  30392. */
  30393. static readonly POINTING_POSE: string;
  30394. /**
  30395. * Creates a new PoseEnabledController from a gamepad
  30396. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  30397. */
  30398. constructor(browserGamepad: any);
  30399. private _workingMatrix;
  30400. /**
  30401. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  30402. */
  30403. update(): void;
  30404. /**
  30405. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  30406. * @param poseData raw pose fromthe device
  30407. */
  30408. updateFromDevice(poseData: DevicePose): void;
  30409. /**
  30410. * @hidden
  30411. */
  30412. _meshAttachedObservable: Observable<AbstractMesh>;
  30413. /**
  30414. * Attaches a mesh to the controller
  30415. * @param mesh the mesh to be attached
  30416. */
  30417. attachToMesh(mesh: AbstractMesh): void;
  30418. /**
  30419. * Attaches the controllers mesh to a camera
  30420. * @param camera the camera the mesh should be attached to
  30421. */
  30422. attachToPoseControlledCamera(camera: TargetCamera): void;
  30423. /**
  30424. * Disposes of the controller
  30425. */
  30426. dispose(): void;
  30427. /**
  30428. * The mesh that is attached to the controller
  30429. */
  30430. readonly mesh: Nullable<AbstractMesh>;
  30431. /**
  30432. * Gets the ray of the controller in the direction the controller is pointing
  30433. * @param length the length the resulting ray should be
  30434. * @returns a ray in the direction the controller is pointing
  30435. */
  30436. getForwardRay(length?: number): Ray;
  30437. }
  30438. }
  30439. declare module BABYLON {
  30440. /**
  30441. * Vive Controller
  30442. */
  30443. class ViveController extends WebVRController {
  30444. /**
  30445. * Base Url for the controller model.
  30446. */
  30447. static MODEL_BASE_URL: string;
  30448. /**
  30449. * File name for the controller model.
  30450. */
  30451. static MODEL_FILENAME: string;
  30452. /**
  30453. * Creates a new ViveController from a gamepad
  30454. * @param vrGamepad the gamepad that the controller should be created from
  30455. */
  30456. constructor(vrGamepad: any);
  30457. /**
  30458. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30459. * @param scene scene in which to add meshes
  30460. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30461. */
  30462. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30463. /**
  30464. * Fired when the left button on this controller is modified
  30465. */
  30466. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30467. /**
  30468. * Fired when the right button on this controller is modified
  30469. */
  30470. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30471. /**
  30472. * Fired when the menu button on this controller is modified
  30473. */
  30474. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30475. /**
  30476. * Called once for each button that changed state since the last frame
  30477. * Vive mapping:
  30478. * 0: touchpad
  30479. * 1: trigger
  30480. * 2: left AND right buttons
  30481. * 3: menu button
  30482. * @param buttonIdx Which button index changed
  30483. * @param state New state of the button
  30484. * @param changes Which properties on the state changed since last frame
  30485. */
  30486. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30487. }
  30488. }
  30489. declare module BABYLON {
  30490. /**
  30491. * Defines the WebVRController object that represents controllers tracked in 3D space
  30492. */
  30493. abstract class WebVRController extends PoseEnabledController {
  30494. /**
  30495. * Internal, the default controller model for the controller
  30496. */
  30497. protected _defaultModel: AbstractMesh;
  30498. /**
  30499. * Fired when the trigger state has changed
  30500. */
  30501. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  30502. /**
  30503. * Fired when the main button state has changed
  30504. */
  30505. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30506. /**
  30507. * Fired when the secondary button state has changed
  30508. */
  30509. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30510. /**
  30511. * Fired when the pad state has changed
  30512. */
  30513. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  30514. /**
  30515. * Fired when controllers stick values have changed
  30516. */
  30517. onPadValuesChangedObservable: Observable<StickValues>;
  30518. /**
  30519. * Array of button availible on the controller
  30520. */
  30521. protected _buttons: Array<MutableGamepadButton>;
  30522. private _onButtonStateChange;
  30523. /**
  30524. * Fired when a controller button's state has changed
  30525. * @param callback the callback containing the button that was modified
  30526. */
  30527. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  30528. /**
  30529. * X and Y axis corrisponding to the controllers joystick
  30530. */
  30531. pad: StickValues;
  30532. /**
  30533. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  30534. */
  30535. hand: string;
  30536. /**
  30537. * The default controller model for the controller
  30538. */
  30539. readonly defaultModel: AbstractMesh;
  30540. /**
  30541. * Creates a new WebVRController from a gamepad
  30542. * @param vrGamepad the gamepad that the WebVRController should be created from
  30543. */
  30544. constructor(vrGamepad: any);
  30545. /**
  30546. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  30547. */
  30548. update(): void;
  30549. /**
  30550. * Function to be called when a button is modified
  30551. */
  30552. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30553. /**
  30554. * Loads a mesh and attaches it to the controller
  30555. * @param scene the scene the mesh should be added to
  30556. * @param meshLoaded callback for when the mesh has been loaded
  30557. */
  30558. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30559. private _setButtonValue(newState, currentState, buttonIndex);
  30560. private _changes;
  30561. private _checkChanges(newState, currentState);
  30562. /**
  30563. * Disposes of th webVRCOntroller
  30564. */
  30565. dispose(): void;
  30566. }
  30567. }
  30568. declare module BABYLON {
  30569. /**
  30570. * Defines the WindowsMotionController object that the state of the windows motion controller
  30571. */
  30572. class WindowsMotionController extends WebVRController {
  30573. /**
  30574. * The base url used to load the left and right controller models
  30575. */
  30576. static MODEL_BASE_URL: string;
  30577. /**
  30578. * The name of the left controller model file
  30579. */
  30580. static MODEL_LEFT_FILENAME: string;
  30581. /**
  30582. * The name of the right controller model file
  30583. */
  30584. static MODEL_RIGHT_FILENAME: string;
  30585. /**
  30586. * The controller name prefix for this controller type
  30587. */
  30588. static readonly GAMEPAD_ID_PREFIX: string;
  30589. /**
  30590. * The controller id pattern for this controller type
  30591. */
  30592. private static readonly GAMEPAD_ID_PATTERN;
  30593. private _loadedMeshInfo;
  30594. private readonly _mapping;
  30595. /**
  30596. * Fired when the trackpad on this controller is clicked
  30597. */
  30598. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  30599. /**
  30600. * Fired when the trackpad on this controller is modified
  30601. */
  30602. onTrackpadValuesChangedObservable: Observable<StickValues>;
  30603. /**
  30604. * The current x and y values of this controller's trackpad
  30605. */
  30606. trackpad: StickValues;
  30607. /**
  30608. * Creates a new WindowsMotionController from a gamepad
  30609. * @param vrGamepad the gamepad that the controller should be created from
  30610. */
  30611. constructor(vrGamepad: any);
  30612. /**
  30613. * Fired when the trigger on this controller is modified
  30614. */
  30615. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30616. /**
  30617. * Fired when the menu button on this controller is modified
  30618. */
  30619. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30620. /**
  30621. * Fired when the grip button on this controller is modified
  30622. */
  30623. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30624. /**
  30625. * Fired when the thumbstick button on this controller is modified
  30626. */
  30627. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30628. /**
  30629. * Fired when the touchpad button on this controller is modified
  30630. */
  30631. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30632. /**
  30633. * Fired when the touchpad values on this controller are modified
  30634. */
  30635. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  30636. /**
  30637. * Called once per frame by the engine.
  30638. */
  30639. update(): void;
  30640. /**
  30641. * Called once for each button that changed state since the last frame
  30642. * @param buttonIdx Which button index changed
  30643. * @param state New state of the button
  30644. * @param changes Which properties on the state changed since last frame
  30645. */
  30646. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30647. /**
  30648. * Moves the buttons on the controller mesh based on their current state
  30649. * @param buttonName the name of the button to move
  30650. * @param buttonValue the value of the button which determines the buttons new position
  30651. */
  30652. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  30653. /**
  30654. * Moves the axis on the controller mesh based on its current state
  30655. * @param axis the index of the axis
  30656. * @param axisValue the value of the axis which determines the meshes new position
  30657. * @hidden
  30658. */
  30659. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  30660. /**
  30661. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30662. * @param scene scene in which to add meshes
  30663. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30664. */
  30665. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  30666. /**
  30667. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  30668. * can be transformed by button presses and axes values, based on this._mapping.
  30669. *
  30670. * @param scene scene in which the meshes exist
  30671. * @param meshes list of meshes that make up the controller model to process
  30672. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  30673. */
  30674. private processModel(scene, meshes);
  30675. private createMeshInfo(rootNode);
  30676. /**
  30677. * Gets the ray of the controller in the direction the controller is pointing
  30678. * @param length the length the resulting ray should be
  30679. * @returns a ray in the direction the controller is pointing
  30680. */
  30681. getForwardRay(length?: number): Ray;
  30682. /**
  30683. * Disposes of the controller
  30684. */
  30685. dispose(): void;
  30686. }
  30687. }
  30688. declare module BABYLON {
  30689. }
  30690. declare module BABYLON {
  30691. /**
  30692. * Interface to implement to create a shadow generator compatible with BJS.
  30693. */
  30694. interface IShadowGenerator {
  30695. /**
  30696. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30697. * @returns The render target texture if present otherwise, null
  30698. */
  30699. getShadowMap(): Nullable<RenderTargetTexture>;
  30700. /**
  30701. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30702. * @returns The render target texture if the shadow map is present otherwise, null
  30703. */
  30704. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30705. /**
  30706. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30707. * @param subMesh The submesh we want to render in the shadow map
  30708. * @param useInstances Defines wether will draw in the map using instances
  30709. * @returns true if ready otherwise, false
  30710. */
  30711. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  30712. /**
  30713. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30714. * @param defines Defines of the material we want to update
  30715. * @param lightIndex Index of the light in the enabled light list of the material
  30716. */
  30717. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  30718. /**
  30719. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30720. * defined in the generator but impacting the effect).
  30721. * It implies the unifroms available on the materials are the standard BJS ones.
  30722. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30723. * @param effect The effect we are binfing the information for
  30724. */
  30725. bindShadowLight(lightIndex: string, effect: Effect): void;
  30726. /**
  30727. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30728. * (eq to shadow prjection matrix * light transform matrix)
  30729. * @returns The transform matrix used to create the shadow map
  30730. */
  30731. getTransformMatrix(): Matrix;
  30732. /**
  30733. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30734. * Cube and 2D textures for instance.
  30735. */
  30736. recreateShadowMap(): void;
  30737. /**
  30738. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30739. * @param onCompiled Callback triggered at the and of the effects compilation
  30740. * @param options Sets of optional options forcing the compilation with different modes
  30741. */
  30742. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  30743. useInstances: boolean;
  30744. }>): void;
  30745. /**
  30746. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30747. * @param options Sets of optional options forcing the compilation with different modes
  30748. * @returns A promise that resolves when the compilation completes
  30749. */
  30750. forceCompilationAsync(options?: Partial<{
  30751. useInstances: boolean;
  30752. }>): Promise<void>;
  30753. /**
  30754. * Serializes the shadow generator setup to a json object.
  30755. * @returns The serialized JSON object
  30756. */
  30757. serialize(): any;
  30758. /**
  30759. * Disposes the Shadow map and related Textures and effects.
  30760. */
  30761. dispose(): void;
  30762. }
  30763. /**
  30764. * Default implementation IShadowGenerator.
  30765. * This is the main object responsible of generating shadows in the framework.
  30766. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  30767. */
  30768. class ShadowGenerator implements IShadowGenerator {
  30769. /**
  30770. * Shadow generator mode None: no filtering applied.
  30771. */
  30772. static readonly FILTER_NONE: number;
  30773. /**
  30774. * Shadow generator mode ESM: Exponential Shadow Mapping.
  30775. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30776. */
  30777. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  30778. /**
  30779. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  30780. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  30781. */
  30782. static readonly FILTER_POISSONSAMPLING: number;
  30783. /**
  30784. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  30785. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30786. */
  30787. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  30788. /**
  30789. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  30790. * edge artifacts on steep falloff.
  30791. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30792. */
  30793. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  30794. /**
  30795. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  30796. * edge artifacts on steep falloff.
  30797. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30798. */
  30799. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  30800. /**
  30801. * Shadow generator mode PCF: Percentage Closer Filtering
  30802. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30803. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  30804. */
  30805. static readonly FILTER_PCF: number;
  30806. /**
  30807. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  30808. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30809. * Contact Hardening
  30810. */
  30811. static readonly FILTER_PCSS: number;
  30812. /**
  30813. * Reserved for PCF and PCSS
  30814. * Highest Quality.
  30815. *
  30816. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  30817. *
  30818. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  30819. */
  30820. static readonly QUALITY_HIGH: number;
  30821. /**
  30822. * Reserved for PCF and PCSS
  30823. * Good tradeoff for quality/perf cross devices
  30824. *
  30825. * Execute PCF on a 3*3 kernel.
  30826. *
  30827. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  30828. */
  30829. static readonly QUALITY_MEDIUM: number;
  30830. /**
  30831. * Reserved for PCF and PCSS
  30832. * The lowest quality but the fastest.
  30833. *
  30834. * Execute PCF on a 1*1 kernel.
  30835. *
  30836. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  30837. */
  30838. static readonly QUALITY_LOW: number;
  30839. private _bias;
  30840. /**
  30841. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  30842. */
  30843. /**
  30844. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  30845. */
  30846. bias: number;
  30847. private _normalBias;
  30848. /**
  30849. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30850. */
  30851. /**
  30852. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30853. */
  30854. normalBias: number;
  30855. private _blurBoxOffset;
  30856. /**
  30857. * Gets the blur box offset: offset applied during the blur pass.
  30858. * Only usefull if useKernelBlur = false
  30859. */
  30860. /**
  30861. * Sets the blur box offset: offset applied during the blur pass.
  30862. * Only usefull if useKernelBlur = false
  30863. */
  30864. blurBoxOffset: number;
  30865. private _blurScale;
  30866. /**
  30867. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  30868. * 2 means half of the size.
  30869. */
  30870. /**
  30871. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  30872. * 2 means half of the size.
  30873. */
  30874. blurScale: number;
  30875. private _blurKernel;
  30876. /**
  30877. * Gets the blur kernel: kernel size of the blur pass.
  30878. * Only usefull if useKernelBlur = true
  30879. */
  30880. /**
  30881. * Sets the blur kernel: kernel size of the blur pass.
  30882. * Only usefull if useKernelBlur = true
  30883. */
  30884. blurKernel: number;
  30885. private _useKernelBlur;
  30886. /**
  30887. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  30888. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  30889. */
  30890. /**
  30891. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  30892. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  30893. */
  30894. useKernelBlur: boolean;
  30895. private _depthScale;
  30896. /**
  30897. * Gets the depth scale used in ESM mode.
  30898. */
  30899. /**
  30900. * Sets the depth scale used in ESM mode.
  30901. * This can override the scale stored on the light.
  30902. */
  30903. depthScale: number;
  30904. private _filter;
  30905. /**
  30906. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  30907. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30908. */
  30909. /**
  30910. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  30911. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30912. */
  30913. filter: number;
  30914. /**
  30915. * Gets if the current filter is set to Poisson Sampling.
  30916. */
  30917. /**
  30918. * Sets the current filter to Poisson Sampling.
  30919. */
  30920. usePoissonSampling: boolean;
  30921. /**
  30922. * Gets if the current filter is set to VSM.
  30923. * DEPRECATED. Should use useExponentialShadowMap instead.
  30924. */
  30925. /**
  30926. * Sets the current filter is to VSM.
  30927. * DEPRECATED. Should use useExponentialShadowMap instead.
  30928. */
  30929. useVarianceShadowMap: boolean;
  30930. /**
  30931. * Gets if the current filter is set to blurred VSM.
  30932. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  30933. */
  30934. /**
  30935. * Sets the current filter is to blurred VSM.
  30936. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  30937. */
  30938. useBlurVarianceShadowMap: boolean;
  30939. /**
  30940. * Gets if the current filter is set to ESM.
  30941. */
  30942. /**
  30943. * Sets the current filter is to ESM.
  30944. */
  30945. useExponentialShadowMap: boolean;
  30946. /**
  30947. * Gets if the current filter is set to filtered ESM.
  30948. */
  30949. /**
  30950. * Gets if the current filter is set to filtered ESM.
  30951. */
  30952. useBlurExponentialShadowMap: boolean;
  30953. /**
  30954. * Gets if the current filter is set to "close ESM" (using the inverse of the
  30955. * exponential to prevent steep falloff artifacts).
  30956. */
  30957. /**
  30958. * Sets the current filter to "close ESM" (using the inverse of the
  30959. * exponential to prevent steep falloff artifacts).
  30960. */
  30961. useCloseExponentialShadowMap: boolean;
  30962. /**
  30963. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  30964. * exponential to prevent steep falloff artifacts).
  30965. */
  30966. /**
  30967. * Sets the current filter to filtered "close ESM" (using the inverse of the
  30968. * exponential to prevent steep falloff artifacts).
  30969. */
  30970. useBlurCloseExponentialShadowMap: boolean;
  30971. /**
  30972. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  30973. */
  30974. /**
  30975. * Sets the current filter to "PCF" (percentage closer filtering).
  30976. */
  30977. usePercentageCloserFiltering: boolean;
  30978. private _filteringQuality;
  30979. /**
  30980. * Gets the PCF or PCSS Quality.
  30981. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30982. */
  30983. /**
  30984. * Sets the PCF or PCSS Quality.
  30985. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30986. */
  30987. filteringQuality: number;
  30988. /**
  30989. * Gets if the current filter is set to "PCSS" (contact hardening).
  30990. */
  30991. /**
  30992. * Sets the current filter to "PCSS" (contact hardening).
  30993. */
  30994. useContactHardeningShadow: boolean;
  30995. private _contactHardeningLightSizeUVRatio;
  30996. /**
  30997. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30998. * Using a ratio helps keeping shape stability independently of the map size.
  30999. *
  31000. * It does not account for the light projection as it was having too much
  31001. * instability during the light setup or during light position changes.
  31002. *
  31003. * Only valid if useContactHardeningShadow is true.
  31004. */
  31005. /**
  31006. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  31007. * Using a ratio helps keeping shape stability independently of the map size.
  31008. *
  31009. * It does not account for the light projection as it was having too much
  31010. * instability during the light setup or during light position changes.
  31011. *
  31012. * Only valid if useContactHardeningShadow is true.
  31013. */
  31014. contactHardeningLightSizeUVRatio: number;
  31015. private _darkness;
  31016. /**
  31017. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  31018. * 0 means strongest and 1 would means no shadow.
  31019. * @returns the darkness.
  31020. */
  31021. getDarkness(): number;
  31022. /**
  31023. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  31024. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  31025. * @returns the shadow generator allowing fluent coding.
  31026. */
  31027. setDarkness(darkness: number): ShadowGenerator;
  31028. private _transparencyShadow;
  31029. /**
  31030. * Sets the ability to have transparent shadow (boolean).
  31031. * @param transparent True if transparent else False
  31032. * @returns the shadow generator allowing fluent coding
  31033. */
  31034. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  31035. private _shadowMap;
  31036. private _shadowMap2;
  31037. /**
  31038. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  31039. * @returns The render target texture if present otherwise, null
  31040. */
  31041. getShadowMap(): Nullable<RenderTargetTexture>;
  31042. /**
  31043. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  31044. * @returns The render target texture if the shadow map is present otherwise, null
  31045. */
  31046. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  31047. /**
  31048. * Helper function to add a mesh and its descendants to the list of shadow casters.
  31049. * @param mesh Mesh to add
  31050. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  31051. * @returns the Shadow Generator itself
  31052. */
  31053. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  31054. /**
  31055. * Helper function to remove a mesh and its descendants from the list of shadow casters
  31056. * @param mesh Mesh to remove
  31057. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  31058. * @returns the Shadow Generator itself
  31059. */
  31060. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  31061. /**
  31062. * Controls the extent to which the shadows fade out at the edge of the frustum
  31063. * Used only by directionals and spots
  31064. */
  31065. frustumEdgeFalloff: number;
  31066. private _light;
  31067. /**
  31068. * Returns the associated light object.
  31069. * @returns the light generating the shadow
  31070. */
  31071. getLight(): IShadowLight;
  31072. /**
  31073. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  31074. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  31075. * It might on the other hand introduce peter panning.
  31076. */
  31077. forceBackFacesOnly: boolean;
  31078. private _scene;
  31079. private _lightDirection;
  31080. private _effect;
  31081. private _viewMatrix;
  31082. private _projectionMatrix;
  31083. private _transformMatrix;
  31084. private _cachedPosition;
  31085. private _cachedDirection;
  31086. private _cachedDefines;
  31087. private _currentRenderID;
  31088. private _boxBlurPostprocess;
  31089. private _kernelBlurXPostprocess;
  31090. private _kernelBlurYPostprocess;
  31091. private _blurPostProcesses;
  31092. private _mapSize;
  31093. private _currentFaceIndex;
  31094. private _currentFaceIndexCache;
  31095. private _textureType;
  31096. private _defaultTextureMatrix;
  31097. /**
  31098. * Creates a ShadowGenerator object.
  31099. * A ShadowGenerator is the required tool to use the shadows.
  31100. * Each light casting shadows needs to use its own ShadowGenerator.
  31101. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  31102. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  31103. * @param light The light object generating the shadows.
  31104. * @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.
  31105. */
  31106. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  31107. private _initializeGenerator();
  31108. private _initializeShadowMap();
  31109. private _initializeBlurRTTAndPostProcesses();
  31110. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  31111. private _renderSubMeshForShadowMap(subMesh);
  31112. private _applyFilterValues();
  31113. /**
  31114. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31115. * @param onCompiled Callback triggered at the and of the effects compilation
  31116. * @param options Sets of optional options forcing the compilation with different modes
  31117. */
  31118. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  31119. useInstances: boolean;
  31120. }>): void;
  31121. /**
  31122. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31123. * @param options Sets of optional options forcing the compilation with different modes
  31124. * @returns A promise that resolves when the compilation completes
  31125. */
  31126. forceCompilationAsync(options?: Partial<{
  31127. useInstances: boolean;
  31128. }>): Promise<void>;
  31129. /**
  31130. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  31131. * @param subMesh The submesh we want to render in the shadow map
  31132. * @param useInstances Defines wether will draw in the map using instances
  31133. * @returns true if ready otherwise, false
  31134. */
  31135. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  31136. /**
  31137. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  31138. * @param defines Defines of the material we want to update
  31139. * @param lightIndex Index of the light in the enabled light list of the material
  31140. */
  31141. prepareDefines(defines: any, lightIndex: number): void;
  31142. /**
  31143. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  31144. * defined in the generator but impacting the effect).
  31145. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  31146. * @param effect The effect we are binfing the information for
  31147. */
  31148. bindShadowLight(lightIndex: string, effect: Effect): void;
  31149. /**
  31150. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  31151. * (eq to shadow prjection matrix * light transform matrix)
  31152. * @returns The transform matrix used to create the shadow map
  31153. */
  31154. getTransformMatrix(): Matrix;
  31155. /**
  31156. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  31157. * Cube and 2D textures for instance.
  31158. */
  31159. recreateShadowMap(): void;
  31160. private _disposeBlurPostProcesses();
  31161. private _disposeRTTandPostProcesses();
  31162. /**
  31163. * Disposes the ShadowGenerator.
  31164. * Returns nothing.
  31165. */
  31166. dispose(): void;
  31167. /**
  31168. * Serializes the shadow generator setup to a json object.
  31169. * @returns The serialized JSON object
  31170. */
  31171. serialize(): any;
  31172. /**
  31173. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  31174. * @param parsedShadowGenerator The JSON object to parse
  31175. * @param scene The scene to create the shadow map for
  31176. * @returns The parsed shadow generator
  31177. */
  31178. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  31179. }
  31180. }
  31181. declare module BABYLON {
  31182. /**
  31183. * Background material used to create an efficient environement around your scene.
  31184. */
  31185. class BackgroundMaterial extends PushMaterial {
  31186. /**
  31187. * Standard reflectance value at parallel view angle.
  31188. */
  31189. static StandardReflectance0: number;
  31190. /**
  31191. * Standard reflectance value at grazing angle.
  31192. */
  31193. static StandardReflectance90: number;
  31194. protected _primaryColor: Color3;
  31195. /**
  31196. * Key light Color (multiply against the environement texture)
  31197. */
  31198. primaryColor: Color3;
  31199. protected __perceptualColor: Nullable<Color3>;
  31200. /**
  31201. * Experimental Internal Use Only.
  31202. *
  31203. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  31204. * This acts as a helper to set the primary color to a more "human friendly" value.
  31205. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  31206. * output color as close as possible from the chosen value.
  31207. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  31208. * part of lighting setup.)
  31209. */
  31210. _perceptualColor: Nullable<Color3>;
  31211. protected _primaryColorShadowLevel: float;
  31212. /**
  31213. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  31214. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  31215. */
  31216. primaryColorShadowLevel: float;
  31217. protected _primaryColorHighlightLevel: float;
  31218. /**
  31219. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  31220. * The primary color is used at the level chosen to define what the white area would look.
  31221. */
  31222. primaryColorHighlightLevel: float;
  31223. protected _reflectionTexture: Nullable<BaseTexture>;
  31224. /**
  31225. * Reflection Texture used in the material.
  31226. * Should be author in a specific way for the best result (refer to the documentation).
  31227. */
  31228. reflectionTexture: Nullable<BaseTexture>;
  31229. protected _reflectionBlur: float;
  31230. /**
  31231. * Reflection Texture level of blur.
  31232. *
  31233. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  31234. * texture twice.
  31235. */
  31236. reflectionBlur: float;
  31237. protected _diffuseTexture: Nullable<BaseTexture>;
  31238. /**
  31239. * Diffuse Texture used in the material.
  31240. * Should be author in a specific way for the best result (refer to the documentation).
  31241. */
  31242. diffuseTexture: Nullable<BaseTexture>;
  31243. protected _shadowLights: Nullable<IShadowLight[]>;
  31244. /**
  31245. * Specify the list of lights casting shadow on the material.
  31246. * All scene shadow lights will be included if null.
  31247. */
  31248. shadowLights: Nullable<IShadowLight[]>;
  31249. protected _shadowLevel: float;
  31250. /**
  31251. * Helps adjusting the shadow to a softer level if required.
  31252. * 0 means black shadows and 1 means no shadows.
  31253. */
  31254. shadowLevel: float;
  31255. protected _sceneCenter: Vector3;
  31256. /**
  31257. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  31258. * It is usually zero but might be interesting to modify according to your setup.
  31259. */
  31260. sceneCenter: Vector3;
  31261. protected _opacityFresnel: boolean;
  31262. /**
  31263. * This helps specifying that the material is falling off to the sky box at grazing angle.
  31264. * This helps ensuring a nice transition when the camera goes under the ground.
  31265. */
  31266. opacityFresnel: boolean;
  31267. protected _reflectionFresnel: boolean;
  31268. /**
  31269. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  31270. * This helps adding a mirror texture on the ground.
  31271. */
  31272. reflectionFresnel: boolean;
  31273. protected _reflectionFalloffDistance: number;
  31274. /**
  31275. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  31276. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  31277. */
  31278. reflectionFalloffDistance: number;
  31279. protected _reflectionAmount: number;
  31280. /**
  31281. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  31282. */
  31283. reflectionAmount: number;
  31284. protected _reflectionReflectance0: number;
  31285. /**
  31286. * This specifies the weight of the reflection at grazing angle.
  31287. */
  31288. reflectionReflectance0: number;
  31289. protected _reflectionReflectance90: number;
  31290. /**
  31291. * This specifies the weight of the reflection at a perpendicular point of view.
  31292. */
  31293. reflectionReflectance90: number;
  31294. /**
  31295. * Sets the reflection reflectance fresnel values according to the default standard
  31296. * empirically know to work well :-)
  31297. */
  31298. reflectionStandardFresnelWeight: number;
  31299. protected _useRGBColor: boolean;
  31300. /**
  31301. * Helps to directly use the maps channels instead of their level.
  31302. */
  31303. useRGBColor: boolean;
  31304. protected _enableNoise: boolean;
  31305. /**
  31306. * This helps reducing the banding effect that could occur on the background.
  31307. */
  31308. enableNoise: boolean;
  31309. /**
  31310. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  31311. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  31312. * Recommended to be keep at 1.0 except for special cases.
  31313. */
  31314. fovMultiplier: number;
  31315. private _fovMultiplier;
  31316. /**
  31317. * Enable the FOV adjustment feature controlled by fovMultiplier.
  31318. */
  31319. useEquirectangularFOV: boolean;
  31320. private _maxSimultaneousLights;
  31321. /**
  31322. * Number of Simultaneous lights allowed on the material.
  31323. */
  31324. maxSimultaneousLights: int;
  31325. /**
  31326. * Default configuration related to image processing available in the Background Material.
  31327. */
  31328. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31329. /**
  31330. * Keep track of the image processing observer to allow dispose and replace.
  31331. */
  31332. private _imageProcessingObserver;
  31333. /**
  31334. * Attaches a new image processing configuration to the PBR Material.
  31335. * @param configuration (if null the scene configuration will be use)
  31336. */
  31337. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31338. /**
  31339. * Gets the image processing configuration used either in this material.
  31340. */
  31341. /**
  31342. * Sets the Default image processing configuration used either in the this material.
  31343. *
  31344. * If sets to null, the scene one is in use.
  31345. */
  31346. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  31347. /**
  31348. * Gets wether the color curves effect is enabled.
  31349. */
  31350. /**
  31351. * Sets wether the color curves effect is enabled.
  31352. */
  31353. cameraColorCurvesEnabled: boolean;
  31354. /**
  31355. * Gets wether the color grading effect is enabled.
  31356. */
  31357. /**
  31358. * Gets wether the color grading effect is enabled.
  31359. */
  31360. cameraColorGradingEnabled: boolean;
  31361. /**
  31362. * Gets wether tonemapping is enabled or not.
  31363. */
  31364. /**
  31365. * Sets wether tonemapping is enabled or not
  31366. */
  31367. cameraToneMappingEnabled: boolean;
  31368. /**
  31369. * The camera exposure used on this material.
  31370. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31371. * This corresponds to a photographic exposure.
  31372. */
  31373. /**
  31374. * The camera exposure used on this material.
  31375. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31376. * This corresponds to a photographic exposure.
  31377. */
  31378. cameraExposure: float;
  31379. /**
  31380. * Gets The camera contrast used on this material.
  31381. */
  31382. /**
  31383. * Sets The camera contrast used on this material.
  31384. */
  31385. cameraContrast: float;
  31386. /**
  31387. * Gets the Color Grading 2D Lookup Texture.
  31388. */
  31389. /**
  31390. * Sets the Color Grading 2D Lookup Texture.
  31391. */
  31392. cameraColorGradingTexture: Nullable<BaseTexture>;
  31393. /**
  31394. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31395. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31396. * 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;
  31397. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31398. */
  31399. /**
  31400. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31401. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31402. * 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;
  31403. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31404. */
  31405. cameraColorCurves: Nullable<ColorCurves>;
  31406. /**
  31407. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  31408. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  31409. */
  31410. switchToBGR: boolean;
  31411. private _renderTargets;
  31412. private _reflectionControls;
  31413. private _white;
  31414. private _primaryShadowColor;
  31415. private _primaryHighlightColor;
  31416. /**
  31417. * Instantiates a Background Material in the given scene
  31418. * @param name The friendly name of the material
  31419. * @param scene The scene to add the material to
  31420. */
  31421. constructor(name: string, scene: Scene);
  31422. /**
  31423. * The entire material has been created in order to prevent overdraw.
  31424. * @returns false
  31425. */
  31426. needAlphaTesting(): boolean;
  31427. /**
  31428. * The entire material has been created in order to prevent overdraw.
  31429. * @returns true if blending is enable
  31430. */
  31431. needAlphaBlending(): boolean;
  31432. /**
  31433. * Checks wether the material is ready to be rendered for a given mesh.
  31434. * @param mesh The mesh to render
  31435. * @param subMesh The submesh to check against
  31436. * @param useInstances Specify wether or not the material is used with instances
  31437. * @returns true if all the dependencies are ready (Textures, Effects...)
  31438. */
  31439. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31440. /**
  31441. * Compute the primary color according to the chosen perceptual color.
  31442. */
  31443. private _computePrimaryColorFromPerceptualColor();
  31444. /**
  31445. * Compute the highlights and shadow colors according to their chosen levels.
  31446. */
  31447. private _computePrimaryColors();
  31448. /**
  31449. * Build the uniform buffer used in the material.
  31450. */
  31451. buildUniformLayout(): void;
  31452. /**
  31453. * Unbind the material.
  31454. */
  31455. unbind(): void;
  31456. /**
  31457. * Bind only the world matrix to the material.
  31458. * @param world The world matrix to bind.
  31459. */
  31460. bindOnlyWorldMatrix(world: Matrix): void;
  31461. /**
  31462. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  31463. * @param world The world matrix to bind.
  31464. * @param subMesh The submesh to bind for.
  31465. */
  31466. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31467. /**
  31468. * Dispose the material.
  31469. * @param forceDisposeEffect Force disposal of the associated effect.
  31470. * @param forceDisposeTextures Force disposal of the associated textures.
  31471. */
  31472. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31473. /**
  31474. * Clones the material.
  31475. * @param name The cloned name.
  31476. * @returns The cloned material.
  31477. */
  31478. clone(name: string): BackgroundMaterial;
  31479. /**
  31480. * Serializes the current material to its JSON representation.
  31481. * @returns The JSON representation.
  31482. */
  31483. serialize(): any;
  31484. /**
  31485. * Gets the class name of the material
  31486. * @returns "BackgroundMaterial"
  31487. */
  31488. getClassName(): string;
  31489. /**
  31490. * Parse a JSON input to create back a background material.
  31491. * @param source The JSON data to parse
  31492. * @param scene The scene to create the parsed material in
  31493. * @param rootUrl The root url of the assets the material depends upon
  31494. * @returns the instantiated BackgroundMaterial.
  31495. */
  31496. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  31497. }
  31498. }
  31499. declare module BABYLON {
  31500. /**
  31501. * The Physically based material base class of BJS.
  31502. *
  31503. * This offers the main features of a standard PBR material.
  31504. * For more information, please refer to the documentation :
  31505. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  31506. */
  31507. abstract class PBRBaseMaterial extends PushMaterial {
  31508. /**
  31509. * Intensity of the direct lights e.g. the four lights available in your scene.
  31510. * This impacts both the direct diffuse and specular highlights.
  31511. */
  31512. protected _directIntensity: number;
  31513. /**
  31514. * Intensity of the emissive part of the material.
  31515. * This helps controlling the emissive effect without modifying the emissive color.
  31516. */
  31517. protected _emissiveIntensity: number;
  31518. /**
  31519. * Intensity of the environment e.g. how much the environment will light the object
  31520. * either through harmonics for rough material or through the refelction for shiny ones.
  31521. */
  31522. protected _environmentIntensity: number;
  31523. /**
  31524. * This is a special control allowing the reduction of the specular highlights coming from the
  31525. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  31526. */
  31527. protected _specularIntensity: number;
  31528. /**
  31529. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  31530. */
  31531. private _lightingInfos;
  31532. /**
  31533. * Debug Control allowing disabling the bump map on this material.
  31534. */
  31535. protected _disableBumpMap: boolean;
  31536. /**
  31537. * AKA Diffuse Texture in standard nomenclature.
  31538. */
  31539. protected _albedoTexture: BaseTexture;
  31540. /**
  31541. * AKA Occlusion Texture in other nomenclature.
  31542. */
  31543. protected _ambientTexture: BaseTexture;
  31544. /**
  31545. * AKA Occlusion Texture Intensity in other nomenclature.
  31546. */
  31547. protected _ambientTextureStrength: number;
  31548. /**
  31549. * Stores the alpha values in a texture.
  31550. */
  31551. protected _opacityTexture: BaseTexture;
  31552. /**
  31553. * Stores the reflection values in a texture.
  31554. */
  31555. protected _reflectionTexture: BaseTexture;
  31556. /**
  31557. * Stores the refraction values in a texture.
  31558. */
  31559. protected _refractionTexture: BaseTexture;
  31560. /**
  31561. * Stores the emissive values in a texture.
  31562. */
  31563. protected _emissiveTexture: BaseTexture;
  31564. /**
  31565. * AKA Specular texture in other nomenclature.
  31566. */
  31567. protected _reflectivityTexture: BaseTexture;
  31568. /**
  31569. * Used to switch from specular/glossiness to metallic/roughness workflow.
  31570. */
  31571. protected _metallicTexture: BaseTexture;
  31572. /**
  31573. * Specifies the metallic scalar of the metallic/roughness workflow.
  31574. * Can also be used to scale the metalness values of the metallic texture.
  31575. */
  31576. protected _metallic: number;
  31577. /**
  31578. * Specifies the roughness scalar of the metallic/roughness workflow.
  31579. * Can also be used to scale the roughness values of the metallic texture.
  31580. */
  31581. protected _roughness: number;
  31582. /**
  31583. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  31584. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  31585. */
  31586. protected _microSurfaceTexture: BaseTexture;
  31587. /**
  31588. * Stores surface normal data used to displace a mesh in a texture.
  31589. */
  31590. protected _bumpTexture: BaseTexture;
  31591. /**
  31592. * Stores the pre-calculated light information of a mesh in a texture.
  31593. */
  31594. protected _lightmapTexture: BaseTexture;
  31595. /**
  31596. * The color of a material in ambient lighting.
  31597. */
  31598. protected _ambientColor: Color3;
  31599. /**
  31600. * AKA Diffuse Color in other nomenclature.
  31601. */
  31602. protected _albedoColor: Color3;
  31603. /**
  31604. * AKA Specular Color in other nomenclature.
  31605. */
  31606. protected _reflectivityColor: Color3;
  31607. /**
  31608. * The color applied when light is reflected from a material.
  31609. */
  31610. protected _reflectionColor: Color3;
  31611. /**
  31612. * The color applied when light is emitted from a material.
  31613. */
  31614. protected _emissiveColor: Color3;
  31615. /**
  31616. * AKA Glossiness in other nomenclature.
  31617. */
  31618. protected _microSurface: number;
  31619. /**
  31620. * source material index of refraction (IOR)' / 'destination material IOR.
  31621. */
  31622. protected _indexOfRefraction: number;
  31623. /**
  31624. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  31625. */
  31626. protected _invertRefractionY: boolean;
  31627. /**
  31628. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  31629. * Materials half opaque for instance using refraction could benefit from this control.
  31630. */
  31631. protected _linkRefractionWithTransparency: boolean;
  31632. /**
  31633. * Specifies that the material will use the light map as a show map.
  31634. */
  31635. protected _useLightmapAsShadowmap: boolean;
  31636. /**
  31637. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  31638. * makes the reflect vector face the model (under horizon).
  31639. */
  31640. protected _useHorizonOcclusion: boolean;
  31641. /**
  31642. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  31643. * too much the area relying on ambient texture to define their ambient occlusion.
  31644. */
  31645. protected _useRadianceOcclusion: boolean;
  31646. /**
  31647. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  31648. */
  31649. protected _useAlphaFromAlbedoTexture: boolean;
  31650. /**
  31651. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  31652. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31653. */
  31654. protected _useSpecularOverAlpha: boolean;
  31655. /**
  31656. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  31657. */
  31658. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  31659. /**
  31660. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  31661. */
  31662. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  31663. /**
  31664. * Specifies if the metallic texture contains the roughness information in its green channel.
  31665. */
  31666. protected _useRoughnessFromMetallicTextureGreen: boolean;
  31667. /**
  31668. * Specifies if the metallic texture contains the metallness information in its blue channel.
  31669. */
  31670. protected _useMetallnessFromMetallicTextureBlue: boolean;
  31671. /**
  31672. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  31673. */
  31674. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  31675. /**
  31676. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  31677. */
  31678. protected _useAmbientInGrayScale: boolean;
  31679. /**
  31680. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  31681. * The material will try to infer what glossiness each pixel should be.
  31682. */
  31683. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  31684. /**
  31685. * BJS is using an harcoded light falloff based on a manually sets up range.
  31686. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  31687. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  31688. */
  31689. protected _usePhysicalLightFalloff: boolean;
  31690. /**
  31691. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31692. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31693. */
  31694. protected _useRadianceOverAlpha: boolean;
  31695. /**
  31696. * Allows using an object space normal map (instead of tangent space).
  31697. */
  31698. protected _useObjectSpaceNormalMap: boolean;
  31699. /**
  31700. * Allows using the bump map in parallax mode.
  31701. */
  31702. protected _useParallax: boolean;
  31703. /**
  31704. * Allows using the bump map in parallax occlusion mode.
  31705. */
  31706. protected _useParallaxOcclusion: boolean;
  31707. /**
  31708. * Controls the scale bias of the parallax mode.
  31709. */
  31710. protected _parallaxScaleBias: number;
  31711. /**
  31712. * If sets to true, disables all the lights affecting the material.
  31713. */
  31714. protected _disableLighting: boolean;
  31715. /**
  31716. * Number of Simultaneous lights allowed on the material.
  31717. */
  31718. protected _maxSimultaneousLights: number;
  31719. /**
  31720. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  31721. */
  31722. protected _invertNormalMapX: boolean;
  31723. /**
  31724. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  31725. */
  31726. protected _invertNormalMapY: boolean;
  31727. /**
  31728. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31729. */
  31730. protected _twoSidedLighting: boolean;
  31731. /**
  31732. * Defines the alpha limits in alpha test mode.
  31733. */
  31734. protected _alphaCutOff: number;
  31735. /**
  31736. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  31737. */
  31738. protected _forceAlphaTest: boolean;
  31739. /**
  31740. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  31741. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  31742. */
  31743. protected _useAlphaFresnel: boolean;
  31744. /**
  31745. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  31746. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  31747. */
  31748. protected _useLinearAlphaFresnel: boolean;
  31749. /**
  31750. * The transparency mode of the material.
  31751. */
  31752. protected _transparencyMode: Nullable<number>;
  31753. /**
  31754. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  31755. * from cos thetav and roughness:
  31756. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  31757. */
  31758. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  31759. /**
  31760. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  31761. */
  31762. protected _forceIrradianceInFragment: boolean;
  31763. /**
  31764. * Force normal to face away from face.
  31765. */
  31766. protected _forceNormalForward: boolean;
  31767. /**
  31768. * Enables specular anti aliasing in the PBR shader.
  31769. * It will both interacts on the Geometry for analytical and IBL lighting.
  31770. * It also prefilter the roughness map based on the bump values.
  31771. */
  31772. protected _enableSpecularAntiAliasing: boolean;
  31773. /**
  31774. * Default configuration related to image processing available in the PBR Material.
  31775. */
  31776. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31777. /**
  31778. * Keep track of the image processing observer to allow dispose and replace.
  31779. */
  31780. private _imageProcessingObserver;
  31781. /**
  31782. * Attaches a new image processing configuration to the PBR Material.
  31783. * @param configuration
  31784. */
  31785. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31786. /**
  31787. * Stores the available render targets.
  31788. */
  31789. private _renderTargets;
  31790. /**
  31791. * Sets the global ambient color for the material used in lighting calculations.
  31792. */
  31793. private _globalAmbientColor;
  31794. /**
  31795. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  31796. */
  31797. private _useLogarithmicDepth;
  31798. /**
  31799. * If set to true, no lighting calculations will be applied.
  31800. */
  31801. private _unlit;
  31802. /**
  31803. * Instantiates a new PBRMaterial instance.
  31804. *
  31805. * @param name The material name
  31806. * @param scene The scene the material will be use in.
  31807. */
  31808. constructor(name: string, scene: Scene);
  31809. /**
  31810. * Gets the name of the material class.
  31811. */
  31812. getClassName(): string;
  31813. /**
  31814. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  31815. */
  31816. /**
  31817. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  31818. */
  31819. useLogarithmicDepth: boolean;
  31820. /**
  31821. * Gets the current transparency mode.
  31822. */
  31823. /**
  31824. * Sets the transparency mode of the material.
  31825. */
  31826. transparencyMode: Nullable<number>;
  31827. /**
  31828. * Returns true if alpha blending should be disabled.
  31829. */
  31830. private readonly _disableAlphaBlending;
  31831. /**
  31832. * Specifies whether or not this material should be rendered in alpha blend mode.
  31833. */
  31834. needAlphaBlending(): boolean;
  31835. /**
  31836. * Specifies if the mesh will require alpha blending.
  31837. * @param mesh - BJS mesh.
  31838. */
  31839. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  31840. /**
  31841. * Specifies whether or not this material should be rendered in alpha test mode.
  31842. */
  31843. needAlphaTesting(): boolean;
  31844. /**
  31845. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  31846. */
  31847. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  31848. /**
  31849. * Gets the texture used for the alpha test.
  31850. */
  31851. getAlphaTestTexture(): BaseTexture;
  31852. /**
  31853. * Stores the reflectivity values based on metallic roughness workflow.
  31854. */
  31855. private static _scaledReflectivity;
  31856. /**
  31857. * Specifies that the submesh is ready to be used.
  31858. * @param mesh - BJS mesh.
  31859. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  31860. * @param useInstances - Specifies that instances should be used.
  31861. * @returns - boolean indicating that the submesh is ready or not.
  31862. */
  31863. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31864. /**
  31865. * Specifies if the material uses metallic roughness workflow.
  31866. * @returns boolean specifiying if the material uses metallic roughness workflow.
  31867. */
  31868. isMetallicWorkflow(): boolean;
  31869. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  31870. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  31871. /**
  31872. * Force shader compilation
  31873. */
  31874. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  31875. clipPlane: boolean;
  31876. }>): void;
  31877. /**
  31878. * Initializes the uniform buffer layout for the shader.
  31879. */
  31880. buildUniformLayout(): void;
  31881. /**
  31882. * Unbinds the textures.
  31883. */
  31884. unbind(): void;
  31885. /**
  31886. * Binds the submesh data.
  31887. * @param world - The world matrix.
  31888. * @param mesh - The BJS mesh.
  31889. * @param subMesh - A submesh of the BJS mesh.
  31890. */
  31891. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31892. /**
  31893. * Returns the animatable textures.
  31894. * @returns - Array of animatable textures.
  31895. */
  31896. getAnimatables(): IAnimatable[];
  31897. /**
  31898. * Returns the texture used for reflections.
  31899. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  31900. */
  31901. private _getReflectionTexture();
  31902. /**
  31903. * Returns the texture used for refraction or null if none is used.
  31904. * @returns - Refection texture if present. If no refraction texture and refraction
  31905. * is linked with transparency, returns environment texture. Otherwise, returns null.
  31906. */
  31907. private _getRefractionTexture();
  31908. /**
  31909. * Disposes the resources of the material.
  31910. * @param forceDisposeEffect - Forces the disposal of effects.
  31911. * @param forceDisposeTextures - Forces the disposal of all textures.
  31912. */
  31913. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31914. }
  31915. }
  31916. declare module BABYLON {
  31917. /**
  31918. * The Physically based simple base material of BJS.
  31919. *
  31920. * This enables better naming and convention enforcements on top of the pbrMaterial.
  31921. * It is used as the base class for both the specGloss and metalRough conventions.
  31922. */
  31923. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  31924. /**
  31925. * Number of Simultaneous lights allowed on the material.
  31926. */
  31927. maxSimultaneousLights: number;
  31928. /**
  31929. * If sets to true, disables all the lights affecting the material.
  31930. */
  31931. disableLighting: boolean;
  31932. /**
  31933. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  31934. */
  31935. environmentTexture: BaseTexture;
  31936. /**
  31937. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31938. */
  31939. invertNormalMapX: boolean;
  31940. /**
  31941. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31942. */
  31943. invertNormalMapY: boolean;
  31944. /**
  31945. * Normal map used in the model.
  31946. */
  31947. normalTexture: BaseTexture;
  31948. /**
  31949. * Emissivie color used to self-illuminate the model.
  31950. */
  31951. emissiveColor: Color3;
  31952. /**
  31953. * Emissivie texture used to self-illuminate the model.
  31954. */
  31955. emissiveTexture: BaseTexture;
  31956. /**
  31957. * Occlusion Channel Strenght.
  31958. */
  31959. occlusionStrength: number;
  31960. /**
  31961. * Occlusion Texture of the material (adding extra occlusion effects).
  31962. */
  31963. occlusionTexture: BaseTexture;
  31964. /**
  31965. * Defines the alpha limits in alpha test mode.
  31966. */
  31967. alphaCutOff: number;
  31968. /**
  31969. * Gets the current double sided mode.
  31970. */
  31971. /**
  31972. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31973. */
  31974. doubleSided: boolean;
  31975. lightmapTexture: BaseTexture;
  31976. useLightmapAsShadowmap: boolean;
  31977. /**
  31978. * Return the active textures of the material.
  31979. */
  31980. getActiveTextures(): BaseTexture[];
  31981. hasTexture(texture: BaseTexture): boolean;
  31982. /**
  31983. * Instantiates a new PBRMaterial instance.
  31984. *
  31985. * @param name The material name
  31986. * @param scene The scene the material will be use in.
  31987. */
  31988. constructor(name: string, scene: Scene);
  31989. getClassName(): string;
  31990. }
  31991. }
  31992. declare module BABYLON {
  31993. /**
  31994. * The Physically based material of BJS.
  31995. *
  31996. * This offers the main features of a standard PBR material.
  31997. * For more information, please refer to the documentation :
  31998. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  31999. */
  32000. class PBRMaterial extends PBRBaseMaterial {
  32001. private static _PBRMATERIAL_OPAQUE;
  32002. /**
  32003. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  32004. */
  32005. static readonly PBRMATERIAL_OPAQUE: number;
  32006. /**
  32007. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  32008. */
  32009. private static _PBRMATERIAL_ALPHATEST;
  32010. /**
  32011. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  32012. */
  32013. static readonly PBRMATERIAL_ALPHATEST: number;
  32014. /**
  32015. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32016. */
  32017. private static _PBRMATERIAL_ALPHABLEND;
  32018. /**
  32019. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32020. */
  32021. static readonly PBRMATERIAL_ALPHABLEND: number;
  32022. /**
  32023. * 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.
  32024. * They are also discarded below the alpha cutoff threshold to improve performances.
  32025. */
  32026. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  32027. /**
  32028. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32029. * They are also discarded below the alpha cutoff threshold to improve performances.
  32030. */
  32031. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  32032. /**
  32033. * Intensity of the direct lights e.g. the four lights available in your scene.
  32034. * This impacts both the direct diffuse and specular highlights.
  32035. */
  32036. directIntensity: number;
  32037. /**
  32038. * Intensity of the emissive part of the material.
  32039. * This helps controlling the emissive effect without modifying the emissive color.
  32040. */
  32041. emissiveIntensity: number;
  32042. /**
  32043. * Intensity of the environment e.g. how much the environment will light the object
  32044. * either through harmonics for rough material or through the refelction for shiny ones.
  32045. */
  32046. environmentIntensity: number;
  32047. /**
  32048. * This is a special control allowing the reduction of the specular highlights coming from the
  32049. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  32050. */
  32051. specularIntensity: number;
  32052. /**
  32053. * Debug Control allowing disabling the bump map on this material.
  32054. */
  32055. disableBumpMap: boolean;
  32056. /**
  32057. * AKA Diffuse Texture in standard nomenclature.
  32058. */
  32059. albedoTexture: BaseTexture;
  32060. /**
  32061. * AKA Occlusion Texture in other nomenclature.
  32062. */
  32063. ambientTexture: BaseTexture;
  32064. /**
  32065. * AKA Occlusion Texture Intensity in other nomenclature.
  32066. */
  32067. ambientTextureStrength: number;
  32068. /**
  32069. * Stores the alpha values in a texture.
  32070. */
  32071. opacityTexture: BaseTexture;
  32072. /**
  32073. * Stores the reflection values in a texture.
  32074. */
  32075. reflectionTexture: Nullable<BaseTexture>;
  32076. /**
  32077. * Stores the emissive values in a texture.
  32078. */
  32079. emissiveTexture: BaseTexture;
  32080. /**
  32081. * AKA Specular texture in other nomenclature.
  32082. */
  32083. reflectivityTexture: BaseTexture;
  32084. /**
  32085. * Used to switch from specular/glossiness to metallic/roughness workflow.
  32086. */
  32087. metallicTexture: BaseTexture;
  32088. /**
  32089. * Specifies the metallic scalar of the metallic/roughness workflow.
  32090. * Can also be used to scale the metalness values of the metallic texture.
  32091. */
  32092. metallic: number;
  32093. /**
  32094. * Specifies the roughness scalar of the metallic/roughness workflow.
  32095. * Can also be used to scale the roughness values of the metallic texture.
  32096. */
  32097. roughness: number;
  32098. /**
  32099. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  32100. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  32101. */
  32102. microSurfaceTexture: BaseTexture;
  32103. /**
  32104. * Stores surface normal data used to displace a mesh in a texture.
  32105. */
  32106. bumpTexture: BaseTexture;
  32107. /**
  32108. * Stores the pre-calculated light information of a mesh in a texture.
  32109. */
  32110. lightmapTexture: BaseTexture;
  32111. /**
  32112. * Stores the refracted light information in a texture.
  32113. */
  32114. refractionTexture: BaseTexture;
  32115. /**
  32116. * The color of a material in ambient lighting.
  32117. */
  32118. ambientColor: Color3;
  32119. /**
  32120. * AKA Diffuse Color in other nomenclature.
  32121. */
  32122. albedoColor: Color3;
  32123. /**
  32124. * AKA Specular Color in other nomenclature.
  32125. */
  32126. reflectivityColor: Color3;
  32127. /**
  32128. * The color reflected from the material.
  32129. */
  32130. reflectionColor: Color3;
  32131. /**
  32132. * The color emitted from the material.
  32133. */
  32134. emissiveColor: Color3;
  32135. /**
  32136. * AKA Glossiness in other nomenclature.
  32137. */
  32138. microSurface: number;
  32139. /**
  32140. * source material index of refraction (IOR)' / 'destination material IOR.
  32141. */
  32142. indexOfRefraction: number;
  32143. /**
  32144. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  32145. */
  32146. invertRefractionY: boolean;
  32147. /**
  32148. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  32149. * Materials half opaque for instance using refraction could benefit from this control.
  32150. */
  32151. linkRefractionWithTransparency: boolean;
  32152. useLightmapAsShadowmap: boolean;
  32153. /**
  32154. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  32155. */
  32156. useAlphaFromAlbedoTexture: boolean;
  32157. /**
  32158. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  32159. */
  32160. forceAlphaTest: boolean;
  32161. /**
  32162. * Defines the alpha limits in alpha test mode.
  32163. */
  32164. alphaCutOff: number;
  32165. /**
  32166. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  32167. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  32168. */
  32169. useSpecularOverAlpha: boolean;
  32170. /**
  32171. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  32172. */
  32173. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  32174. /**
  32175. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  32176. */
  32177. useRoughnessFromMetallicTextureAlpha: boolean;
  32178. /**
  32179. * Specifies if the metallic texture contains the roughness information in its green channel.
  32180. */
  32181. useRoughnessFromMetallicTextureGreen: boolean;
  32182. /**
  32183. * Specifies if the metallic texture contains the metallness information in its blue channel.
  32184. */
  32185. useMetallnessFromMetallicTextureBlue: boolean;
  32186. /**
  32187. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  32188. */
  32189. useAmbientOcclusionFromMetallicTextureRed: boolean;
  32190. /**
  32191. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  32192. */
  32193. useAmbientInGrayScale: boolean;
  32194. /**
  32195. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  32196. * The material will try to infer what glossiness each pixel should be.
  32197. */
  32198. useAutoMicroSurfaceFromReflectivityMap: boolean;
  32199. /**
  32200. * BJS is using an harcoded light falloff based on a manually sets up range.
  32201. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  32202. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  32203. */
  32204. usePhysicalLightFalloff: boolean;
  32205. /**
  32206. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  32207. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  32208. */
  32209. useRadianceOverAlpha: boolean;
  32210. /**
  32211. * Allows using an object space normal map (instead of tangent space).
  32212. */
  32213. useObjectSpaceNormalMap: boolean;
  32214. /**
  32215. * Allows using the bump map in parallax mode.
  32216. */
  32217. useParallax: boolean;
  32218. /**
  32219. * Allows using the bump map in parallax occlusion mode.
  32220. */
  32221. useParallaxOcclusion: boolean;
  32222. /**
  32223. * Controls the scale bias of the parallax mode.
  32224. */
  32225. parallaxScaleBias: number;
  32226. /**
  32227. * If sets to true, disables all the lights affecting the material.
  32228. */
  32229. disableLighting: boolean;
  32230. /**
  32231. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  32232. */
  32233. forceIrradianceInFragment: boolean;
  32234. /**
  32235. * Number of Simultaneous lights allowed on the material.
  32236. */
  32237. maxSimultaneousLights: number;
  32238. /**
  32239. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32240. */
  32241. invertNormalMapX: boolean;
  32242. /**
  32243. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32244. */
  32245. invertNormalMapY: boolean;
  32246. /**
  32247. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32248. */
  32249. twoSidedLighting: boolean;
  32250. /**
  32251. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32252. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  32253. */
  32254. useAlphaFresnel: boolean;
  32255. /**
  32256. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32257. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  32258. */
  32259. useLinearAlphaFresnel: boolean;
  32260. /**
  32261. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32262. * And/Or occlude the blended part.
  32263. */
  32264. environmentBRDFTexture: Nullable<BaseTexture>;
  32265. /**
  32266. * Force normal to face away from face.
  32267. */
  32268. forceNormalForward: boolean;
  32269. /**
  32270. * Enables specular anti aliasing in the PBR shader.
  32271. * It will both interacts on the Geometry for analytical and IBL lighting.
  32272. * It also prefilter the roughness map based on the bump values.
  32273. */
  32274. enableSpecularAntiAliasing: boolean;
  32275. /**
  32276. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  32277. * makes the reflect vector face the model (under horizon).
  32278. */
  32279. useHorizonOcclusion: boolean;
  32280. /**
  32281. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  32282. * too much the area relying on ambient texture to define their ambient occlusion.
  32283. */
  32284. useRadianceOcclusion: boolean;
  32285. /**
  32286. * If set to true, no lighting calculations will be applied.
  32287. */
  32288. unlit: boolean;
  32289. /**
  32290. * Gets the image processing configuration used either in this material.
  32291. */
  32292. /**
  32293. * Sets the Default image processing configuration used either in the this material.
  32294. *
  32295. * If sets to null, the scene one is in use.
  32296. */
  32297. imageProcessingConfiguration: ImageProcessingConfiguration;
  32298. /**
  32299. * Gets wether the color curves effect is enabled.
  32300. */
  32301. /**
  32302. * Sets wether the color curves effect is enabled.
  32303. */
  32304. cameraColorCurvesEnabled: boolean;
  32305. /**
  32306. * Gets wether the color grading effect is enabled.
  32307. */
  32308. /**
  32309. * Gets wether the color grading effect is enabled.
  32310. */
  32311. cameraColorGradingEnabled: boolean;
  32312. /**
  32313. * Gets wether tonemapping is enabled or not.
  32314. */
  32315. /**
  32316. * Sets wether tonemapping is enabled or not
  32317. */
  32318. cameraToneMappingEnabled: boolean;
  32319. /**
  32320. * The camera exposure used on this material.
  32321. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32322. * This corresponds to a photographic exposure.
  32323. */
  32324. /**
  32325. * The camera exposure used on this material.
  32326. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32327. * This corresponds to a photographic exposure.
  32328. */
  32329. cameraExposure: number;
  32330. /**
  32331. * Gets The camera contrast used on this material.
  32332. */
  32333. /**
  32334. * Sets The camera contrast used on this material.
  32335. */
  32336. cameraContrast: number;
  32337. /**
  32338. * Gets the Color Grading 2D Lookup Texture.
  32339. */
  32340. /**
  32341. * Sets the Color Grading 2D Lookup Texture.
  32342. */
  32343. cameraColorGradingTexture: Nullable<BaseTexture>;
  32344. /**
  32345. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32346. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32347. * 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;
  32348. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32349. */
  32350. /**
  32351. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32352. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32353. * 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;
  32354. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32355. */
  32356. cameraColorCurves: Nullable<ColorCurves>;
  32357. /**
  32358. * Instantiates a new PBRMaterial instance.
  32359. *
  32360. * @param name The material name
  32361. * @param scene The scene the material will be use in.
  32362. */
  32363. constructor(name: string, scene: Scene);
  32364. /**
  32365. * Returns the name of this material class.
  32366. */
  32367. getClassName(): string;
  32368. /**
  32369. * Returns an array of the actively used textures.
  32370. * @returns - Array of BaseTextures
  32371. */
  32372. getActiveTextures(): BaseTexture[];
  32373. /**
  32374. * Checks to see if a texture is used in the material.
  32375. * @param texture - Base texture to use.
  32376. * @returns - Boolean specifying if a texture is used in the material.
  32377. */
  32378. hasTexture(texture: BaseTexture): boolean;
  32379. /**
  32380. * Makes a duplicate of the current material.
  32381. * @param name - name to use for the new material.
  32382. */
  32383. clone(name: string): PBRMaterial;
  32384. /**
  32385. * Serializes this PBR Material.
  32386. * @returns - An object with the serialized material.
  32387. */
  32388. serialize(): any;
  32389. /**
  32390. * Parses a PBR Material from a serialized object.
  32391. * @param source - Serialized object.
  32392. * @param scene - BJS scene instance.
  32393. * @param rootUrl - url for the scene object
  32394. * @returns - PBRMaterial
  32395. */
  32396. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  32397. }
  32398. }
  32399. declare module BABYLON {
  32400. /**
  32401. * The PBR material of BJS following the metal roughness convention.
  32402. *
  32403. * This fits to the PBR convention in the GLTF definition:
  32404. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  32405. */
  32406. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  32407. /**
  32408. * The base color has two different interpretations depending on the value of metalness.
  32409. * When the material is a metal, the base color is the specific measured reflectance value
  32410. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  32411. * of the material.
  32412. */
  32413. baseColor: Color3;
  32414. /**
  32415. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  32416. * well as opacity information in the alpha channel.
  32417. */
  32418. baseTexture: BaseTexture;
  32419. /**
  32420. * Specifies the metallic scalar value of the material.
  32421. * Can also be used to scale the metalness values of the metallic texture.
  32422. */
  32423. metallic: number;
  32424. /**
  32425. * Specifies the roughness scalar value of the material.
  32426. * Can also be used to scale the roughness values of the metallic texture.
  32427. */
  32428. roughness: number;
  32429. /**
  32430. * Texture containing both the metallic value in the B channel and the
  32431. * roughness value in the G channel to keep better precision.
  32432. */
  32433. metallicRoughnessTexture: BaseTexture;
  32434. /**
  32435. * Instantiates a new PBRMetalRoughnessMaterial instance.
  32436. *
  32437. * @param name The material name
  32438. * @param scene The scene the material will be use in.
  32439. */
  32440. constructor(name: string, scene: Scene);
  32441. /**
  32442. * Return the currrent class name of the material.
  32443. */
  32444. getClassName(): string;
  32445. /**
  32446. * Return the active textures of the material.
  32447. */
  32448. getActiveTextures(): BaseTexture[];
  32449. /**
  32450. * Checks to see if a texture is used in the material.
  32451. * @param texture - Base texture to use.
  32452. * @returns - Boolean specifying if a texture is used in the material.
  32453. */
  32454. hasTexture(texture: BaseTexture): boolean;
  32455. /**
  32456. * Makes a duplicate of the current material.
  32457. * @param name - name to use for the new material.
  32458. */
  32459. clone(name: string): PBRMetallicRoughnessMaterial;
  32460. /**
  32461. * Serialize the material to a parsable JSON object.
  32462. */
  32463. serialize(): any;
  32464. /**
  32465. * Parses a JSON object correponding to the serialize function.
  32466. */
  32467. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  32468. }
  32469. }
  32470. declare module BABYLON {
  32471. /**
  32472. * The PBR material of BJS following the specular glossiness convention.
  32473. *
  32474. * This fits to the PBR convention in the GLTF definition:
  32475. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  32476. */
  32477. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  32478. /**
  32479. * Specifies the diffuse color of the material.
  32480. */
  32481. diffuseColor: Color3;
  32482. /**
  32483. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  32484. * channel.
  32485. */
  32486. diffuseTexture: BaseTexture;
  32487. /**
  32488. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  32489. */
  32490. specularColor: Color3;
  32491. /**
  32492. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  32493. */
  32494. glossiness: number;
  32495. /**
  32496. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  32497. */
  32498. specularGlossinessTexture: BaseTexture;
  32499. /**
  32500. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  32501. *
  32502. * @param name The material name
  32503. * @param scene The scene the material will be use in.
  32504. */
  32505. constructor(name: string, scene: Scene);
  32506. /**
  32507. * Return the currrent class name of the material.
  32508. */
  32509. getClassName(): string;
  32510. /**
  32511. * Return the active textures of the material.
  32512. */
  32513. getActiveTextures(): BaseTexture[];
  32514. /**
  32515. * Checks to see if a texture is used in the material.
  32516. * @param texture - Base texture to use.
  32517. * @returns - Boolean specifying if a texture is used in the material.
  32518. */
  32519. hasTexture(texture: BaseTexture): boolean;
  32520. /**
  32521. * Makes a duplicate of the current material.
  32522. * @param name - name to use for the new material.
  32523. */
  32524. clone(name: string): PBRSpecularGlossinessMaterial;
  32525. /**
  32526. * Serialize the material to a parsable JSON object.
  32527. */
  32528. serialize(): any;
  32529. /**
  32530. * Parses a JSON object correponding to the serialize function.
  32531. */
  32532. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  32533. }
  32534. }
  32535. declare module BABYLON {
  32536. class BaseTexture {
  32537. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32538. name: string;
  32539. private _hasAlpha;
  32540. hasAlpha: boolean;
  32541. getAlphaFromRGB: boolean;
  32542. level: number;
  32543. coordinatesIndex: number;
  32544. private _coordinatesMode;
  32545. /**
  32546. * How a texture is mapped.
  32547. *
  32548. * | Value | Type | Description |
  32549. * | ----- | ----------------------------------- | ----------- |
  32550. * | 0 | EXPLICIT_MODE | |
  32551. * | 1 | SPHERICAL_MODE | |
  32552. * | 2 | PLANAR_MODE | |
  32553. * | 3 | CUBIC_MODE | |
  32554. * | 4 | PROJECTION_MODE | |
  32555. * | 5 | SKYBOX_MODE | |
  32556. * | 6 | INVCUBIC_MODE | |
  32557. * | 7 | EQUIRECTANGULAR_MODE | |
  32558. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32559. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32560. */
  32561. coordinatesMode: number;
  32562. /**
  32563. * | Value | Type | Description |
  32564. * | ----- | ------------------ | ----------- |
  32565. * | 0 | CLAMP_ADDRESSMODE | |
  32566. * | 1 | WRAP_ADDRESSMODE | |
  32567. * | 2 | MIRROR_ADDRESSMODE | |
  32568. */
  32569. wrapU: number;
  32570. /**
  32571. * | Value | Type | Description |
  32572. * | ----- | ------------------ | ----------- |
  32573. * | 0 | CLAMP_ADDRESSMODE | |
  32574. * | 1 | WRAP_ADDRESSMODE | |
  32575. * | 2 | MIRROR_ADDRESSMODE | |
  32576. */
  32577. wrapV: number;
  32578. /**
  32579. * | Value | Type | Description |
  32580. * | ----- | ------------------ | ----------- |
  32581. * | 0 | CLAMP_ADDRESSMODE | |
  32582. * | 1 | WRAP_ADDRESSMODE | |
  32583. * | 2 | MIRROR_ADDRESSMODE | |
  32584. */
  32585. wrapR: number;
  32586. anisotropicFilteringLevel: number;
  32587. isCube: boolean;
  32588. is3D: boolean;
  32589. gammaSpace: boolean;
  32590. invertZ: boolean;
  32591. lodLevelInAlpha: boolean;
  32592. lodGenerationOffset: number;
  32593. lodGenerationScale: number;
  32594. isRenderTarget: boolean;
  32595. readonly uid: string;
  32596. toString(): string;
  32597. getClassName(): string;
  32598. animations: Animation[];
  32599. /**
  32600. * An event triggered when the texture is disposed.
  32601. */
  32602. onDisposeObservable: Observable<BaseTexture>;
  32603. private _onDisposeObserver;
  32604. onDispose: () => void;
  32605. delayLoadState: number;
  32606. private _scene;
  32607. _texture: Nullable<InternalTexture>;
  32608. private _uid;
  32609. readonly isBlocking: boolean;
  32610. constructor(scene: Nullable<Scene>);
  32611. getScene(): Nullable<Scene>;
  32612. getTextureMatrix(): Matrix;
  32613. getReflectionTextureMatrix(): Matrix;
  32614. getInternalTexture(): Nullable<InternalTexture>;
  32615. isReadyOrNotBlocking(): boolean;
  32616. isReady(): boolean;
  32617. getSize(): ISize;
  32618. getBaseSize(): ISize;
  32619. scale(ratio: number): void;
  32620. readonly canRescale: boolean;
  32621. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  32622. _rebuild(): void;
  32623. delayLoad(): void;
  32624. clone(): Nullable<BaseTexture>;
  32625. readonly textureType: number;
  32626. readonly textureFormat: number;
  32627. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  32628. releaseInternalTexture(): void;
  32629. sphericalPolynomial: Nullable<SphericalPolynomial>;
  32630. readonly _lodTextureHigh: Nullable<BaseTexture>;
  32631. readonly _lodTextureMid: Nullable<BaseTexture>;
  32632. readonly _lodTextureLow: Nullable<BaseTexture>;
  32633. dispose(): void;
  32634. serialize(): any;
  32635. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  32636. }
  32637. }
  32638. declare module BABYLON {
  32639. /**
  32640. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  32641. * It can help converting any input color in a desired output one. This can then be used to create effects
  32642. * from sepia, black and white to sixties or futuristic rendering...
  32643. *
  32644. * The only supported format is currently 3dl.
  32645. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  32646. */
  32647. class ColorGradingTexture extends BaseTexture {
  32648. /**
  32649. * The current texture matrix. (will always be identity in color grading texture)
  32650. */
  32651. private _textureMatrix;
  32652. /**
  32653. * The texture URL.
  32654. */
  32655. url: string;
  32656. /**
  32657. * Empty line regex stored for GC.
  32658. */
  32659. private static _noneEmptyLineRegex;
  32660. private _engine;
  32661. /**
  32662. * Instantiates a ColorGradingTexture from the following parameters.
  32663. *
  32664. * @param url The location of the color gradind data (currently only supporting 3dl)
  32665. * @param scene The scene the texture will be used in
  32666. */
  32667. constructor(url: string, scene: Scene);
  32668. /**
  32669. * Returns the texture matrix used in most of the material.
  32670. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  32671. */
  32672. getTextureMatrix(): Matrix;
  32673. /**
  32674. * Occurs when the file being loaded is a .3dl LUT file.
  32675. */
  32676. private load3dlTexture();
  32677. /**
  32678. * Starts the loading process of the texture.
  32679. */
  32680. private loadTexture();
  32681. /**
  32682. * Clones the color gradind texture.
  32683. */
  32684. clone(): ColorGradingTexture;
  32685. /**
  32686. * Called during delayed load for textures.
  32687. */
  32688. delayLoad(): void;
  32689. /**
  32690. * Parses a color grading texture serialized by Babylon.
  32691. * @param parsedTexture The texture information being parsedTexture
  32692. * @param scene The scene to load the texture in
  32693. * @param rootUrl The root url of the data assets to load
  32694. * @return A color gradind texture
  32695. */
  32696. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  32697. /**
  32698. * Serializes the LUT texture to json format.
  32699. */
  32700. serialize(): any;
  32701. }
  32702. }
  32703. declare module BABYLON {
  32704. class CubeTexture extends BaseTexture {
  32705. url: string;
  32706. coordinatesMode: number;
  32707. /**
  32708. * Gets or sets the center of the bounding box associated with the cube texture
  32709. * It must define where the camera used to render the texture was set
  32710. */
  32711. boundingBoxPosition: Vector3;
  32712. private _boundingBoxSize;
  32713. /**
  32714. * Gets or sets the size of the bounding box associated with the cube texture
  32715. * When defined, the cubemap will switch to local mode
  32716. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  32717. * @example https://www.babylonjs-playground.com/#RNASML
  32718. */
  32719. boundingBoxSize: Vector3;
  32720. protected _rotationY: number;
  32721. /**
  32722. * Gets texture matrix rotation angle around Y axis radians.
  32723. */
  32724. /**
  32725. * Sets texture matrix rotation angle around Y axis in radians.
  32726. */
  32727. rotationY: number;
  32728. private _noMipmap;
  32729. private _files;
  32730. private _extensions;
  32731. private _textureMatrix;
  32732. private _format;
  32733. private _prefiltered;
  32734. private _createPolynomials;
  32735. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  32736. /**
  32737. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  32738. * @param url defines the url of the prefiltered texture
  32739. * @param scene defines the scene the texture is attached to
  32740. * @param forcedExtension defines the extension of the file if different from the url
  32741. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  32742. * @return the prefiltered texture
  32743. */
  32744. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  32745. /**
  32746. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  32747. * as prefiltered data.
  32748. * @param rootUrl defines the url of the texture or the root name of the six images
  32749. * @param scene defines the scene the texture is attached to
  32750. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  32751. * @param noMipmap defines if mipmaps should be created or not
  32752. * @param files defines the six files to load for the different faces
  32753. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  32754. * @param onError defines a callback triggered in case of error during load
  32755. * @param format defines the internal format to use for the texture once loaded
  32756. * @param prefiltered defines whether or not the texture is created from prefiltered data
  32757. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  32758. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  32759. * @return the cube texture
  32760. */
  32761. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean);
  32762. delayLoad(): void;
  32763. getReflectionTextureMatrix(): Matrix;
  32764. setReflectionTextureMatrix(value: Matrix): void;
  32765. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  32766. clone(): CubeTexture;
  32767. }
  32768. }
  32769. declare module BABYLON {
  32770. /**
  32771. * A class extending {BABYLON.Texture} allowing drawing on a texture
  32772. * @see http://doc.babylonjs.com/how_to/dynamictexture
  32773. */
  32774. class DynamicTexture extends Texture {
  32775. private _generateMipMaps;
  32776. private _canvas;
  32777. private _context;
  32778. private _engine;
  32779. /**
  32780. * Creates a {BABYLON.DynamicTexture}
  32781. * @param name defines the name of the texture
  32782. * @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
  32783. * @param scene defines the scene where you want the texture
  32784. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  32785. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  32786. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  32787. */
  32788. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  32789. /**
  32790. * Gets the current state of canRescale
  32791. */
  32792. readonly canRescale: boolean;
  32793. private _recreate(textureSize);
  32794. /**
  32795. * Scales the texture
  32796. * @param ratio the scale factor to apply to both width and height
  32797. */
  32798. scale(ratio: number): void;
  32799. /**
  32800. * Resizes the texture
  32801. * @param width the new width
  32802. * @param height the new height
  32803. */
  32804. scaleTo(width: number, height: number): void;
  32805. /**
  32806. * Gets the context of the canvas used by the texture
  32807. * @returns the canvas context of the dynamic texture
  32808. */
  32809. getContext(): CanvasRenderingContext2D;
  32810. /**
  32811. * Clears the texture
  32812. */
  32813. clear(): void;
  32814. /**
  32815. * Updates the texture
  32816. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  32817. */
  32818. update(invertY?: boolean): void;
  32819. /**
  32820. * Draws text onto the texture
  32821. * @param text defines the text to be drawn
  32822. * @param x defines the placement of the text from the left
  32823. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  32824. * @param font defines the font to be used with font-style, font-size, font-name
  32825. * @param color defines the color used for the text
  32826. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  32827. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  32828. * @param update defines whether texture is immediately update (default is true)
  32829. */
  32830. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  32831. /**
  32832. * Clones the texture
  32833. * @returns the clone of the texture.
  32834. */
  32835. clone(): DynamicTexture;
  32836. /** @hidden */
  32837. _rebuild(): void;
  32838. }
  32839. }
  32840. declare module BABYLON {
  32841. /**
  32842. * This represents a texture coming from an HDR input.
  32843. *
  32844. * The only supported format is currently panorama picture stored in RGBE format.
  32845. * Example of such files can be found on HDRLib: http://hdrlib.com/
  32846. */
  32847. class HDRCubeTexture extends BaseTexture {
  32848. private static _facesMapping;
  32849. private _generateHarmonics;
  32850. private _noMipmap;
  32851. private _textureMatrix;
  32852. private _size;
  32853. private _onLoad;
  32854. private _onError;
  32855. /**
  32856. * The texture URL.
  32857. */
  32858. url: string;
  32859. /**
  32860. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  32861. */
  32862. coordinatesMode: number;
  32863. protected _isBlocking: boolean;
  32864. /**
  32865. * Gets wether or not the texture is blocking during loading.
  32866. */
  32867. /**
  32868. * Sets wether or not the texture is blocking during loading.
  32869. */
  32870. isBlocking: boolean;
  32871. protected _rotationY: number;
  32872. /**
  32873. * Gets texture matrix rotation angle around Y axis radians.
  32874. */
  32875. /**
  32876. * Sets texture matrix rotation angle around Y axis in radians.
  32877. */
  32878. rotationY: number;
  32879. /**
  32880. * Gets or sets the center of the bounding box associated with the cube texture
  32881. * It must define where the camera used to render the texture was set
  32882. */
  32883. boundingBoxPosition: Vector3;
  32884. private _boundingBoxSize;
  32885. /**
  32886. * Gets or sets the size of the bounding box associated with the cube texture
  32887. * When defined, the cubemap will switch to local mode
  32888. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  32889. * @example https://www.babylonjs-playground.com/#RNASML
  32890. */
  32891. boundingBoxSize: Vector3;
  32892. /**
  32893. * Instantiates an HDRTexture from the following parameters.
  32894. *
  32895. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  32896. * @param scene The scene the texture will be used in
  32897. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  32898. * @param noMipmap Forces to not generate the mipmap if true
  32899. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  32900. * @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)
  32901. * @param reserved Reserved flag for internal use.
  32902. */
  32903. 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>);
  32904. /**
  32905. * Occurs when the file is raw .hdr file.
  32906. */
  32907. private loadTexture();
  32908. clone(): HDRCubeTexture;
  32909. delayLoad(): void;
  32910. getReflectionTextureMatrix(): Matrix;
  32911. setReflectionTextureMatrix(value: Matrix): void;
  32912. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  32913. serialize(): any;
  32914. }
  32915. }
  32916. declare module BABYLON {
  32917. /**
  32918. * Class used to store data associated with WebGL texture data for the engine
  32919. * This class should not be used directly
  32920. */
  32921. class InternalTexture implements IInternalTextureTracker {
  32922. /**
  32923. * The source of the texture data is unknown
  32924. */
  32925. static DATASOURCE_UNKNOWN: number;
  32926. /**
  32927. * Texture data comes from an URL
  32928. */
  32929. static DATASOURCE_URL: number;
  32930. /**
  32931. * Texture data is only used for temporary storage
  32932. */
  32933. static DATASOURCE_TEMP: number;
  32934. /**
  32935. * Texture data comes from raw data (ArrayBuffer)
  32936. */
  32937. static DATASOURCE_RAW: number;
  32938. /**
  32939. * Texture content is dynamic (video or dynamic texture)
  32940. */
  32941. static DATASOURCE_DYNAMIC: number;
  32942. /**
  32943. * Texture content is generated by rendering to it
  32944. */
  32945. static DATASOURCE_RENDERTARGET: number;
  32946. /**
  32947. * Texture content is part of a multi render target process
  32948. */
  32949. static DATASOURCE_MULTIRENDERTARGET: number;
  32950. /**
  32951. * Texture data comes from a cube data file
  32952. */
  32953. static DATASOURCE_CUBE: number;
  32954. /**
  32955. * Texture data comes from a raw cube data
  32956. */
  32957. static DATASOURCE_CUBERAW: number;
  32958. /**
  32959. * Texture data come from a prefiltered cube data file
  32960. */
  32961. static DATASOURCE_CUBEPREFILTERED: number;
  32962. /**
  32963. * Texture content is raw 3D data
  32964. */
  32965. static DATASOURCE_RAW3D: number;
  32966. /**
  32967. * Texture content is a depth texture
  32968. */
  32969. static DATASOURCE_DEPTHTEXTURE: number;
  32970. /**
  32971. * Defines if the texture is ready
  32972. */
  32973. isReady: boolean;
  32974. /**
  32975. * Defines if the texture is a cube texture
  32976. */
  32977. isCube: boolean;
  32978. /**
  32979. * Defines if the texture contains 3D data
  32980. */
  32981. is3D: boolean;
  32982. /**
  32983. * Gets the URL used to load this texture
  32984. */
  32985. url: string;
  32986. /**
  32987. * Gets the sampling mode of the texture
  32988. */
  32989. samplingMode: number;
  32990. /**
  32991. * Gets a boolean indicating if the texture needs mipmaps generation
  32992. */
  32993. generateMipMaps: boolean;
  32994. /**
  32995. * Gets the number of samples used by the texture (WebGL2+ only)
  32996. */
  32997. samples: number;
  32998. /**
  32999. * Gets the type of the texture
  33000. */
  33001. type: number;
  33002. /**
  33003. * Gets the format of the texture
  33004. */
  33005. format: number;
  33006. /**
  33007. * Observable called when the texture is loaded
  33008. */
  33009. onLoadedObservable: Observable<InternalTexture>;
  33010. /**
  33011. * Gets the width of the texture
  33012. */
  33013. width: number;
  33014. /**
  33015. * Gets the height of the texture
  33016. */
  33017. height: number;
  33018. /**
  33019. * Gets the depth of the texture
  33020. */
  33021. depth: number;
  33022. /**
  33023. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33024. */
  33025. baseWidth: number;
  33026. /**
  33027. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33028. */
  33029. baseHeight: number;
  33030. /**
  33031. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33032. */
  33033. baseDepth: number;
  33034. /**
  33035. * Gets a boolean indicating if the texture is inverted on Y axis
  33036. */
  33037. invertY: boolean;
  33038. /**
  33039. * Gets or set the previous tracker in the list
  33040. */
  33041. previous: Nullable<IInternalTextureTracker>;
  33042. /**
  33043. * Gets or set the next tracker in the list
  33044. */
  33045. next: Nullable<IInternalTextureTracker>;
  33046. /** @hidden */
  33047. _initialSlot: number;
  33048. /** @hidden */
  33049. _designatedSlot: number;
  33050. /** @hidden */
  33051. _dataSource: number;
  33052. /** @hidden */
  33053. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  33054. /** @hidden */
  33055. _bufferView: Nullable<ArrayBufferView>;
  33056. /** @hidden */
  33057. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33058. /** @hidden */
  33059. _size: number;
  33060. /** @hidden */
  33061. _extension: string;
  33062. /** @hidden */
  33063. _files: Nullable<string[]>;
  33064. /** @hidden */
  33065. _workingCanvas: HTMLCanvasElement;
  33066. /** @hidden */
  33067. _workingContext: CanvasRenderingContext2D;
  33068. /** @hidden */
  33069. _framebuffer: Nullable<WebGLFramebuffer>;
  33070. /** @hidden */
  33071. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33072. /** @hidden */
  33073. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33074. /** @hidden */
  33075. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33076. /** @hidden */
  33077. _attachments: Nullable<number[]>;
  33078. /** @hidden */
  33079. _cachedCoordinatesMode: Nullable<number>;
  33080. /** @hidden */
  33081. _cachedWrapU: Nullable<number>;
  33082. /** @hidden */
  33083. _cachedWrapV: Nullable<number>;
  33084. /** @hidden */
  33085. _cachedWrapR: Nullable<number>;
  33086. /** @hidden */
  33087. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33088. /** @hidden */
  33089. _isDisabled: boolean;
  33090. /** @hidden */
  33091. _compression: Nullable<string>;
  33092. /** @hidden */
  33093. _generateStencilBuffer: boolean;
  33094. /** @hidden */
  33095. _generateDepthBuffer: boolean;
  33096. /** @hidden */
  33097. _comparisonFunction: number;
  33098. /** @hidden */
  33099. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33100. /** @hidden */
  33101. _lodGenerationScale: number;
  33102. /** @hidden */
  33103. _lodGenerationOffset: number;
  33104. /** @hidden */
  33105. _lodTextureHigh: BaseTexture;
  33106. /** @hidden */
  33107. _lodTextureMid: BaseTexture;
  33108. /** @hidden */
  33109. _lodTextureLow: BaseTexture;
  33110. /** @hidden */
  33111. _webGLTexture: Nullable<WebGLTexture>;
  33112. /** @hidden */
  33113. _references: number;
  33114. private _engine;
  33115. /**
  33116. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  33117. */
  33118. readonly dataSource: number;
  33119. /**
  33120. * Creates a new InternalTexture
  33121. * @param engine defines the engine to use
  33122. * @param dataSource defines the type of data that will be used
  33123. */
  33124. constructor(engine: Engine, dataSource: number);
  33125. /**
  33126. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  33127. */
  33128. incrementReferences(): void;
  33129. /**
  33130. * Change the size of the texture (not the size of the content)
  33131. * @param width defines the new width
  33132. * @param height defines the new height
  33133. * @param depth defines the new depth (1 by default)
  33134. */
  33135. updateSize(width: int, height: int, depth?: int): void;
  33136. /** @hidden */
  33137. _rebuild(): void;
  33138. private _swapAndDie(target);
  33139. /**
  33140. * Dispose the current allocated resources
  33141. */
  33142. dispose(): void;
  33143. }
  33144. }
  33145. declare module BABYLON {
  33146. /**
  33147. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  33148. */
  33149. interface IInternalTextureTracker {
  33150. /**
  33151. * Gets or set the previous tracker in the list
  33152. */
  33153. previous: Nullable<IInternalTextureTracker>;
  33154. /**
  33155. * Gets or set the next tracker in the list
  33156. */
  33157. next: Nullable<IInternalTextureTracker>;
  33158. }
  33159. /**
  33160. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  33161. */
  33162. class DummyInternalTextureTracker {
  33163. /**
  33164. * Gets or set the previous tracker in the list
  33165. */
  33166. previous: Nullable<IInternalTextureTracker>;
  33167. /**
  33168. * Gets or set the next tracker in the list
  33169. */
  33170. next: Nullable<IInternalTextureTracker>;
  33171. }
  33172. }
  33173. declare module BABYLON {
  33174. class MirrorTexture extends RenderTargetTexture {
  33175. private scene;
  33176. mirrorPlane: Plane;
  33177. private _transformMatrix;
  33178. private _mirrorMatrix;
  33179. private _savedViewMatrix;
  33180. private _blurX;
  33181. private _blurY;
  33182. private _adaptiveBlurKernel;
  33183. private _blurKernelX;
  33184. private _blurKernelY;
  33185. private _blurRatio;
  33186. blurRatio: number;
  33187. adaptiveBlurKernel: number;
  33188. blurKernel: number;
  33189. blurKernelX: number;
  33190. blurKernelY: number;
  33191. private _autoComputeBlurKernel();
  33192. protected _onRatioRescale(): void;
  33193. private _updateGammaSpace();
  33194. private _imageProcessingConfigChangeObserver;
  33195. constructor(name: string, size: number | {
  33196. width: number;
  33197. height: number;
  33198. } | {
  33199. ratio: number;
  33200. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  33201. private _preparePostProcesses();
  33202. clone(): MirrorTexture;
  33203. serialize(): any;
  33204. dispose(): void;
  33205. }
  33206. }
  33207. declare module BABYLON {
  33208. interface IMultiRenderTargetOptions {
  33209. generateMipMaps?: boolean;
  33210. types?: number[];
  33211. samplingModes?: number[];
  33212. generateDepthBuffer?: boolean;
  33213. generateStencilBuffer?: boolean;
  33214. generateDepthTexture?: boolean;
  33215. textureCount?: number;
  33216. doNotChangeAspectRatio?: boolean;
  33217. defaultType?: number;
  33218. }
  33219. class MultiRenderTarget extends RenderTargetTexture {
  33220. private _internalTextures;
  33221. private _textures;
  33222. readonly isSupported: boolean;
  33223. private _multiRenderTargetOptions;
  33224. readonly textures: Texture[];
  33225. readonly depthTexture: Texture;
  33226. wrapU: number;
  33227. wrapV: number;
  33228. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  33229. _rebuild(): void;
  33230. private _createInternalTextures();
  33231. private _createTextures();
  33232. samples: number;
  33233. resize(size: any): void;
  33234. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  33235. dispose(): void;
  33236. releaseInternalTextures(): void;
  33237. }
  33238. }
  33239. declare module BABYLON {
  33240. class RawTexture extends Texture {
  33241. format: number;
  33242. private _engine;
  33243. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  33244. update(data: ArrayBufferView): void;
  33245. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33246. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33247. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33248. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33249. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33250. }
  33251. }
  33252. declare module BABYLON {
  33253. /**
  33254. * Class used to store 3D textures containing user data
  33255. */
  33256. class RawTexture3D extends Texture {
  33257. /** Gets or sets the texture format to use*/
  33258. format: number;
  33259. private _engine;
  33260. /**
  33261. * Create a new RawTexture3D
  33262. * @param data defines the data of the texture
  33263. * @param width defines the width of the texture
  33264. * @param height defines the height of the texture
  33265. * @param depth defines the depth of the texture
  33266. * @param format defines the texture format to use
  33267. * @param scene defines the hosting scene
  33268. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  33269. * @param invertY defines if texture must be stored with Y axis inverted
  33270. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  33271. */
  33272. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  33273. /** Gets or sets the texture format to use*/
  33274. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number);
  33275. /**
  33276. * Update the texture with new data
  33277. * @param data defines the data to store in the texture
  33278. */
  33279. update(data: ArrayBufferView): void;
  33280. }
  33281. }
  33282. declare module BABYLON {
  33283. /**
  33284. * Creates a refraction texture used by refraction channel of the standard material.
  33285. * @param name the texture name
  33286. * @param size size of the underlying texture
  33287. * @param scene root scene
  33288. */
  33289. class RefractionTexture extends RenderTargetTexture {
  33290. refractionPlane: Plane;
  33291. depth: number;
  33292. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  33293. clone(): RefractionTexture;
  33294. serialize(): any;
  33295. }
  33296. }
  33297. declare module BABYLON {
  33298. class RenderTargetTexture extends Texture {
  33299. isCube: boolean;
  33300. static _REFRESHRATE_RENDER_ONCE: number;
  33301. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  33302. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  33303. static readonly REFRESHRATE_RENDER_ONCE: number;
  33304. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  33305. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  33306. /**
  33307. * Use this predicate to dynamically define the list of mesh you want to render.
  33308. * If set, the renderList property will be overwritten.
  33309. */
  33310. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  33311. /**
  33312. * Use this list to define the list of mesh you want to render.
  33313. */
  33314. renderList: Nullable<Array<AbstractMesh>>;
  33315. renderParticles: boolean;
  33316. renderSprites: boolean;
  33317. coordinatesMode: number;
  33318. activeCamera: Nullable<Camera>;
  33319. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  33320. useCameraPostProcesses: boolean;
  33321. ignoreCameraViewport: boolean;
  33322. private _postProcessManager;
  33323. private _postProcesses;
  33324. private _resizeObserver;
  33325. /**
  33326. * An event triggered when the texture is unbind.
  33327. */
  33328. onBeforeBindObservable: Observable<RenderTargetTexture>;
  33329. /**
  33330. * An event triggered when the texture is unbind.
  33331. */
  33332. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  33333. private _onAfterUnbindObserver;
  33334. onAfterUnbind: () => void;
  33335. /**
  33336. * An event triggered before rendering the texture
  33337. */
  33338. onBeforeRenderObservable: Observable<number>;
  33339. private _onBeforeRenderObserver;
  33340. onBeforeRender: (faceIndex: number) => void;
  33341. /**
  33342. * An event triggered after rendering the texture
  33343. */
  33344. onAfterRenderObservable: Observable<number>;
  33345. private _onAfterRenderObserver;
  33346. onAfterRender: (faceIndex: number) => void;
  33347. /**
  33348. * An event triggered after the texture clear
  33349. */
  33350. onClearObservable: Observable<Engine>;
  33351. private _onClearObserver;
  33352. onClear: (Engine: Engine) => void;
  33353. clearColor: Color4;
  33354. protected _size: number | {
  33355. width: number;
  33356. height: number;
  33357. };
  33358. protected _initialSizeParameter: number | {
  33359. width: number;
  33360. height: number;
  33361. } | {
  33362. ratio: number;
  33363. };
  33364. protected _sizeRatio: Nullable<number>;
  33365. _generateMipMaps: boolean;
  33366. protected _renderingManager: RenderingManager;
  33367. _waitingRenderList: string[];
  33368. protected _doNotChangeAspectRatio: boolean;
  33369. protected _currentRefreshId: number;
  33370. protected _refreshRate: number;
  33371. protected _textureMatrix: Matrix;
  33372. protected _samples: number;
  33373. protected _renderTargetOptions: RenderTargetCreationOptions;
  33374. readonly renderTargetOptions: RenderTargetCreationOptions;
  33375. protected _engine: Engine;
  33376. protected _onRatioRescale(): void;
  33377. /**
  33378. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  33379. * It must define where the camera used to render the texture is set
  33380. */
  33381. boundingBoxPosition: Vector3;
  33382. private _boundingBoxSize;
  33383. /**
  33384. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  33385. * When defined, the cubemap will switch to local mode
  33386. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33387. * @example https://www.babylonjs-playground.com/#RNASML
  33388. */
  33389. boundingBoxSize: Vector3;
  33390. /**
  33391. * In case the RTT has been created with a depth texture, get the associated
  33392. * depth texture.
  33393. * Otherwise, return null.
  33394. */
  33395. depthStencilTexture: Nullable<InternalTexture>;
  33396. /**
  33397. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  33398. * or used a shadow, depth texture...
  33399. * @param name The friendly name of the texture
  33400. * @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)
  33401. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  33402. * @param generateMipMaps True if mip maps need to be generated after render.
  33403. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  33404. * @param type The type of the buffer in the RTT (int, half float, float...)
  33405. * @param isCube True if a cube texture needs to be created
  33406. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  33407. * @param generateDepthBuffer True to generate a depth buffer
  33408. * @param generateStencilBuffer True to generate a stencil buffer
  33409. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  33410. */
  33411. constructor(name: string, size: number | {
  33412. width: number;
  33413. height: number;
  33414. } | {
  33415. ratio: number;
  33416. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  33417. /**
  33418. * Creates a depth stencil texture.
  33419. * This is only available in WebGL 2 or with the depth texture extension available.
  33420. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  33421. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  33422. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  33423. */
  33424. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  33425. private _processSizeParameter(size);
  33426. samples: number;
  33427. resetRefreshCounter(): void;
  33428. refreshRate: number;
  33429. addPostProcess(postProcess: PostProcess): void;
  33430. clearPostProcesses(dispose?: boolean): void;
  33431. removePostProcess(postProcess: PostProcess): void;
  33432. _shouldRender(): boolean;
  33433. getRenderSize(): number;
  33434. getRenderWidth(): number;
  33435. getRenderHeight(): number;
  33436. readonly canRescale: boolean;
  33437. scale(ratio: number): void;
  33438. getReflectionTextureMatrix(): Matrix;
  33439. resize(size: number | {
  33440. width: number;
  33441. height: number;
  33442. } | {
  33443. ratio: number;
  33444. }): void;
  33445. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  33446. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  33447. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  33448. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  33449. /**
  33450. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33451. * This allowed control for front to back rendering or reversly depending of the special needs.
  33452. *
  33453. * @param renderingGroupId The rendering group id corresponding to its index
  33454. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33455. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33456. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33457. */
  33458. 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;
  33459. /**
  33460. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33461. *
  33462. * @param renderingGroupId The rendering group id corresponding to its index
  33463. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33464. */
  33465. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  33466. clone(): RenderTargetTexture;
  33467. serialize(): any;
  33468. disposeFramebufferObjects(): void;
  33469. dispose(): void;
  33470. _rebuild(): void;
  33471. /**
  33472. * Clear the info related to rendering groups preventing retention point in material dispose.
  33473. */
  33474. freeRenderingGroups(): void;
  33475. }
  33476. }
  33477. declare module BABYLON {
  33478. class Texture extends BaseTexture {
  33479. static NEAREST_SAMPLINGMODE: number;
  33480. static NEAREST_NEAREST_MIPLINEAR: number;
  33481. static BILINEAR_SAMPLINGMODE: number;
  33482. static LINEAR_LINEAR_MIPNEAREST: number;
  33483. static TRILINEAR_SAMPLINGMODE: number;
  33484. static LINEAR_LINEAR_MIPLINEAR: number;
  33485. static NEAREST_NEAREST_MIPNEAREST: number;
  33486. static NEAREST_LINEAR_MIPNEAREST: number;
  33487. static NEAREST_LINEAR_MIPLINEAR: number;
  33488. static NEAREST_LINEAR: number;
  33489. static NEAREST_NEAREST: number;
  33490. static LINEAR_NEAREST_MIPNEAREST: number;
  33491. static LINEAR_NEAREST_MIPLINEAR: number;
  33492. static LINEAR_LINEAR: number;
  33493. static LINEAR_NEAREST: number;
  33494. static EXPLICIT_MODE: number;
  33495. static SPHERICAL_MODE: number;
  33496. static PLANAR_MODE: number;
  33497. static CUBIC_MODE: number;
  33498. static PROJECTION_MODE: number;
  33499. static SKYBOX_MODE: number;
  33500. static INVCUBIC_MODE: number;
  33501. static EQUIRECTANGULAR_MODE: number;
  33502. static FIXED_EQUIRECTANGULAR_MODE: number;
  33503. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33504. static CLAMP_ADDRESSMODE: number;
  33505. static WRAP_ADDRESSMODE: number;
  33506. static MIRROR_ADDRESSMODE: number;
  33507. /**
  33508. * 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
  33509. */
  33510. static UseSerializedUrlIfAny: boolean;
  33511. url: Nullable<string>;
  33512. uOffset: number;
  33513. vOffset: number;
  33514. uScale: number;
  33515. vScale: number;
  33516. uAng: number;
  33517. vAng: number;
  33518. wAng: number;
  33519. /**
  33520. * Defines the center of rotation (U)
  33521. */
  33522. uRotationCenter: number;
  33523. /**
  33524. * Defines the center of rotation (V)
  33525. */
  33526. vRotationCenter: number;
  33527. /**
  33528. * Defines the center of rotation (W)
  33529. */
  33530. wRotationCenter: number;
  33531. readonly noMipmap: boolean;
  33532. private _noMipmap;
  33533. _invertY: boolean;
  33534. private _rowGenerationMatrix;
  33535. private _cachedTextureMatrix;
  33536. private _projectionModeMatrix;
  33537. private _t0;
  33538. private _t1;
  33539. private _t2;
  33540. private _cachedUOffset;
  33541. private _cachedVOffset;
  33542. private _cachedUScale;
  33543. private _cachedVScale;
  33544. private _cachedUAng;
  33545. private _cachedVAng;
  33546. private _cachedWAng;
  33547. private _cachedProjectionMatrixId;
  33548. private _cachedCoordinatesMode;
  33549. _samplingMode: number;
  33550. private _buffer;
  33551. private _deleteBuffer;
  33552. protected _format: Nullable<number>;
  33553. private _delayedOnLoad;
  33554. private _delayedOnError;
  33555. protected _onLoadObservable: Nullable<Observable<Texture>>;
  33556. protected _isBlocking: boolean;
  33557. isBlocking: boolean;
  33558. readonly samplingMode: number;
  33559. 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);
  33560. /**
  33561. * Update the url (and optional buffer) of this texture if url was null during construction.
  33562. * @param url the url of the texture
  33563. * @param buffer the buffer of the texture (defaults to null)
  33564. */
  33565. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  33566. delayLoad(): void;
  33567. updateSamplingMode(samplingMode: number): void;
  33568. private _prepareRowForTextureGeneration(x, y, z, t);
  33569. getTextureMatrix(): Matrix;
  33570. getReflectionTextureMatrix(): Matrix;
  33571. clone(): Texture;
  33572. readonly onLoadObservable: Observable<Texture>;
  33573. serialize(): any;
  33574. getClassName(): string;
  33575. dispose(): void;
  33576. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  33577. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  33578. 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;
  33579. }
  33580. }
  33581. declare module BABYLON {
  33582. /**
  33583. * Settings for finer control over video usage
  33584. */
  33585. interface VideoTextureSettings {
  33586. /**
  33587. * Applies `autoplay` to video, if specified
  33588. */
  33589. autoPlay?: boolean;
  33590. /**
  33591. * Applies `loop` to video, if specified
  33592. */
  33593. loop?: boolean;
  33594. /**
  33595. * Automatically updates internal texture from video at every frame in the render loop
  33596. */
  33597. autoUpdateTexture: boolean;
  33598. }
  33599. class VideoTexture extends Texture {
  33600. /**
  33601. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  33602. */
  33603. readonly autoUpdateTexture: boolean;
  33604. /**
  33605. * The video instance used by the texture internally
  33606. */
  33607. readonly video: HTMLVideoElement;
  33608. private _generateMipMaps;
  33609. private _engine;
  33610. private _stillImageCaptured;
  33611. /**
  33612. * Creates a video texture.
  33613. * Sample : https://doc.babylonjs.com/how_to/video_texture
  33614. * @param {string | null} name optional name, will detect from video source, if not defined
  33615. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  33616. * @param {BABYLON.Scene} scene is obviously the current scene.
  33617. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  33618. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  33619. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  33620. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  33621. */
  33622. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  33623. private _getName(src);
  33624. private _getVideo(src);
  33625. private _createInternalTexture;
  33626. private reset;
  33627. /**
  33628. * Internal method to initiate `update`.
  33629. */
  33630. _rebuild(): void;
  33631. /**
  33632. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  33633. */
  33634. update(): void;
  33635. /**
  33636. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  33637. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  33638. */
  33639. updateTexture(isVisible: boolean): void;
  33640. protected _updateInternalTexture: (e?: Event | undefined) => void;
  33641. /**
  33642. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  33643. * @param url New url.
  33644. */
  33645. updateURL(url: string): void;
  33646. dispose(): void;
  33647. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  33648. minWidth: number;
  33649. maxWidth: number;
  33650. minHeight: number;
  33651. maxHeight: number;
  33652. deviceId: string;
  33653. }): void;
  33654. }
  33655. }
  33656. declare var DracoDecoderModule: any;
  33657. declare var WebAssembly: any;
  33658. declare module BABYLON {
  33659. /**
  33660. * Configuration for Draco compression
  33661. */
  33662. interface IDracoCompressionConfiguration {
  33663. /**
  33664. * Configuration for the decoder.
  33665. */
  33666. decoder?: {
  33667. /**
  33668. * The url to the WebAssembly module.
  33669. */
  33670. wasmUrl?: string;
  33671. /**
  33672. * The url to the WebAssembly binary.
  33673. */
  33674. wasmBinaryUrl?: string;
  33675. /**
  33676. * The url to the fallback JavaScript module.
  33677. */
  33678. fallbackUrl?: string;
  33679. };
  33680. }
  33681. /**
  33682. * Draco compression (https://google.github.io/draco/)
  33683. */
  33684. class DracoCompression implements IDisposable {
  33685. private static _DecoderModulePromise;
  33686. /**
  33687. * The configuration.
  33688. */
  33689. static Configuration: IDracoCompressionConfiguration;
  33690. /**
  33691. * Returns true if the decoder is available.
  33692. */
  33693. static readonly DecoderAvailable: boolean;
  33694. /**
  33695. * Constructor
  33696. */
  33697. constructor();
  33698. /**
  33699. * Stop all async operations and release resources.
  33700. */
  33701. dispose(): void;
  33702. /**
  33703. * Decode Draco compressed mesh data to vertex data.
  33704. * @param data The array buffer view for the Draco compression data
  33705. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  33706. * @returns A promise that resolves with the decoded vertex data
  33707. */
  33708. decodeMeshAsync(data: ArrayBufferView, attributes: {
  33709. [kind: string]: number;
  33710. }): Promise<VertexData>;
  33711. private static _GetDecoderModule();
  33712. private static _LoadScriptAsync(url);
  33713. private static _LoadFileAsync(url);
  33714. }
  33715. }
  33716. declare module BABYLON {
  33717. /**
  33718. * Particle emitter emitting particles from the inside of a box.
  33719. * It emits the particles randomly between 2 given directions.
  33720. */
  33721. class BoxParticleEmitter implements IParticleEmitterType {
  33722. /**
  33723. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  33724. */
  33725. direction1: Vector3;
  33726. /**
  33727. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  33728. */
  33729. direction2: Vector3;
  33730. /**
  33731. * 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.
  33732. */
  33733. minEmitBox: Vector3;
  33734. /**
  33735. * 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.
  33736. */
  33737. maxEmitBox: Vector3;
  33738. /**
  33739. * Creates a new instance BoxParticleEmitter
  33740. */
  33741. constructor();
  33742. /**
  33743. * Called by the particle System when the direction is computed for the created particle.
  33744. * @param emitPower is the power of the particle (speed)
  33745. * @param worldMatrix is the world matrix of the particle system
  33746. * @param directionToUpdate is the direction vector to update with the result
  33747. * @param particle is the particle we are computed the direction for
  33748. */
  33749. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33750. /**
  33751. * Called by the particle System when the position is computed for the created particle.
  33752. * @param worldMatrix is the world matrix of the particle system
  33753. * @param positionToUpdate is the position vector to update with the result
  33754. * @param particle is the particle we are computed the position for
  33755. */
  33756. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33757. /**
  33758. * Clones the current emitter and returns a copy of it
  33759. * @returns the new emitter
  33760. */
  33761. clone(): BoxParticleEmitter;
  33762. /**
  33763. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33764. * @param effect defines the update shader
  33765. */
  33766. applyToShader(effect: Effect): void;
  33767. /**
  33768. * Returns a string to use to update the GPU particles update shader
  33769. * @returns a string containng the defines string
  33770. */
  33771. getEffectDefines(): string;
  33772. /**
  33773. * Returns the string "BoxEmitter"
  33774. * @returns a string containing the class name
  33775. */
  33776. getClassName(): string;
  33777. /**
  33778. * Serializes the particle system to a JSON object.
  33779. * @returns the JSON object
  33780. */
  33781. serialize(): any;
  33782. /**
  33783. * Parse properties from a JSON object
  33784. * @param serializationObject defines the JSON object
  33785. */
  33786. parse(serializationObject: any): void;
  33787. }
  33788. }
  33789. declare module BABYLON {
  33790. /**
  33791. * Particle emitter emitting particles from the inside of a cone.
  33792. * It emits the particles alongside the cone volume from the base to the particle.
  33793. * The emission direction might be randomized.
  33794. */
  33795. class ConeParticleEmitter implements IParticleEmitterType {
  33796. /**
  33797. * The radius of the emission cone.
  33798. */
  33799. angle: number;
  33800. /**
  33801. * The cone base angle.
  33802. */
  33803. directionRandomizer: number;
  33804. private _radius;
  33805. private _height;
  33806. /**
  33807. * Gets the radius of the emission cone.
  33808. */
  33809. /**
  33810. * Sets the radius of the emission cone.
  33811. */
  33812. radius: number;
  33813. /**
  33814. * Creates a new instance ConeParticleEmitter
  33815. * @param radius the radius of the emission cone (1 by default)
  33816. * @param angles the cone base angle (PI by default)
  33817. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  33818. */
  33819. constructor(radius?: number,
  33820. /**
  33821. * The radius of the emission cone.
  33822. */
  33823. angle?: number,
  33824. /**
  33825. * The cone base angle.
  33826. */
  33827. directionRandomizer?: number);
  33828. /**
  33829. * Called by the particle System when the direction is computed for the created particle.
  33830. * @param emitPower is the power of the particle (speed)
  33831. * @param worldMatrix is the world matrix of the particle system
  33832. * @param directionToUpdate is the direction vector to update with the result
  33833. * @param particle is the particle we are computed the direction for
  33834. */
  33835. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33836. /**
  33837. * Called by the particle System when the position is computed for the created particle.
  33838. * @param worldMatrix is the world matrix of the particle system
  33839. * @param positionToUpdate is the position vector to update with the result
  33840. * @param particle is the particle we are computed the position for
  33841. */
  33842. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33843. /**
  33844. * Clones the current emitter and returns a copy of it
  33845. * @returns the new emitter
  33846. */
  33847. clone(): ConeParticleEmitter;
  33848. /**
  33849. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33850. * @param effect defines the update shader
  33851. */
  33852. applyToShader(effect: Effect): void;
  33853. /**
  33854. * Returns a string to use to update the GPU particles update shader
  33855. * @returns a string containng the defines string
  33856. */
  33857. getEffectDefines(): string;
  33858. /**
  33859. * Returns the string "BoxEmitter"
  33860. * @returns a string containing the class name
  33861. */
  33862. getClassName(): string;
  33863. /**
  33864. * Serializes the particle system to a JSON object.
  33865. * @returns the JSON object
  33866. */
  33867. serialize(): any;
  33868. /**
  33869. * Parse properties from a JSON object
  33870. * @param serializationObject defines the JSON object
  33871. */
  33872. parse(serializationObject: any): void;
  33873. }
  33874. }
  33875. declare module BABYLON {
  33876. /**
  33877. * Particle emitter represents a volume emitting particles.
  33878. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  33879. */
  33880. interface IParticleEmitterType {
  33881. /**
  33882. * Called by the particle System when the direction is computed for the created particle.
  33883. * @param emitPower is the power of the particle (speed)
  33884. * @param worldMatrix is the world matrix of the particle system
  33885. * @param directionToUpdate is the direction vector to update with the result
  33886. * @param particle is the particle we are computed the direction for
  33887. */
  33888. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33889. /**
  33890. * Called by the particle System when the position is computed for the created particle.
  33891. * @param worldMatrix is the world matrix of the particle system
  33892. * @param positionToUpdate is the position vector to update with the result
  33893. * @param particle is the particle we are computed the position for
  33894. */
  33895. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33896. /**
  33897. * Clones the current emitter and returns a copy of it
  33898. * @returns the new emitter
  33899. */
  33900. clone(): IParticleEmitterType;
  33901. /**
  33902. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33903. * @param effect defines the update shader
  33904. */
  33905. applyToShader(effect: Effect): void;
  33906. /**
  33907. * Returns a string to use to update the GPU particles update shader
  33908. * @returns the effect defines string
  33909. */
  33910. getEffectDefines(): string;
  33911. /**
  33912. * Returns a string representing the class name
  33913. * @returns a string containing the class name
  33914. */
  33915. getClassName(): string;
  33916. /**
  33917. * Serializes the particle system to a JSON object.
  33918. * @returns the JSON object
  33919. */
  33920. serialize(): any;
  33921. /**
  33922. * Parse properties from a JSON object
  33923. * @param serializationObject defines the JSON object
  33924. */
  33925. parse(serializationObject: any): void;
  33926. }
  33927. }
  33928. declare module BABYLON {
  33929. /**
  33930. * Particle emitter emitting particles from the inside of a sphere.
  33931. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  33932. */
  33933. class SphereParticleEmitter implements IParticleEmitterType {
  33934. /**
  33935. * The radius of the emission sphere.
  33936. */
  33937. radius: number;
  33938. /**
  33939. * How much to randomize the particle direction [0-1].
  33940. */
  33941. directionRandomizer: number;
  33942. /**
  33943. * Creates a new instance SphereParticleEmitter
  33944. * @param radius the radius of the emission sphere (1 by default)
  33945. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  33946. */
  33947. constructor(
  33948. /**
  33949. * The radius of the emission sphere.
  33950. */
  33951. radius?: number,
  33952. /**
  33953. * How much to randomize the particle direction [0-1].
  33954. */
  33955. directionRandomizer?: number);
  33956. /**
  33957. * Called by the particle System when the direction is computed for the created particle.
  33958. * @param emitPower is the power of the particle (speed)
  33959. * @param worldMatrix is the world matrix of the particle system
  33960. * @param directionToUpdate is the direction vector to update with the result
  33961. * @param particle is the particle we are computed the direction for
  33962. */
  33963. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33964. /**
  33965. * Called by the particle System when the position is computed for the created particle.
  33966. * @param worldMatrix is the world matrix of the particle system
  33967. * @param positionToUpdate is the position vector to update with the result
  33968. * @param particle is the particle we are computed the position for
  33969. */
  33970. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33971. /**
  33972. * Clones the current emitter and returns a copy of it
  33973. * @returns the new emitter
  33974. */
  33975. clone(): SphereParticleEmitter;
  33976. /**
  33977. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33978. * @param effect defines the update shader
  33979. */
  33980. applyToShader(effect: Effect): void;
  33981. /**
  33982. * Returns a string to use to update the GPU particles update shader
  33983. * @returns a string containng the defines string
  33984. */
  33985. getEffectDefines(): string;
  33986. /**
  33987. * Returns the string "SphereParticleEmitter"
  33988. * @returns a string containing the class name
  33989. */
  33990. getClassName(): string;
  33991. /**
  33992. * Serializes the particle system to a JSON object.
  33993. * @returns the JSON object
  33994. */
  33995. serialize(): any;
  33996. /**
  33997. * Parse properties from a JSON object
  33998. * @param serializationObject defines the JSON object
  33999. */
  34000. parse(serializationObject: any): void;
  34001. }
  34002. /**
  34003. * Particle emitter emitting particles from the inside of a sphere.
  34004. * It emits the particles randomly between two vectors.
  34005. */
  34006. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  34007. /**
  34008. * The min limit of the emission direction.
  34009. */
  34010. direction1: Vector3;
  34011. /**
  34012. * The max limit of the emission direction.
  34013. */
  34014. direction2: Vector3;
  34015. /**
  34016. * Creates a new instance SphereDirectedParticleEmitter
  34017. * @param radius the radius of the emission sphere (1 by default)
  34018. * @param direction1 the min limit of the emission direction (up vector by default)
  34019. * @param direction2 the max limit of the emission direction (up vector by default)
  34020. */
  34021. constructor(radius?: number,
  34022. /**
  34023. * The min limit of the emission direction.
  34024. */
  34025. direction1?: Vector3,
  34026. /**
  34027. * The max limit of the emission direction.
  34028. */
  34029. direction2?: Vector3);
  34030. /**
  34031. * Called by the particle System when the direction is computed for the created particle.
  34032. * @param emitPower is the power of the particle (speed)
  34033. * @param worldMatrix is the world matrix of the particle system
  34034. * @param directionToUpdate is the direction vector to update with the result
  34035. * @param particle is the particle we are computed the direction for
  34036. */
  34037. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34038. /**
  34039. * Clones the current emitter and returns a copy of it
  34040. * @returns the new emitter
  34041. */
  34042. clone(): SphereDirectedParticleEmitter;
  34043. /**
  34044. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34045. * @param effect defines the update shader
  34046. */
  34047. applyToShader(effect: Effect): void;
  34048. /**
  34049. * Returns a string to use to update the GPU particles update shader
  34050. * @returns a string containng the defines string
  34051. */
  34052. getEffectDefines(): string;
  34053. /**
  34054. * Returns the string "SphereDirectedParticleEmitter"
  34055. * @returns a string containing the class name
  34056. */
  34057. getClassName(): string;
  34058. /**
  34059. * Serializes the particle system to a JSON object.
  34060. * @returns the JSON object
  34061. */
  34062. serialize(): any;
  34063. /**
  34064. * Parse properties from a JSON object
  34065. * @param serializationObject defines the JSON object
  34066. */
  34067. parse(serializationObject: any): void;
  34068. }
  34069. }
  34070. declare module BABYLON {
  34071. class CannonJSPlugin implements IPhysicsEnginePlugin {
  34072. private _useDeltaForWorldStep;
  34073. world: any;
  34074. name: string;
  34075. private _physicsMaterials;
  34076. private _fixedTimeStep;
  34077. BJSCANNON: any;
  34078. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  34079. setGravity(gravity: Vector3): void;
  34080. setTimeStep(timeStep: number): void;
  34081. getTimeStep(): number;
  34082. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  34083. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34084. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34085. generatePhysicsBody(impostor: PhysicsImpostor): void;
  34086. private _processChildMeshes(mainImpostor);
  34087. removePhysicsBody(impostor: PhysicsImpostor): void;
  34088. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  34089. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  34090. private _addMaterial(name, friction, restitution);
  34091. private _checkWithEpsilon(value);
  34092. private _createShape(impostor);
  34093. private _createHeightmap(object, pointDepth?);
  34094. private _minus90X;
  34095. private _plus90X;
  34096. private _tmpPosition;
  34097. private _tmpDeltaPosition;
  34098. private _tmpUnityRotation;
  34099. private _updatePhysicsBodyTransformation(impostor);
  34100. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  34101. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  34102. isSupported(): boolean;
  34103. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34104. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34105. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34106. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34107. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  34108. getBodyMass(impostor: PhysicsImpostor): number;
  34109. getBodyFriction(impostor: PhysicsImpostor): number;
  34110. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  34111. getBodyRestitution(impostor: PhysicsImpostor): number;
  34112. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  34113. sleepBody(impostor: PhysicsImpostor): void;
  34114. wakeUpBody(impostor: PhysicsImpostor): void;
  34115. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  34116. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  34117. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  34118. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  34119. getRadius(impostor: PhysicsImpostor): number;
  34120. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  34121. dispose(): void;
  34122. private _extendNamespace();
  34123. }
  34124. }
  34125. declare module BABYLON {
  34126. class OimoJSPlugin implements IPhysicsEnginePlugin {
  34127. world: any;
  34128. name: string;
  34129. BJSOIMO: any;
  34130. constructor(iterations?: number);
  34131. setGravity(gravity: Vector3): void;
  34132. setTimeStep(timeStep: number): void;
  34133. getTimeStep(): number;
  34134. private _tmpImpostorsArray;
  34135. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  34136. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34137. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34138. generatePhysicsBody(impostor: PhysicsImpostor): void;
  34139. private _tmpPositionVector;
  34140. removePhysicsBody(impostor: PhysicsImpostor): void;
  34141. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  34142. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  34143. isSupported(): boolean;
  34144. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  34145. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  34146. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34147. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34148. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34149. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34150. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  34151. getBodyMass(impostor: PhysicsImpostor): number;
  34152. getBodyFriction(impostor: PhysicsImpostor): number;
  34153. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  34154. getBodyRestitution(impostor: PhysicsImpostor): number;
  34155. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  34156. sleepBody(impostor: PhysicsImpostor): void;
  34157. wakeUpBody(impostor: PhysicsImpostor): void;
  34158. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  34159. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  34160. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34161. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  34162. getRadius(impostor: PhysicsImpostor): number;
  34163. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  34164. dispose(): void;
  34165. }
  34166. }
  34167. declare module BABYLON {
  34168. /**
  34169. * This represents a set of one or more post processes in Babylon.
  34170. * A post process can be used to apply a shader to a texture after it is rendered.
  34171. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  34172. */
  34173. class PostProcessRenderEffect {
  34174. private _postProcesses;
  34175. private _getPostProcesses;
  34176. private _singleInstance;
  34177. private _cameras;
  34178. private _indicesForCamera;
  34179. /**
  34180. * Name of the effect
  34181. */
  34182. _name: string;
  34183. /**
  34184. * Instantiates a post process render effect.
  34185. * A post process can be used to apply a shader to a texture after it is rendered.
  34186. * @param engine The engine the effect is tied to
  34187. * @param name The name of the effect
  34188. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  34189. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  34190. */
  34191. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  34192. /**
  34193. * Checks if all the post processes in the effect are supported.
  34194. */
  34195. readonly isSupported: boolean;
  34196. /**
  34197. * Updates the current state of the effect
  34198. */
  34199. _update(): void;
  34200. /**
  34201. * Attaches the effect on cameras
  34202. * @param cameras The camera to attach to.
  34203. */
  34204. _attachCameras(cameras: Camera): void;
  34205. /**
  34206. * Attaches the effect on cameras
  34207. * @param cameras The camera to attach to.
  34208. */
  34209. _attachCameras(cameras: Camera[]): void;
  34210. /**
  34211. * Detatches the effect on cameras
  34212. * @param cameras The camera to detatch from.
  34213. */
  34214. _detachCameras(cameras: Camera): void;
  34215. /**
  34216. * Detatches the effect on cameras
  34217. * @param cameras The camera to detatch from.
  34218. */
  34219. _detachCameras(cameras: Camera[]): void;
  34220. /**
  34221. * Enables the effect on given cameras
  34222. * @param cameras The camera to enable.
  34223. */
  34224. _enable(cameras: Camera): void;
  34225. /**
  34226. * Enables the effect on given cameras
  34227. * @param cameras The camera to enable.
  34228. */
  34229. _enable(cameras: Nullable<Camera[]>): void;
  34230. /**
  34231. * Disables the effect on the given cameras
  34232. * @param cameras The camera to disable.
  34233. */
  34234. _disable(cameras: Camera): void;
  34235. /**
  34236. * Disables the effect on the given cameras
  34237. * @param cameras The camera to disable.
  34238. */
  34239. _disable(cameras: Nullable<Camera[]>): void;
  34240. /**
  34241. * Gets a list of the post processes contained in the effect.
  34242. * @param camera The camera to get the post processes on.
  34243. * @returns The list of the post processes in the effect.
  34244. */
  34245. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  34246. }
  34247. }
  34248. declare module BABYLON {
  34249. class PostProcessRenderPipeline {
  34250. private engine;
  34251. private _renderEffects;
  34252. private _renderEffectsForIsolatedPass;
  34253. protected _cameras: Camera[];
  34254. _name: string;
  34255. constructor(engine: Engine, name: string);
  34256. getClassName(): string;
  34257. readonly isSupported: boolean;
  34258. addEffect(renderEffect: PostProcessRenderEffect): void;
  34259. _rebuild(): void;
  34260. _enableEffect(renderEffectName: string, cameras: Camera): void;
  34261. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  34262. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  34263. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  34264. _attachCameras(cameras: Camera, unique: boolean): void;
  34265. _attachCameras(cameras: Camera[], unique: boolean): void;
  34266. _detachCameras(cameras: Camera): void;
  34267. _detachCameras(cameras: Nullable<Camera[]>): void;
  34268. _update(): void;
  34269. _reset(): void;
  34270. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  34271. dispose(): void;
  34272. }
  34273. }
  34274. declare module BABYLON {
  34275. class PostProcessRenderPipelineManager {
  34276. private _renderPipelines;
  34277. constructor();
  34278. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  34279. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  34280. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  34281. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  34282. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  34283. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  34284. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  34285. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  34286. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  34287. update(): void;
  34288. _rebuild(): void;
  34289. dispose(): void;
  34290. }
  34291. }
  34292. declare module BABYLON {
  34293. /**
  34294. * Helper class dealing with the extraction of spherical polynomial dataArray
  34295. * from a cube map.
  34296. */
  34297. class CubeMapToSphericalPolynomialTools {
  34298. private static FileFaces;
  34299. /**
  34300. * Converts a texture to the according Spherical Polynomial data.
  34301. * This extracts the first 3 orders only as they are the only one used in the lighting.
  34302. *
  34303. * @param texture The texture to extract the information from.
  34304. * @return The Spherical Polynomial data.
  34305. */
  34306. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  34307. /**
  34308. * Converts a cubemap to the according Spherical Polynomial data.
  34309. * This extracts the first 3 orders only as they are the only one used in the lighting.
  34310. *
  34311. * @param cubeInfo The Cube map to extract the information from.
  34312. * @return The Spherical Polynomial data.
  34313. */
  34314. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  34315. }
  34316. }
  34317. declare module BABYLON {
  34318. /**
  34319. * Header information of HDR texture files.
  34320. */
  34321. interface HDRInfo {
  34322. /**
  34323. * The height of the texture in pixels.
  34324. */
  34325. height: number;
  34326. /**
  34327. * The width of the texture in pixels.
  34328. */
  34329. width: number;
  34330. /**
  34331. * The index of the beginning of the data in the binary file.
  34332. */
  34333. dataPosition: number;
  34334. }
  34335. /**
  34336. * This groups tools to convert HDR texture to native colors array.
  34337. */
  34338. class HDRTools {
  34339. private static Ldexp(mantissa, exponent);
  34340. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  34341. private static readStringLine(uint8array, startIndex);
  34342. /**
  34343. * Reads header information from an RGBE texture stored in a native array.
  34344. * More information on this format are available here:
  34345. * https://en.wikipedia.org/wiki/RGBE_image_format
  34346. *
  34347. * @param uint8array The binary file stored in native array.
  34348. * @return The header information.
  34349. */
  34350. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  34351. /**
  34352. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  34353. * This RGBE texture needs to store the information as a panorama.
  34354. *
  34355. * More information on this format are available here:
  34356. * https://en.wikipedia.org/wiki/RGBE_image_format
  34357. *
  34358. * @param buffer The binary file stored in an array buffer.
  34359. * @param size The expected size of the extracted cubemap.
  34360. * @return The Cube Map information.
  34361. */
  34362. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  34363. /**
  34364. * Returns the pixels data extracted from an RGBE texture.
  34365. * This pixels will be stored left to right up to down in the R G B order in one array.
  34366. *
  34367. * More information on this format are available here:
  34368. * https://en.wikipedia.org/wiki/RGBE_image_format
  34369. *
  34370. * @param uint8array The binary file stored in an array buffer.
  34371. * @param hdrInfo The header information of the file.
  34372. * @return The pixels data in RGB right to left up to down order.
  34373. */
  34374. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  34375. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  34376. }
  34377. }
  34378. declare module BABYLON {
  34379. /**
  34380. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  34381. */
  34382. interface CubeMapInfo {
  34383. /**
  34384. * The pixel array for the front face.
  34385. * This is stored in format, left to right, up to down format.
  34386. */
  34387. front: Nullable<ArrayBufferView>;
  34388. /**
  34389. * The pixel array for the back face.
  34390. * This is stored in format, left to right, up to down format.
  34391. */
  34392. back: Nullable<ArrayBufferView>;
  34393. /**
  34394. * The pixel array for the left face.
  34395. * This is stored in format, left to right, up to down format.
  34396. */
  34397. left: Nullable<ArrayBufferView>;
  34398. /**
  34399. * The pixel array for the right face.
  34400. * This is stored in format, left to right, up to down format.
  34401. */
  34402. right: Nullable<ArrayBufferView>;
  34403. /**
  34404. * The pixel array for the up face.
  34405. * This is stored in format, left to right, up to down format.
  34406. */
  34407. up: Nullable<ArrayBufferView>;
  34408. /**
  34409. * The pixel array for the down face.
  34410. * This is stored in format, left to right, up to down format.
  34411. */
  34412. down: Nullable<ArrayBufferView>;
  34413. /**
  34414. * The size of the cubemap stored.
  34415. *
  34416. * Each faces will be size * size pixels.
  34417. */
  34418. size: number;
  34419. /**
  34420. * The format of the texture.
  34421. *
  34422. * RGBA, RGB.
  34423. */
  34424. format: number;
  34425. /**
  34426. * The type of the texture data.
  34427. *
  34428. * UNSIGNED_INT, FLOAT.
  34429. */
  34430. type: number;
  34431. /**
  34432. * Specifies whether the texture is in gamma space.
  34433. */
  34434. gammaSpace: boolean;
  34435. }
  34436. /**
  34437. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  34438. */
  34439. class PanoramaToCubeMapTools {
  34440. private static FACE_FRONT;
  34441. private static FACE_BACK;
  34442. private static FACE_RIGHT;
  34443. private static FACE_LEFT;
  34444. private static FACE_DOWN;
  34445. private static FACE_UP;
  34446. /**
  34447. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  34448. *
  34449. * @param float32Array The source data.
  34450. * @param inputWidth The width of the input panorama.
  34451. * @param inputhHeight The height of the input panorama.
  34452. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  34453. * @return The cubemap data
  34454. */
  34455. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  34456. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  34457. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  34458. }
  34459. }
  34460. declare module BABYLON {
  34461. class CustomProceduralTexture extends ProceduralTexture {
  34462. private _animate;
  34463. private _time;
  34464. private _config;
  34465. private _texturePath;
  34466. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  34467. private loadJson(jsonUrl);
  34468. isReady(): boolean;
  34469. render(useCameraPostProcess?: boolean): void;
  34470. updateTextures(): void;
  34471. updateShaderUniforms(): void;
  34472. animate: boolean;
  34473. }
  34474. }
  34475. declare module BABYLON {
  34476. class ProceduralTexture extends Texture {
  34477. isCube: boolean;
  34478. private _size;
  34479. _generateMipMaps: boolean;
  34480. isEnabled: boolean;
  34481. private _currentRefreshId;
  34482. private _refreshRate;
  34483. onGenerated: () => void;
  34484. private _vertexBuffers;
  34485. private _indexBuffer;
  34486. private _effect;
  34487. private _uniforms;
  34488. private _samplers;
  34489. private _fragment;
  34490. _textures: {
  34491. [key: string]: Texture;
  34492. };
  34493. private _floats;
  34494. private _floatsArrays;
  34495. private _colors3;
  34496. private _colors4;
  34497. private _vectors2;
  34498. private _vectors3;
  34499. private _matrices;
  34500. private _fallbackTexture;
  34501. private _fallbackTextureUsed;
  34502. private _engine;
  34503. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  34504. private _createIndexBuffer();
  34505. _rebuild(): void;
  34506. reset(): void;
  34507. isReady(): boolean;
  34508. resetRefreshCounter(): void;
  34509. setFragment(fragment: any): void;
  34510. refreshRate: number;
  34511. _shouldRender(): boolean;
  34512. getRenderSize(): number;
  34513. resize(size: number, generateMipMaps: boolean): void;
  34514. private _checkUniform(uniformName);
  34515. setTexture(name: string, texture: Texture): ProceduralTexture;
  34516. setFloat(name: string, value: number): ProceduralTexture;
  34517. setFloats(name: string, value: number[]): ProceduralTexture;
  34518. setColor3(name: string, value: Color3): ProceduralTexture;
  34519. setColor4(name: string, value: Color4): ProceduralTexture;
  34520. setVector2(name: string, value: Vector2): ProceduralTexture;
  34521. setVector3(name: string, value: Vector3): ProceduralTexture;
  34522. setMatrix(name: string, value: Matrix): ProceduralTexture;
  34523. render(useCameraPostProcess?: boolean): void;
  34524. clone(): ProceduralTexture;
  34525. dispose(): void;
  34526. }
  34527. }
  34528. declare module BABYLON {
  34529. /**
  34530. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  34531. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  34532. */
  34533. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  34534. private _scene;
  34535. private _originalCameras;
  34536. /**
  34537. * ID of the sharpen post process,
  34538. */
  34539. private readonly SharpenPostProcessId;
  34540. /**
  34541. * ID of the image processing post process;
  34542. */
  34543. readonly ImageProcessingPostProcessId: string;
  34544. /**
  34545. * ID of the Fast Approximate Anti-Aliasing post process;
  34546. */
  34547. readonly FxaaPostProcessId: string;
  34548. /**
  34549. * ID of the chromatic aberration post process,
  34550. */
  34551. private readonly ChromaticAberrationPostProcessId;
  34552. /**
  34553. * ID of the grain post process
  34554. */
  34555. private readonly GrainPostProcessId;
  34556. /**
  34557. * Sharpen post process which will apply a sharpen convolution to enhance edges
  34558. */
  34559. sharpen: SharpenPostProcess;
  34560. private _sharpenEffect;
  34561. private bloom;
  34562. /**
  34563. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  34564. */
  34565. depthOfField: DepthOfFieldEffect;
  34566. /**
  34567. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  34568. */
  34569. fxaa: FxaaPostProcess;
  34570. /**
  34571. * Image post processing pass used to perform operations such as tone mapping or color grading.
  34572. */
  34573. imageProcessing: ImageProcessingPostProcess;
  34574. /**
  34575. * Chromatic aberration post process which will shift rgb colors in the image
  34576. */
  34577. chromaticAberration: ChromaticAberrationPostProcess;
  34578. private _chromaticAberrationEffect;
  34579. /**
  34580. * Grain post process which add noise to the image
  34581. */
  34582. grain: GrainPostProcess;
  34583. private _grainEffect;
  34584. /**
  34585. * Glow post process which adds a glow to emmisive areas of the image
  34586. */
  34587. private _glowLayer;
  34588. /**
  34589. * Animations which can be used to tweak settings over a period of time
  34590. */
  34591. animations: Animation[];
  34592. private _imageProcessingConfigurationObserver;
  34593. private _sharpenEnabled;
  34594. private _bloomEnabled;
  34595. private _depthOfFieldEnabled;
  34596. private _depthOfFieldBlurLevel;
  34597. private _fxaaEnabled;
  34598. private _imageProcessingEnabled;
  34599. private _defaultPipelineTextureType;
  34600. private _bloomScale;
  34601. private _chromaticAberrationEnabled;
  34602. private _grainEnabled;
  34603. private _buildAllowed;
  34604. /**
  34605. * Enable or disable the sharpen process from the pipeline
  34606. */
  34607. sharpenEnabled: boolean;
  34608. private _resizeObserver;
  34609. private _hardwareScaleLevel;
  34610. private _bloomKernel;
  34611. /**
  34612. * Specifies the size of the bloom blur kernel, relative to the final output size
  34613. */
  34614. bloomKernel: number;
  34615. /**
  34616. * Specifies the weight of the bloom in the final rendering
  34617. */
  34618. private _bloomWeight;
  34619. /**
  34620. * Specifies the luma threshold for the area that will be blurred by the bloom
  34621. */
  34622. private _bloomThreshold;
  34623. private _hdr;
  34624. /**
  34625. * The strength of the bloom.
  34626. */
  34627. bloomWeight: number;
  34628. /**
  34629. * The strength of the bloom.
  34630. */
  34631. bloomThreshold: number;
  34632. /**
  34633. * The scale of the bloom, lower value will provide better performance.
  34634. */
  34635. bloomScale: number;
  34636. /**
  34637. * Enable or disable the bloom from the pipeline
  34638. */
  34639. bloomEnabled: boolean;
  34640. private _rebuildBloom();
  34641. /**
  34642. * If the depth of field is enabled.
  34643. */
  34644. depthOfFieldEnabled: boolean;
  34645. /**
  34646. * Blur level of the depth of field effect. (Higher blur will effect performance)
  34647. */
  34648. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  34649. /**
  34650. * If the anti aliasing is enabled.
  34651. */
  34652. fxaaEnabled: boolean;
  34653. private _samples;
  34654. /**
  34655. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  34656. */
  34657. samples: number;
  34658. /**
  34659. * If image processing is enabled.
  34660. */
  34661. imageProcessingEnabled: boolean;
  34662. /**
  34663. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  34664. */
  34665. glowLayerEnabled: boolean;
  34666. /**
  34667. * Enable or disable the chromaticAberration process from the pipeline
  34668. */
  34669. chromaticAberrationEnabled: boolean;
  34670. /**
  34671. * Enable or disable the grain process from the pipeline
  34672. */
  34673. grainEnabled: boolean;
  34674. /**
  34675. * @constructor
  34676. * @param {string} name - The rendering pipeline name (default: "")
  34677. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  34678. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  34679. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  34680. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  34681. */
  34682. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  34683. /**
  34684. * Force the compilation of the entire pipeline.
  34685. */
  34686. prepare(): void;
  34687. private _hasCleared;
  34688. private _prevPostProcess;
  34689. private _prevPrevPostProcess;
  34690. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  34691. private _buildPipeline();
  34692. private _disposePostProcesses(disposeNonRecreated?);
  34693. /**
  34694. * Dispose of the pipeline and stop all post processes
  34695. */
  34696. dispose(): void;
  34697. /**
  34698. * Serialize the rendering pipeline (Used when exporting)
  34699. * @returns the serialized object
  34700. */
  34701. serialize(): any;
  34702. /**
  34703. * Parse the serialized pipeline
  34704. * @param source Source pipeline.
  34705. * @param scene The scene to load the pipeline to.
  34706. * @param rootUrl The URL of the serialized pipeline.
  34707. * @returns An instantiated pipeline from the serialized object.
  34708. */
  34709. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  34710. }
  34711. }
  34712. declare module BABYLON {
  34713. class LensRenderingPipeline extends PostProcessRenderPipeline {
  34714. /**
  34715. * The chromatic aberration PostProcess id in the pipeline
  34716. */
  34717. LensChromaticAberrationEffect: string;
  34718. /**
  34719. * The highlights enhancing PostProcess id in the pipeline
  34720. */
  34721. HighlightsEnhancingEffect: string;
  34722. /**
  34723. * The depth-of-field PostProcess id in the pipeline
  34724. */
  34725. LensDepthOfFieldEffect: string;
  34726. private _scene;
  34727. private _depthTexture;
  34728. private _grainTexture;
  34729. private _chromaticAberrationPostProcess;
  34730. private _highlightsPostProcess;
  34731. private _depthOfFieldPostProcess;
  34732. private _edgeBlur;
  34733. private _grainAmount;
  34734. private _chromaticAberration;
  34735. private _distortion;
  34736. private _highlightsGain;
  34737. private _highlightsThreshold;
  34738. private _dofDistance;
  34739. private _dofAperture;
  34740. private _dofDarken;
  34741. private _dofPentagon;
  34742. private _blurNoise;
  34743. /**
  34744. * @constructor
  34745. *
  34746. * Effect parameters are as follow:
  34747. * {
  34748. * chromatic_aberration: number; // from 0 to x (1 for realism)
  34749. * edge_blur: number; // from 0 to x (1 for realism)
  34750. * distortion: number; // from 0 to x (1 for realism)
  34751. * grain_amount: number; // from 0 to 1
  34752. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  34753. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  34754. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  34755. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  34756. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  34757. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  34758. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  34759. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  34760. * }
  34761. * Note: if an effect parameter is unset, effect is disabled
  34762. *
  34763. * @param {string} name - The rendering pipeline name
  34764. * @param {object} parameters - An object containing all parameters (see above)
  34765. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34766. * @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)
  34767. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34768. */
  34769. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  34770. setEdgeBlur(amount: number): void;
  34771. disableEdgeBlur(): void;
  34772. setGrainAmount(amount: number): void;
  34773. disableGrain(): void;
  34774. setChromaticAberration(amount: number): void;
  34775. disableChromaticAberration(): void;
  34776. setEdgeDistortion(amount: number): void;
  34777. disableEdgeDistortion(): void;
  34778. setFocusDistance(amount: number): void;
  34779. disableDepthOfField(): void;
  34780. setAperture(amount: number): void;
  34781. setDarkenOutOfFocus(amount: number): void;
  34782. enablePentagonBokeh(): void;
  34783. disablePentagonBokeh(): void;
  34784. enableNoiseBlur(): void;
  34785. disableNoiseBlur(): void;
  34786. setHighlightsGain(amount: number): void;
  34787. setHighlightsThreshold(amount: number): void;
  34788. disableHighlights(): void;
  34789. /**
  34790. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  34791. */
  34792. dispose(disableDepthRender?: boolean): void;
  34793. private _createChromaticAberrationPostProcess(ratio);
  34794. private _createHighlightsPostProcess(ratio);
  34795. private _createDepthOfFieldPostProcess(ratio);
  34796. private _createGrainTexture();
  34797. }
  34798. }
  34799. declare module BABYLON {
  34800. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  34801. /**
  34802. * The PassPostProcess id in the pipeline that contains the original scene color
  34803. */
  34804. SSAOOriginalSceneColorEffect: string;
  34805. /**
  34806. * The SSAO PostProcess id in the pipeline
  34807. */
  34808. SSAORenderEffect: string;
  34809. /**
  34810. * The horizontal blur PostProcess id in the pipeline
  34811. */
  34812. SSAOBlurHRenderEffect: string;
  34813. /**
  34814. * The vertical blur PostProcess id in the pipeline
  34815. */
  34816. SSAOBlurVRenderEffect: string;
  34817. /**
  34818. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  34819. */
  34820. SSAOCombineRenderEffect: string;
  34821. /**
  34822. * The output strength of the SSAO post-process. Default value is 1.0.
  34823. */
  34824. totalStrength: number;
  34825. /**
  34826. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  34827. */
  34828. maxZ: number;
  34829. /**
  34830. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  34831. */
  34832. minZAspect: number;
  34833. /**
  34834. * Number of samples used for the SSAO calculations. Default value is 8
  34835. */
  34836. private _samples;
  34837. /**
  34838. * Ratio object used for SSAO ratio and blur ratio
  34839. */
  34840. private _ratio;
  34841. /**
  34842. * Dynamically generated sphere sampler.
  34843. */
  34844. private _sampleSphere;
  34845. /**
  34846. * Blur filter offsets
  34847. */
  34848. private _samplerOffsets;
  34849. samples: number;
  34850. /**
  34851. * Are we using bilateral blur ?
  34852. */
  34853. private _expensiveBlur;
  34854. expensiveBlur: boolean;
  34855. /**
  34856. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  34857. */
  34858. radius: number;
  34859. /**
  34860. * The base color of the SSAO post-process
  34861. * The final result is "base + ssao" between [0, 1]
  34862. */
  34863. base: number;
  34864. /**
  34865. * Support test.
  34866. */
  34867. static readonly IsSupported: boolean;
  34868. private _scene;
  34869. private _depthTexture;
  34870. private _normalTexture;
  34871. private _randomTexture;
  34872. private _originalColorPostProcess;
  34873. private _ssaoPostProcess;
  34874. private _blurHPostProcess;
  34875. private _blurVPostProcess;
  34876. private _ssaoCombinePostProcess;
  34877. private _firstUpdate;
  34878. /**
  34879. * @constructor
  34880. * @param {string} name - The rendering pipeline name
  34881. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34882. * @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 }
  34883. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34884. */
  34885. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  34886. /**
  34887. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  34888. */
  34889. dispose(disableGeometryBufferRenderer?: boolean): void;
  34890. private _createBlurPostProcess(ssaoRatio, blurRatio);
  34891. _rebuild(): void;
  34892. private _generateHemisphere();
  34893. private _createSSAOPostProcess(ratio);
  34894. private _createSSAOCombinePostProcess(ratio);
  34895. private _createRandomTexture();
  34896. /**
  34897. * Serialize the rendering pipeline (Used when exporting)
  34898. * @returns the serialized object
  34899. */
  34900. serialize(): any;
  34901. /**
  34902. * Parse the serialized pipeline
  34903. * @param source Source pipeline.
  34904. * @param scene The scene to load the pipeline to.
  34905. * @param rootUrl The URL of the serialized pipeline.
  34906. * @returns An instantiated pipeline from the serialized object.
  34907. */
  34908. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  34909. }
  34910. }
  34911. declare module BABYLON {
  34912. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  34913. /**
  34914. * The PassPostProcess id in the pipeline that contains the original scene color
  34915. */
  34916. SSAOOriginalSceneColorEffect: string;
  34917. /**
  34918. * The SSAO PostProcess id in the pipeline
  34919. */
  34920. SSAORenderEffect: string;
  34921. /**
  34922. * The horizontal blur PostProcess id in the pipeline
  34923. */
  34924. SSAOBlurHRenderEffect: string;
  34925. /**
  34926. * The vertical blur PostProcess id in the pipeline
  34927. */
  34928. SSAOBlurVRenderEffect: string;
  34929. /**
  34930. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  34931. */
  34932. SSAOCombineRenderEffect: string;
  34933. /**
  34934. * The output strength of the SSAO post-process. Default value is 1.0.
  34935. */
  34936. totalStrength: number;
  34937. /**
  34938. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  34939. */
  34940. radius: number;
  34941. /**
  34942. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  34943. * Must not be equal to fallOff and superior to fallOff.
  34944. * Default value is 0.975
  34945. */
  34946. area: number;
  34947. /**
  34948. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  34949. * Must not be equal to area and inferior to area.
  34950. * Default value is 0.0
  34951. */
  34952. fallOff: number;
  34953. /**
  34954. * The base color of the SSAO post-process
  34955. * The final result is "base + ssao" between [0, 1]
  34956. */
  34957. base: number;
  34958. private _scene;
  34959. private _depthTexture;
  34960. private _randomTexture;
  34961. private _originalColorPostProcess;
  34962. private _ssaoPostProcess;
  34963. private _blurHPostProcess;
  34964. private _blurVPostProcess;
  34965. private _ssaoCombinePostProcess;
  34966. private _firstUpdate;
  34967. /**
  34968. * @constructor
  34969. * @param {string} name - The rendering pipeline name
  34970. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34971. * @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 }
  34972. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34973. */
  34974. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  34975. /**
  34976. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  34977. */
  34978. dispose(disableDepthRender?: boolean): void;
  34979. private _createBlurPostProcess(ratio);
  34980. _rebuild(): void;
  34981. private _createSSAOPostProcess(ratio);
  34982. private _createSSAOCombinePostProcess(ratio);
  34983. private _createRandomTexture();
  34984. }
  34985. }
  34986. declare module BABYLON {
  34987. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  34988. /**
  34989. * Public members
  34990. */
  34991. originalPostProcess: Nullable<PostProcess>;
  34992. downSampleX4PostProcess: Nullable<PostProcess>;
  34993. brightPassPostProcess: Nullable<PostProcess>;
  34994. blurHPostProcesses: PostProcess[];
  34995. blurVPostProcesses: PostProcess[];
  34996. textureAdderPostProcess: Nullable<PostProcess>;
  34997. volumetricLightPostProcess: Nullable<PostProcess>;
  34998. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  34999. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  35000. volumetricLightMergePostProces: Nullable<PostProcess>;
  35001. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  35002. luminancePostProcess: Nullable<PostProcess>;
  35003. luminanceDownSamplePostProcesses: PostProcess[];
  35004. hdrPostProcess: Nullable<PostProcess>;
  35005. textureAdderFinalPostProcess: Nullable<PostProcess>;
  35006. lensFlareFinalPostProcess: Nullable<PostProcess>;
  35007. hdrFinalPostProcess: Nullable<PostProcess>;
  35008. lensFlarePostProcess: Nullable<PostProcess>;
  35009. lensFlareComposePostProcess: Nullable<PostProcess>;
  35010. motionBlurPostProcess: Nullable<PostProcess>;
  35011. depthOfFieldPostProcess: Nullable<PostProcess>;
  35012. brightThreshold: number;
  35013. blurWidth: number;
  35014. horizontalBlur: boolean;
  35015. exposure: number;
  35016. lensTexture: Nullable<Texture>;
  35017. volumetricLightCoefficient: number;
  35018. volumetricLightPower: number;
  35019. volumetricLightBlurScale: number;
  35020. sourceLight: Nullable<SpotLight | DirectionalLight>;
  35021. hdrMinimumLuminance: number;
  35022. hdrDecreaseRate: number;
  35023. hdrIncreaseRate: number;
  35024. lensColorTexture: Nullable<Texture>;
  35025. lensFlareStrength: number;
  35026. lensFlareGhostDispersal: number;
  35027. lensFlareHaloWidth: number;
  35028. lensFlareDistortionStrength: number;
  35029. lensStarTexture: Nullable<Texture>;
  35030. lensFlareDirtTexture: Nullable<Texture>;
  35031. depthOfFieldDistance: number;
  35032. depthOfFieldBlurWidth: number;
  35033. motionStrength: number;
  35034. animations: Animation[];
  35035. /**
  35036. * Private members
  35037. */
  35038. private _scene;
  35039. private _currentDepthOfFieldSource;
  35040. private _basePostProcess;
  35041. private _hdrCurrentLuminance;
  35042. private _floatTextureType;
  35043. private _ratio;
  35044. private _bloomEnabled;
  35045. private _depthOfFieldEnabled;
  35046. private _vlsEnabled;
  35047. private _lensFlareEnabled;
  35048. private _hdrEnabled;
  35049. private _motionBlurEnabled;
  35050. private _motionBlurSamples;
  35051. private _volumetricLightStepsCount;
  35052. BloomEnabled: boolean;
  35053. DepthOfFieldEnabled: boolean;
  35054. LensFlareEnabled: boolean;
  35055. HDREnabled: boolean;
  35056. VLSEnabled: boolean;
  35057. MotionBlurEnabled: boolean;
  35058. volumetricLightStepsCount: number;
  35059. motionBlurSamples: number;
  35060. /**
  35061. * @constructor
  35062. * @param {string} name - The rendering pipeline name
  35063. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35064. * @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)
  35065. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  35066. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35067. */
  35068. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  35069. private _buildPipeline();
  35070. private _createDownSampleX4PostProcess(scene, ratio);
  35071. private _createBrightPassPostProcess(scene, ratio);
  35072. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  35073. private _createTextureAdderPostProcess(scene, ratio);
  35074. private _createVolumetricLightPostProcess(scene, ratio);
  35075. private _createLuminancePostProcesses(scene, textureType);
  35076. private _createHdrPostProcess(scene, ratio);
  35077. private _createLensFlarePostProcess(scene, ratio);
  35078. private _createDepthOfFieldPostProcess(scene, ratio);
  35079. private _createMotionBlurPostProcess(scene, ratio);
  35080. private _getDepthTexture();
  35081. private _disposePostProcesses();
  35082. /**
  35083. * Dispose of the pipeline and stop all post processes
  35084. */
  35085. dispose(): void;
  35086. /**
  35087. * Serialize the rendering pipeline (Used when exporting)
  35088. * @returns the serialized object
  35089. */
  35090. serialize(): any;
  35091. /**
  35092. * Parse the serialized pipeline
  35093. * @param source Source pipeline.
  35094. * @param scene The scene to load the pipeline to.
  35095. * @param rootUrl The URL of the serialized pipeline.
  35096. * @returns An instantiated pipeline from the serialized object.
  35097. */
  35098. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  35099. static LuminanceSteps: number;
  35100. }
  35101. }