babylon.d.ts 1.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219
  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 _timeAccumulator;
  1018. private _currentStepId;
  1019. private _currentInternalStep;
  1020. /** @hidden */
  1021. _mirroredCameraPosition: Nullable<Vector3>;
  1022. /**
  1023. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1024. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1025. */
  1026. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1027. /**
  1028. * Observable event triggered each time an keyboard event is received from the hosting window
  1029. */
  1030. onKeyboardObservable: Observable<KeyboardInfo>;
  1031. private _onKeyDown;
  1032. private _onKeyUp;
  1033. private _onCanvasFocusObserver;
  1034. private _onCanvasBlurObserver;
  1035. private _useRightHandedSystem;
  1036. /**
  1037. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1038. */
  1039. useRightHandedSystem: boolean;
  1040. /**
  1041. * Sets the step Id used by deterministic lock step
  1042. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1043. * @param newStepId defines the step Id
  1044. */
  1045. setStepId(newStepId: number): void;
  1046. /**
  1047. * Gets the step Id used by deterministic lock step
  1048. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1049. * @returns the step Id
  1050. */
  1051. getStepId(): number;
  1052. /**
  1053. * Gets the internal step used by deterministic lock step
  1054. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1055. * @returns the internal step
  1056. */
  1057. getInternalStep(): number;
  1058. private _fogEnabled;
  1059. /**
  1060. * Gets or sets a boolean indicating if fog is enabled on this scene
  1061. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1062. */
  1063. fogEnabled: boolean;
  1064. private _fogMode;
  1065. /**
  1066. * Gets or sets the fog mode to use
  1067. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1068. */
  1069. fogMode: number;
  1070. /**
  1071. * Gets or sets the fog color to use
  1072. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1073. */
  1074. fogColor: Color3;
  1075. /**
  1076. * Gets or sets the fog density to use
  1077. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1078. */
  1079. fogDensity: number;
  1080. /**
  1081. * Gets or sets the fog start distance to use
  1082. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1083. */
  1084. fogStart: number;
  1085. /**
  1086. * Gets or sets the fog end distance to use
  1087. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1088. */
  1089. fogEnd: number;
  1090. private _shadowsEnabled;
  1091. /**
  1092. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1093. */
  1094. shadowsEnabled: boolean;
  1095. private _lightsEnabled;
  1096. /**
  1097. * Gets or sets a boolean indicating if lights are enabled on this scene
  1098. */
  1099. lightsEnabled: boolean;
  1100. /**
  1101. * All of the lights added to this scene
  1102. * @see http://doc.babylonjs.com/babylon101/lights
  1103. */
  1104. lights: Light[];
  1105. /** All of the cameras added to this scene.
  1106. * @see http://doc.babylonjs.com/babylon101/cameras
  1107. */
  1108. cameras: Camera[];
  1109. /** All of the active cameras added to this scene. */
  1110. activeCameras: Camera[];
  1111. /** The current active camera */
  1112. activeCamera: Nullable<Camera>;
  1113. /**
  1114. * All of the tranform nodes added to this scene
  1115. * @see http://doc.babylonjs.com/how_to/transformnode
  1116. */
  1117. transformNodes: TransformNode[];
  1118. /**
  1119. * All of the (abstract) meshes added to this scene
  1120. */
  1121. meshes: AbstractMesh[];
  1122. /**
  1123. * All of the animation groups added to this scene
  1124. * @see http://doc.babylonjs.com/how_to/group
  1125. */
  1126. animationGroups: AnimationGroup[];
  1127. private _geometries;
  1128. /**
  1129. * All of the materials added to this scene
  1130. * @see http://doc.babylonjs.com/babylon101/materials
  1131. */
  1132. materials: Material[];
  1133. /**
  1134. * All of the multi-materials added to this scene
  1135. * @see http://doc.babylonjs.com/how_to/multi_materials
  1136. */
  1137. multiMaterials: MultiMaterial[];
  1138. private _defaultMaterial;
  1139. /** The default material used on meshes when no material is affected */
  1140. /** The default material used on meshes when no material is affected */
  1141. defaultMaterial: Material;
  1142. private _texturesEnabled;
  1143. /**
  1144. * Gets or sets a boolean indicating if textures are enabled on this scene
  1145. */
  1146. texturesEnabled: boolean;
  1147. /**
  1148. * All of the textures added to this scene
  1149. */
  1150. textures: BaseTexture[];
  1151. /**
  1152. * Gets or sets a boolean indicating if particles are enabled on this scene
  1153. */
  1154. particlesEnabled: boolean;
  1155. /**
  1156. * All of the particle systems added to this scene
  1157. * @see http://doc.babylonjs.com/babylon101/particles
  1158. */
  1159. particleSystems: IParticleSystem[];
  1160. /**
  1161. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1162. */
  1163. spritesEnabled: boolean;
  1164. /**
  1165. * All of the sprite managers added to this scene
  1166. * @see http://doc.babylonjs.com/babylon101/sprites
  1167. */
  1168. spriteManagers: SpriteManager[];
  1169. /**
  1170. * The list of layers (background and foreground) of the scene
  1171. */
  1172. layers: Layer[];
  1173. /**
  1174. * The list of effect layers (highlights/glow) added to the scene
  1175. * @see http://doc.babylonjs.com/how_to/highlight_layer
  1176. * @see http://doc.babylonjs.com/how_to/glow_layer
  1177. */
  1178. effectLayers: EffectLayer[];
  1179. private _skeletonsEnabled;
  1180. /**
  1181. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1182. */
  1183. skeletonsEnabled: boolean;
  1184. /**
  1185. * The list of skeletons added to the scene
  1186. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  1187. */
  1188. skeletons: Skeleton[];
  1189. /**
  1190. * The list of morph target managers added to the scene
  1191. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  1192. */
  1193. morphTargetManagers: MorphTargetManager[];
  1194. /**
  1195. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1196. */
  1197. lensFlaresEnabled: boolean;
  1198. /**
  1199. * The list of lens flare system added to the scene
  1200. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  1201. */
  1202. lensFlareSystems: LensFlareSystem[];
  1203. /**
  1204. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1205. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1206. */
  1207. collisionsEnabled: boolean;
  1208. private _workerCollisions;
  1209. /** @hidden */
  1210. collisionCoordinator: ICollisionCoordinator;
  1211. /**
  1212. * Defines the gravity applied to this scene (used only for collisions)
  1213. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1214. */
  1215. gravity: Vector3;
  1216. /**
  1217. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1218. */
  1219. postProcessesEnabled: boolean;
  1220. /**
  1221. * The list of postprocesses added to the scene
  1222. */
  1223. postProcesses: PostProcess[];
  1224. /**
  1225. * Gets the current postprocess manager
  1226. */
  1227. postProcessManager: PostProcessManager;
  1228. private _postProcessRenderPipelineManager;
  1229. /**
  1230. * Gets the postprocess render pipeline manager
  1231. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1232. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1233. */
  1234. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1235. /**
  1236. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1237. */
  1238. renderTargetsEnabled: boolean;
  1239. /**
  1240. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1241. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1242. */
  1243. dumpNextRenderTargets: boolean;
  1244. /**
  1245. * The list of user defined render targets added to the scene
  1246. */
  1247. customRenderTargets: RenderTargetTexture[];
  1248. /**
  1249. * Defines if texture loading must be delayed
  1250. * If true, textures will only be loaded when they need to be rendered
  1251. */
  1252. useDelayedTextureLoading: boolean;
  1253. /**
  1254. * Gets the list of meshes imported to the scene through SceneLoader
  1255. */
  1256. importedMeshesFiles: String[];
  1257. /**
  1258. * Gets or sets a boolean indicating if probes are enabled on this scene
  1259. */
  1260. probesEnabled: boolean;
  1261. /**
  1262. * The list of reflection probes added to the scene
  1263. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1264. */
  1265. reflectionProbes: ReflectionProbe[];
  1266. /**
  1267. * @hidden
  1268. */
  1269. database: Database;
  1270. /**
  1271. * Gets or sets the action manager associated with the scene
  1272. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1273. */
  1274. actionManager: ActionManager;
  1275. /** @hidden */
  1276. _actionManagers: ActionManager[];
  1277. private _meshesForIntersections;
  1278. /**
  1279. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1280. */
  1281. proceduralTexturesEnabled: boolean;
  1282. /**
  1283. * The list of procedural textures added to the scene
  1284. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1285. */
  1286. proceduralTextures: ProceduralTexture[];
  1287. private _mainSoundTrack;
  1288. /**
  1289. * The list of sound tracks added to the scene
  1290. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1291. */
  1292. soundTracks: SoundTrack[];
  1293. private _audioEnabled;
  1294. private _headphone;
  1295. /**
  1296. * Gets the main soundtrack associated with the scene
  1297. */
  1298. readonly mainSoundTrack: SoundTrack;
  1299. /**
  1300. * Gets or sets the VRExperienceHelper attached to the scene
  1301. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1302. * @ignorenaming
  1303. */
  1304. VRHelper: VRExperienceHelper;
  1305. /**
  1306. * Gets or sets the simplification queue attached to the scene
  1307. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1308. */
  1309. simplificationQueue: SimplificationQueue;
  1310. private _engine;
  1311. private _totalVertices;
  1312. /** @hidden */
  1313. _activeIndices: PerfCounter;
  1314. /** @hidden */
  1315. _activeParticles: PerfCounter;
  1316. /** @hidden */
  1317. _activeBones: PerfCounter;
  1318. private _animationRatio;
  1319. private _animationTimeLast;
  1320. private _animationTime;
  1321. /**
  1322. * Gets or sets a general scale for animation speed
  1323. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1324. */
  1325. animationTimeScale: number;
  1326. /** @hidden */
  1327. _cachedMaterial: Nullable<Material>;
  1328. /** @hidden */
  1329. _cachedEffect: Nullable<Effect>;
  1330. /** @hidden */
  1331. _cachedVisibility: Nullable<number>;
  1332. private _renderId;
  1333. private _executeWhenReadyTimeoutId;
  1334. private _intermediateRendering;
  1335. private _viewUpdateFlag;
  1336. private _projectionUpdateFlag;
  1337. private _alternateViewUpdateFlag;
  1338. private _alternateProjectionUpdateFlag;
  1339. /** @hidden */
  1340. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1341. private _activeRequests;
  1342. private _pendingData;
  1343. private _isDisposed;
  1344. /**
  1345. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1346. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1347. */
  1348. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1349. private _activeMeshes;
  1350. private _processedMaterials;
  1351. private _renderTargets;
  1352. /** @hidden */
  1353. _activeParticleSystems: SmartArray<IParticleSystem>;
  1354. private _activeSkeletons;
  1355. private _softwareSkinnedMeshes;
  1356. private _renderingManager;
  1357. private _physicsEngine;
  1358. /** @hidden */
  1359. _activeAnimatables: Animatable[];
  1360. private _transformMatrix;
  1361. private _sceneUbo;
  1362. private _alternateSceneUbo;
  1363. private _pickWithRayInverseMatrix;
  1364. private _boundingBoxRenderer;
  1365. private _outlineRenderer;
  1366. private _viewMatrix;
  1367. private _projectionMatrix;
  1368. private _alternateViewMatrix;
  1369. private _alternateProjectionMatrix;
  1370. private _alternateTransformMatrix;
  1371. private _useAlternateCameraConfiguration;
  1372. private _alternateRendering;
  1373. /** @hidden */
  1374. _forcedViewPosition: Nullable<Vector3>;
  1375. /** @hidden */
  1376. readonly _isAlternateRenderingEnabled: boolean;
  1377. private _frustumPlanes;
  1378. /**
  1379. * Gets the list of frustum planes (built from the active camera)
  1380. */
  1381. readonly frustumPlanes: Plane[];
  1382. /**
  1383. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1384. * This is useful if there are more lights that the maximum simulteanous authorized
  1385. */
  1386. requireLightSorting: boolean;
  1387. private _selectionOctree;
  1388. private _pointerOverMesh;
  1389. private _pointerOverSprite;
  1390. private _debugLayer;
  1391. private _depthRenderer;
  1392. private _geometryBufferRenderer;
  1393. /**
  1394. * Gets the current geometry buffer associated to the scene.
  1395. */
  1396. /**
  1397. * Sets the current geometry buffer for the scene.
  1398. */
  1399. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1400. private _pickedDownMesh;
  1401. private _pickedUpMesh;
  1402. private _pickedDownSprite;
  1403. private _externalData;
  1404. private _uid;
  1405. /**
  1406. * Creates a new Scene
  1407. * @param engine defines the engine to use to render this scene
  1408. */
  1409. constructor(engine: Engine);
  1410. /**
  1411. * Gets the debug layer associated with the scene
  1412. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1413. */
  1414. readonly debugLayer: DebugLayer;
  1415. /**
  1416. * Gets a boolean indicating if collisions are processed on a web worker
  1417. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1418. */
  1419. workerCollisions: boolean;
  1420. /**
  1421. * Gets the octree used to boost mesh selection (picking)
  1422. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1423. */
  1424. readonly selectionOctree: Octree<AbstractMesh>;
  1425. /**
  1426. * Gets the mesh that is currently under the pointer
  1427. */
  1428. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1429. /**
  1430. * Gets the current on-screen X position of the pointer
  1431. */
  1432. readonly pointerX: number;
  1433. /**
  1434. * Gets the current on-screen Y position of the pointer
  1435. */
  1436. readonly pointerY: number;
  1437. /**
  1438. * Gets the cached material (ie. the latest rendered one)
  1439. * @returns the cached material
  1440. */
  1441. getCachedMaterial(): Nullable<Material>;
  1442. /**
  1443. * Gets the cached effect (ie. the latest rendered one)
  1444. * @returns the cached effect
  1445. */
  1446. getCachedEffect(): Nullable<Effect>;
  1447. /**
  1448. * Gets the cached visibility state (ie. the latest rendered one)
  1449. * @returns the cached visibility state
  1450. */
  1451. getCachedVisibility(): Nullable<number>;
  1452. /**
  1453. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1454. * @param material defines the current material
  1455. * @param effect defines the current effect
  1456. * @param visibility defines the current visibility state
  1457. * @returns true if one parameter is not cached
  1458. */
  1459. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1460. /**
  1461. * Gets the bounding box renderer associated with the scene
  1462. * @returns a BoundingBoxRenderer
  1463. */
  1464. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1465. /**
  1466. * Gets the outline renderer associated with the scene
  1467. * @returns a OutlineRenderer
  1468. */
  1469. getOutlineRenderer(): OutlineRenderer;
  1470. /**
  1471. * Gets the engine associated with the scene
  1472. * @returns an Engine
  1473. */
  1474. getEngine(): Engine;
  1475. /**
  1476. * Gets the total number of vertices rendered per frame
  1477. * @returns the total number of vertices rendered per frame
  1478. */
  1479. getTotalVertices(): number;
  1480. /**
  1481. * Gets the performance counter for total vertices
  1482. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1483. */
  1484. readonly totalVerticesPerfCounter: PerfCounter;
  1485. /**
  1486. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1487. * @returns the total number of active indices rendered per frame
  1488. */
  1489. getActiveIndices(): number;
  1490. /**
  1491. * Gets the performance counter for active indices
  1492. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1493. */
  1494. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1495. /**
  1496. * Gets the total number of active particles rendered per frame
  1497. * @returns the total number of active particles rendered per frame
  1498. */
  1499. getActiveParticles(): number;
  1500. /**
  1501. * Gets the performance counter for active particles
  1502. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1503. */
  1504. readonly activeParticlesPerfCounter: PerfCounter;
  1505. /**
  1506. * Gets the total number of active bones rendered per frame
  1507. * @returns the total number of active bones rendered per frame
  1508. */
  1509. getActiveBones(): number;
  1510. /**
  1511. * Gets the performance counter for active bones
  1512. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1513. */
  1514. readonly activeBonesPerfCounter: PerfCounter;
  1515. /** @hidden */
  1516. getInterFramePerfCounter(): number;
  1517. /** @hidden */
  1518. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1519. /** @hidden */
  1520. getLastFrameDuration(): number;
  1521. /** @hidden */
  1522. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1523. /** @hidden */
  1524. getEvaluateActiveMeshesDuration(): number;
  1525. /** @hidden */
  1526. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1527. /**
  1528. * Gets the array of active meshes
  1529. * @returns an array of AbstractMesh
  1530. */
  1531. getActiveMeshes(): SmartArray<AbstractMesh>;
  1532. /** @hidden */
  1533. getRenderTargetsDuration(): number;
  1534. /** @hidden */
  1535. getRenderDuration(): number;
  1536. /** @hidden */
  1537. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1538. /** @hidden */
  1539. getParticlesDuration(): number;
  1540. /** @hidden */
  1541. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1542. /** @hidden */
  1543. getSpritesDuration(): number;
  1544. /** @hidden */
  1545. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1546. /**
  1547. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1548. * @returns a number
  1549. */
  1550. getAnimationRatio(): number;
  1551. /**
  1552. * Gets an unique Id for the current frame
  1553. * @returns a number
  1554. */
  1555. getRenderId(): number;
  1556. /** Call this function if you want to manually increment the render Id*/
  1557. incrementRenderId(): void;
  1558. private _updatePointerPosition(evt);
  1559. private _createUbo();
  1560. private _createAlternateUbo();
  1561. /**
  1562. * Use this method to simulate a pointer move on a mesh
  1563. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1564. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1565. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1566. * @returns the current scene
  1567. */
  1568. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1569. private _processPointerMove(pickResult, evt);
  1570. /**
  1571. * Use this method to simulate a pointer down on a mesh
  1572. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1573. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1574. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1575. * @returns the current scene
  1576. */
  1577. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1578. private _processPointerDown(pickResult, evt);
  1579. /**
  1580. * Use this method to simulate a pointer up on a mesh
  1581. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1582. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1583. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1584. * @returns the current scene
  1585. */
  1586. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1587. private _processPointerUp(pickResult, evt, clickInfo);
  1588. /**
  1589. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1590. * @param attachUp defines if you want to attach events to pointerup
  1591. * @param attachDown defines if you want to attach events to pointerdown
  1592. * @param attachMove defines if you want to attach events to pointermove
  1593. */
  1594. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1595. /** Detaches all event handlers*/
  1596. detachControl(): void;
  1597. /**
  1598. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1599. * Delay loaded resources are not taking in account
  1600. * @return true if all required resources are ready
  1601. */
  1602. isReady(): boolean;
  1603. /** Resets all cached information relative to material (including effect and visibility) */
  1604. resetCachedMaterial(): void;
  1605. /**
  1606. * Registers a function to be called before every frame render
  1607. * @param func defines the function to register
  1608. */
  1609. registerBeforeRender(func: () => void): void;
  1610. /**
  1611. * Unregisters a function called before every frame render
  1612. * @param func defines the function to unregister
  1613. */
  1614. unregisterBeforeRender(func: () => void): void;
  1615. /**
  1616. * Registers a function to be called after every frame render
  1617. * @param func defines the function to register
  1618. */
  1619. registerAfterRender(func: () => void): void;
  1620. /**
  1621. * Unregisters a function called after every frame render
  1622. * @param func defines the function to unregister
  1623. */
  1624. unregisterAfterRender(func: () => void): void;
  1625. private _executeOnceBeforeRender(func);
  1626. /**
  1627. * The provided function will run before render once and will be disposed afterwards.
  1628. * A timeout delay can be provided so that the function will be executed in N ms.
  1629. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1630. * @param func The function to be executed.
  1631. * @param timeout optional delay in ms
  1632. */
  1633. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1634. /** @hidden */
  1635. _addPendingData(data: any): void;
  1636. /** @hidden */
  1637. _removePendingData(data: any): void;
  1638. /**
  1639. * Returns the number of items waiting to be loaded
  1640. * @returns the number of items waiting to be loaded
  1641. */
  1642. getWaitingItemsCount(): number;
  1643. /**
  1644. * Returns a boolean indicating if the scene is still loading data
  1645. */
  1646. readonly isLoading: boolean;
  1647. /**
  1648. * Registers a function to be executed when the scene is ready
  1649. * @param {Function} func - the function to be executed
  1650. */
  1651. executeWhenReady(func: () => void): void;
  1652. /**
  1653. * Returns a promise that resolves when the scene is ready
  1654. * @returns A promise that resolves when the scene is ready
  1655. */
  1656. whenReadyAsync(): Promise<void>;
  1657. /** @hidden */
  1658. _checkIsReady(): void;
  1659. /**
  1660. * Will start the animation sequence of a given target
  1661. * @param target defines the target
  1662. * @param from defines from which frame should animation start
  1663. * @param to defines until which frame should animation run.
  1664. * @param weight defines the weight to apply to the animation (1.0 by default)
  1665. * @param loop defines if the animation loops
  1666. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1667. * @param onAnimationEnd defines the function to be executed when the animation ends
  1668. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1669. * @returns the animatable object created for this animation
  1670. */
  1671. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1672. /**
  1673. * Will start the animation sequence of a given target
  1674. * @param target defines the target
  1675. * @param from defines from which frame should animation start
  1676. * @param to defines until which frame should animation run.
  1677. * @param loop defines if the animation loops
  1678. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1679. * @param onAnimationEnd defines the function to be executed when the animation ends
  1680. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1681. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1682. * @returns the animatable object created for this animation
  1683. */
  1684. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean): Animatable;
  1685. /**
  1686. * Begin a new animation on a given node
  1687. * @param target defines the target where the animation will take place
  1688. * @param animations defines the list of animations to start
  1689. * @param from defines the initial value
  1690. * @param to defines the final value
  1691. * @param loop defines if you want animation to loop (off by default)
  1692. * @param speedRatio defines the speed ratio to apply to all animations
  1693. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1694. * @returns the list of created animatables
  1695. */
  1696. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1697. /**
  1698. * Begin a new animation on a given node and its hierarchy
  1699. * @param target defines the root node where the animation will take place
  1700. * @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.
  1701. * @param animations defines the list of animations to start
  1702. * @param from defines the initial value
  1703. * @param to defines the final value
  1704. * @param loop defines if you want animation to loop (off by default)
  1705. * @param speedRatio defines the speed ratio to apply to all animations
  1706. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1707. * @returns the list of animatables created for all nodes
  1708. */
  1709. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1710. /**
  1711. * Gets the animatable associated with a specific target
  1712. * @param target defines the target of the animatable
  1713. * @returns the required animatable if found
  1714. */
  1715. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1716. /**
  1717. * Gets all animatables associated with a given target
  1718. * @param target defines the target to look animatables for
  1719. * @returns an array of Animatables
  1720. */
  1721. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1722. /**
  1723. * Gets all animatable attached to the scene
  1724. */
  1725. readonly animatables: Animatable[];
  1726. /**
  1727. * Will stop the animation of the given target
  1728. * @param target - the target
  1729. * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
  1730. */
  1731. stopAnimation(target: any, animationName?: string): void;
  1732. /**
  1733. * Stops and removes all animations that have been applied to the scene
  1734. */
  1735. stopAllAnimations(): void;
  1736. private _animate();
  1737. /** @hidden */
  1738. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation): void;
  1739. private _processLateAnimationBindingsForMatrices(holder, originalValue);
  1740. private _processLateAnimationBindings();
  1741. /** @hidden */
  1742. _switchToAlternateCameraConfiguration(active: boolean): void;
  1743. /**
  1744. * Gets the current view matrix
  1745. * @returns a Matrix
  1746. */
  1747. getViewMatrix(): Matrix;
  1748. /**
  1749. * Gets the current projection matrix
  1750. * @returns a Matrix
  1751. */
  1752. getProjectionMatrix(): Matrix;
  1753. /**
  1754. * Gets the current transform matrix
  1755. * @returns a Matrix made of View * Projection
  1756. */
  1757. getTransformMatrix(): Matrix;
  1758. /**
  1759. * Sets the current transform matrix
  1760. * @param view defines the View matrix to use
  1761. * @param projection defines the Projection matrix to use
  1762. */
  1763. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1764. /** @hidden */
  1765. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1766. /**
  1767. * Gets the uniform buffer used to store scene data
  1768. * @returns a UniformBuffer
  1769. */
  1770. getSceneUniformBuffer(): UniformBuffer;
  1771. /**
  1772. * Gets an unique (relatively to the current scene) Id
  1773. * @returns an unique number for the scene
  1774. */
  1775. getUniqueId(): number;
  1776. /**
  1777. * Add a mesh to the list of scene's meshes
  1778. * @param newMesh defines the mesh to add
  1779. */
  1780. addMesh(newMesh: AbstractMesh): void;
  1781. /**
  1782. * Remove a mesh for the list of scene's meshes
  1783. * @param toRemove defines the mesh to remove
  1784. * @param recursive if all child meshes should also be removed from the scene
  1785. * @returns the index where the mesh was in the mesh list
  1786. */
  1787. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1788. /**
  1789. * Add a transform node to the list of scene's transform nodes
  1790. * @param newTransformNode defines the transform node to add
  1791. */
  1792. addTransformNode(newTransformNode: TransformNode): void;
  1793. /**
  1794. * Remove a transform node for the list of scene's transform nodes
  1795. * @param toRemove defines the transform node to remove
  1796. * @returns the index where the transform node was in the transform node list
  1797. */
  1798. removeTransformNode(toRemove: TransformNode): number;
  1799. /**
  1800. * Remove a skeleton for the list of scene's skeletons
  1801. * @param toRemove defines the skeleton to remove
  1802. * @returns the index where the skeleton was in the skeleton list
  1803. */
  1804. removeSkeleton(toRemove: Skeleton): number;
  1805. /**
  1806. * Remove a morph target for the list of scene's morph targets
  1807. * @param toRemove defines the morph target to remove
  1808. * @returns the index where the morph target was in the morph target list
  1809. */
  1810. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1811. /**
  1812. * Remove a light for the list of scene's lights
  1813. * @param toRemove defines the light to remove
  1814. * @returns the index where the light was in the light list
  1815. */
  1816. removeLight(toRemove: Light): number;
  1817. /**
  1818. * Remove a camera for the list of scene's cameras
  1819. * @param toRemove defines the camera to remove
  1820. * @returns the index where the camera was in the camera list
  1821. */
  1822. removeCamera(toRemove: Camera): number;
  1823. /**
  1824. * Remove a particle system for the list of scene's particle systems
  1825. * @param toRemove defines the particle system to remove
  1826. * @returns the index where the particle system was in the particle system list
  1827. */
  1828. removeParticleSystem(toRemove: IParticleSystem): number;
  1829. /**
  1830. * Remove a animation for the list of scene's animations
  1831. * @param toRemove defines the animation to remove
  1832. * @returns the index where the animation was in the animation list
  1833. */
  1834. removeAnimation(toRemove: Animation): number;
  1835. /**
  1836. * Removes the given animation group from this scene.
  1837. * @param toRemove The animation group to remove
  1838. * @returns The index of the removed animation group
  1839. */
  1840. removeAnimationGroup(toRemove: AnimationGroup): number;
  1841. /**
  1842. * Removes the given multi-material from this scene.
  1843. * @param toRemove The multi-material to remove
  1844. * @returns The index of the removed multi-material
  1845. */
  1846. removeMultiMaterial(toRemove: MultiMaterial): number;
  1847. /**
  1848. * Removes the given material from this scene.
  1849. * @param toRemove The material to remove
  1850. * @returns The index of the removed material
  1851. */
  1852. removeMaterial(toRemove: Material): number;
  1853. /**
  1854. * Removes the given lens flare system from this scene.
  1855. * @param toRemove The lens flare system to remove
  1856. * @returns The index of the removed lens flare system
  1857. */
  1858. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1859. /**
  1860. * Removes the given action manager from this scene.
  1861. * @param toRemove The action manager to remove
  1862. * @returns The index of the removed action manager
  1863. */
  1864. removeActionManager(toRemove: ActionManager): number;
  1865. /**
  1866. * Removes the given effect layer from this scene.
  1867. * @param toRemove defines the effect layer to remove
  1868. * @returns the index of the removed effect layer
  1869. */
  1870. removeEffectLayer(toRemove: EffectLayer): number;
  1871. /**
  1872. * Removes the given texture from this scene.
  1873. * @param toRemove The texture to remove
  1874. * @returns The index of the removed texture
  1875. */
  1876. removeTexture(toRemove: BaseTexture): number;
  1877. /**
  1878. * Adds the given light to this scene
  1879. * @param newLight The light to add
  1880. */
  1881. addLight(newLight: Light): void;
  1882. /**
  1883. * Sorts the list list based on light priorities
  1884. */
  1885. sortLightsByPriority(): void;
  1886. /**
  1887. * Adds the given camera to this scene
  1888. * @param newCamera The camera to add
  1889. */
  1890. addCamera(newCamera: Camera): void;
  1891. /**
  1892. * Adds the given skeleton to this scene
  1893. * @param newSkeleton The skeleton to add
  1894. */
  1895. addSkeleton(newSkeleton: Skeleton): void;
  1896. /**
  1897. * Adds the given particle system to this scene
  1898. * @param newParticleSystem The particle system to add
  1899. */
  1900. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1901. /**
  1902. * Adds the given animation to this scene
  1903. * @param newAnimation The animation to add
  1904. */
  1905. addAnimation(newAnimation: Animation): void;
  1906. /**
  1907. * Adds the given animation group to this scene.
  1908. * @param newAnimationGroup The animation group to add
  1909. */
  1910. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1911. /**
  1912. * Adds the given multi-material to this scene
  1913. * @param newMultiMaterial The multi-material to add
  1914. */
  1915. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1916. /**
  1917. * Adds the given material to this scene
  1918. * @param newMaterial The material to add
  1919. */
  1920. addMaterial(newMaterial: Material): void;
  1921. /**
  1922. * Adds the given morph target to this scene
  1923. * @param newMorphTargetManager The morph target to add
  1924. */
  1925. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1926. /**
  1927. * Adds the given geometry to this scene
  1928. * @param newGeometry The geometry to add
  1929. */
  1930. addGeometry(newGeometry: Geometry): void;
  1931. /**
  1932. * Adds the given lens flare system to this scene
  1933. * @param newLensFlareSystem The lens flare system to add
  1934. */
  1935. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1936. /**
  1937. * Adds the given effect layer to this scene
  1938. * @param newEffectLayer defines the effect layer to add
  1939. */
  1940. addEffectLayer(newEffectLayer: EffectLayer): void;
  1941. /**
  1942. * Adds the given action manager to this scene
  1943. * @param newActionManager The action manager to add
  1944. */
  1945. addActionManager(newActionManager: ActionManager): void;
  1946. /**
  1947. * Adds the given texture to this scene.
  1948. * @param newTexture The texture to add
  1949. */
  1950. addTexture(newTexture: BaseTexture): void;
  1951. /**
  1952. * Switch active camera
  1953. * @param newCamera defines the new active camera
  1954. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1955. */
  1956. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1957. /**
  1958. * sets the active camera of the scene using its ID
  1959. * @param id defines the camera's ID
  1960. * @return the new active camera or null if none found.
  1961. */
  1962. setActiveCameraByID(id: string): Nullable<Camera>;
  1963. /**
  1964. * sets the active camera of the scene using its name
  1965. * @param name defines the camera's name
  1966. * @returns the new active camera or null if none found.
  1967. */
  1968. setActiveCameraByName(name: string): Nullable<Camera>;
  1969. /**
  1970. * get an animation group using its name
  1971. * @param name defines the material's name
  1972. * @return the animation group or null if none found.
  1973. */
  1974. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1975. /**
  1976. * get a material using its id
  1977. * @param id defines the material's ID
  1978. * @return the material or null if none found.
  1979. */
  1980. getMaterialByID(id: string): Nullable<Material>;
  1981. /**
  1982. * Gets a material using its name
  1983. * @param name defines the material's name
  1984. * @return the material or null if none found.
  1985. */
  1986. getMaterialByName(name: string): Nullable<Material>;
  1987. /**
  1988. * Gets a lens flare system using its name
  1989. * @param name defines the name to look for
  1990. * @returns the lens flare system or null if not found
  1991. */
  1992. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  1993. /**
  1994. * Gets a lens flare system using its id
  1995. * @param id defines the id to look for
  1996. * @returns the lens flare system or null if not found
  1997. */
  1998. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  1999. /**
  2000. * Gets a camera using its id
  2001. * @param id defines the id to look for
  2002. * @returns the camera or null if not found
  2003. */
  2004. getCameraByID(id: string): Nullable<Camera>;
  2005. /**
  2006. * Gets a camera using its unique id
  2007. * @param uniqueId defines the unique id to look for
  2008. * @returns the camera or null if not found
  2009. */
  2010. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2011. /**
  2012. * Gets a camera using its name
  2013. * @param name defines the camera's name
  2014. * @return the camera or null if none found.
  2015. */
  2016. getCameraByName(name: string): Nullable<Camera>;
  2017. /**
  2018. * Gets a bone using its id
  2019. * @param id defines the bone's id
  2020. * @return the bone or null if not found
  2021. */
  2022. getBoneByID(id: string): Nullable<Bone>;
  2023. /**
  2024. * Gets a bone using its id
  2025. * @param name defines the bone's name
  2026. * @return the bone or null if not found
  2027. */
  2028. getBoneByName(name: string): Nullable<Bone>;
  2029. /**
  2030. * Gets a light node using its name
  2031. * @param name defines the the light's name
  2032. * @return the light or null if none found.
  2033. */
  2034. getLightByName(name: string): Nullable<Light>;
  2035. /**
  2036. * Gets a light node using its id
  2037. * @param id defines the light's id
  2038. * @return the light or null if none found.
  2039. */
  2040. getLightByID(id: string): Nullable<Light>;
  2041. /**
  2042. * Gets a light node using its scene-generated unique ID
  2043. * @param uniqueId defines the light's unique id
  2044. * @return the light or null if none found.
  2045. */
  2046. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2047. /**
  2048. * Gets a particle system by id
  2049. * @param id defines the particle system id
  2050. * @return the corresponding system or null if none found
  2051. */
  2052. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2053. /**
  2054. * Gets a geometry using its ID
  2055. * @param id defines the geometry's id
  2056. * @return the geometry or null if none found.
  2057. */
  2058. getGeometryByID(id: string): Nullable<Geometry>;
  2059. /**
  2060. * Add a new geometry to this scene
  2061. * @param geometry defines the geometry to be added to the scene.
  2062. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2063. * @return a boolean defining if the geometry was added or not
  2064. */
  2065. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2066. /**
  2067. * Removes an existing geometry
  2068. * @param geometry defines the geometry to be removed from the scene
  2069. * @return a boolean defining if the geometry was removed or not
  2070. */
  2071. removeGeometry(geometry: Geometry): boolean;
  2072. /**
  2073. * Gets the list of geometries attached to the scene
  2074. * @returns an array of Geometry
  2075. */
  2076. getGeometries(): Geometry[];
  2077. /**
  2078. * Gets the first added mesh found of a given ID
  2079. * @param id defines the id to search for
  2080. * @return the mesh found or null if not found at all
  2081. */
  2082. getMeshByID(id: string): Nullable<AbstractMesh>;
  2083. /**
  2084. * Gets a list of meshes using their id
  2085. * @param id defines the id to search for
  2086. * @returns a list of meshes
  2087. */
  2088. getMeshesByID(id: string): Array<AbstractMesh>;
  2089. /**
  2090. * Gets the first added transform node found of a given ID
  2091. * @param id defines the id to search for
  2092. * @return the found transform node or null if not found at all.
  2093. */
  2094. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2095. /**
  2096. * Gets a list of transform nodes using their id
  2097. * @param id defines the id to search for
  2098. * @returns a list of transform nodes
  2099. */
  2100. getTransformNodesByID(id: string): Array<TransformNode>;
  2101. /**
  2102. * Gets a mesh with its auto-generated unique id
  2103. * @param uniqueId defines the unique id to search for
  2104. * @return the found mesh or null if not found at all.
  2105. */
  2106. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2107. /**
  2108. * Gets a the last added mesh using a given id
  2109. * @param id defines the id to search for
  2110. * @return the found mesh or null if not found at all.
  2111. */
  2112. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2113. /**
  2114. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2115. * @param id defines the id to search for
  2116. * @return the found node or null if not found at all
  2117. */
  2118. getLastEntryByID(id: string): Nullable<Node>;
  2119. /**
  2120. * Gets a node (Mesh, Camera, Light) using a given id
  2121. * @param id defines the id to search for
  2122. * @return the found node or null if not found at all
  2123. */
  2124. getNodeByID(id: string): Nullable<Node>;
  2125. /**
  2126. * Gets a node (Mesh, Camera, Light) using a given name
  2127. * @param name defines the name to search for
  2128. * @return the found node or null if not found at all.
  2129. */
  2130. getNodeByName(name: string): Nullable<Node>;
  2131. /**
  2132. * Gets a mesh using a given name
  2133. * @param name defines the name to search for
  2134. * @return the found mesh or null if not found at all.
  2135. */
  2136. getMeshByName(name: string): Nullable<AbstractMesh>;
  2137. /**
  2138. * Gets a transform node using a given name
  2139. * @param name defines the name to search for
  2140. * @return the found transform node or null if not found at all.
  2141. */
  2142. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2143. /**
  2144. * Gets a sound using a given name
  2145. * @param name defines the name to search for
  2146. * @return the found sound or null if not found at all.
  2147. */
  2148. getSoundByName(name: string): Nullable<Sound>;
  2149. /**
  2150. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2151. * @param id defines the id to search for
  2152. * @return the found skeleton or null if not found at all.
  2153. */
  2154. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2155. /**
  2156. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2157. * @param id defines the id to search for
  2158. * @return the found skeleton or null if not found at all.
  2159. */
  2160. getSkeletonById(id: string): Nullable<Skeleton>;
  2161. /**
  2162. * Gets a skeleton using a given name
  2163. * @param name defines the name to search for
  2164. * @return the found skeleton or null if not found at all.
  2165. */
  2166. getSkeletonByName(name: string): Nullable<Skeleton>;
  2167. /**
  2168. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2169. * @param id defines the id to search for
  2170. * @return the found morph target manager or null if not found at all.
  2171. */
  2172. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2173. /**
  2174. * Gets a boolean indicating if the given mesh is active
  2175. * @param mesh defines the mesh to look for
  2176. * @returns true if the mesh is in the active list
  2177. */
  2178. isActiveMesh(mesh: AbstractMesh): boolean;
  2179. /**
  2180. * Return a the first highlight layer of the scene with a given name.
  2181. * @param name The name of the highlight layer to look for.
  2182. * @return The highlight layer if found otherwise null.
  2183. */
  2184. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  2185. /**
  2186. * Return a the first highlight layer of the scene with a given name.
  2187. * @param name The name of the highlight layer to look for.
  2188. * @return The highlight layer if found otherwise null.
  2189. */
  2190. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  2191. /**
  2192. * Return a unique id as a string which can serve as an identifier for the scene
  2193. */
  2194. readonly uid: string;
  2195. /**
  2196. * Add an externaly attached data from its key.
  2197. * This method call will fail and return false, if such key already exists.
  2198. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2199. * @param key the unique key that identifies the data
  2200. * @param data the data object to associate to the key for this Engine instance
  2201. * @return true if no such key were already present and the data was added successfully, false otherwise
  2202. */
  2203. addExternalData<T>(key: string, data: T): boolean;
  2204. /**
  2205. * Get an externaly attached data from its key
  2206. * @param key the unique key that identifies the data
  2207. * @return the associated data, if present (can be null), or undefined if not present
  2208. */
  2209. getExternalData<T>(key: string): Nullable<T>;
  2210. /**
  2211. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2212. * @param key the unique key that identifies the data
  2213. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2214. * @return the associated data, can be null if the factory returned null.
  2215. */
  2216. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2217. /**
  2218. * Remove an externaly attached data from the Engine instance
  2219. * @param key the unique key that identifies the data
  2220. * @return true if the data was successfully removed, false if it doesn't exist
  2221. */
  2222. removeExternalData(key: string): boolean;
  2223. private _evaluateSubMesh(subMesh, mesh);
  2224. /**
  2225. * Clear the processed materials smart array preventing retention point in material dispose.
  2226. */
  2227. freeProcessedMaterials(): void;
  2228. /**
  2229. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2230. */
  2231. freeActiveMeshes(): void;
  2232. /**
  2233. * Clear the info related to rendering groups preventing retention points during dispose.
  2234. */
  2235. freeRenderingGroups(): void;
  2236. /** @hidden */
  2237. _isInIntermediateRendering(): boolean;
  2238. private _activeMeshCandidateProvider;
  2239. /**
  2240. * Defines the current active mesh candidate provider
  2241. * @param provider defines the provider to use
  2242. */
  2243. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2244. /**
  2245. * Gets the current active mesh candidate provider
  2246. * @returns the current active mesh candidate provider
  2247. */
  2248. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2249. private _activeMeshesFrozen;
  2250. /**
  2251. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2252. * @returns the current scene
  2253. */
  2254. freezeActiveMeshes(): Scene;
  2255. /**
  2256. * Use this function to restart evaluating active meshes on every frame
  2257. * @returns the current scene
  2258. */
  2259. unfreezeActiveMeshes(): Scene;
  2260. private _evaluateActiveMeshes();
  2261. private _activeMesh(sourceMesh, mesh);
  2262. /**
  2263. * Update the transform matrix to update from the current active camera
  2264. * @param force defines a boolean used to force the update even if cache is up to date
  2265. */
  2266. updateTransformMatrix(force?: boolean): void;
  2267. /**
  2268. * 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)
  2269. * @param alternateCamera defines the camera to use
  2270. */
  2271. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2272. private _renderForCamera(camera, rigParent?);
  2273. private _processSubCameras(camera);
  2274. private _checkIntersections();
  2275. /**
  2276. * Render the scene
  2277. */
  2278. render(): void;
  2279. private _updateAudioParameters();
  2280. /**
  2281. * Gets or sets if audio support is enabled
  2282. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2283. */
  2284. audioEnabled: boolean;
  2285. private _disableAudio();
  2286. private _enableAudio();
  2287. /**
  2288. * Gets or sets if audio will be output to headphones
  2289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2290. */
  2291. headphone: boolean;
  2292. private _switchAudioModeForHeadphones();
  2293. private _switchAudioModeForNormalSpeakers();
  2294. /**
  2295. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2296. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2297. * @returns the created depth renderer
  2298. */
  2299. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2300. /**
  2301. * Disables a depth renderer for a given camera
  2302. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2303. */
  2304. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2305. /**
  2306. * Enables a GeometryBufferRender and associates it with the scene
  2307. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2308. * @returns the GeometryBufferRenderer
  2309. */
  2310. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2311. /**
  2312. * Disables the GeometryBufferRender associated with the scene
  2313. */
  2314. disableGeometryBufferRenderer(): void;
  2315. /**
  2316. * Freeze all materials
  2317. * A frozen material will not be updatable but should be faster to render
  2318. */
  2319. freezeMaterials(): void;
  2320. /**
  2321. * Unfreeze all materials
  2322. * A frozen material will not be updatable but should be faster to render
  2323. */
  2324. unfreezeMaterials(): void;
  2325. /**
  2326. * Releases all held ressources
  2327. */
  2328. dispose(): void;
  2329. /**
  2330. * Gets if the scene is already disposed
  2331. */
  2332. readonly isDisposed: boolean;
  2333. /**
  2334. * Releases sounds & soundtracks
  2335. */
  2336. disposeSounds(): void;
  2337. /**
  2338. * Get the world extend vectors with an optional filter
  2339. *
  2340. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2341. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2342. */
  2343. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2344. min: Vector3;
  2345. max: Vector3;
  2346. };
  2347. /**
  2348. * Creates or updates the octree used to boost selection (picking)
  2349. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2350. * @param maxCapacity defines the maximum capacity per leaf
  2351. * @param maxDepth defines the maximum depth of the octree
  2352. * @returns an octree of AbstractMesh
  2353. */
  2354. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2355. /**
  2356. * Creates a ray that can be used to pick in the scene
  2357. * @param x defines the x coordinate of the origin (on-screen)
  2358. * @param y defines the y coordinate of the origin (on-screen)
  2359. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2360. * @param camera defines the camera to use for the picking
  2361. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2362. * @returns a Ray
  2363. */
  2364. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2365. /**
  2366. * Creates a ray that can be used to pick in the scene
  2367. * @param x defines the x coordinate of the origin (on-screen)
  2368. * @param y defines the y coordinate of the origin (on-screen)
  2369. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2370. * @param result defines the ray where to store the picking ray
  2371. * @param camera defines the camera to use for the picking
  2372. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2373. * @returns the current scene
  2374. */
  2375. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2376. /**
  2377. * Creates a ray that can be used to pick in the scene
  2378. * @param x defines the x coordinate of the origin (on-screen)
  2379. * @param y defines the y coordinate of the origin (on-screen)
  2380. * @param camera defines the camera to use for the picking
  2381. * @returns a Ray
  2382. */
  2383. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  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 result defines the ray where to store the picking ray
  2389. * @param camera defines the camera to use for the picking
  2390. * @returns the current scene
  2391. */
  2392. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2393. private _internalPick(rayFunction, predicate?, fastCheck?);
  2394. private _internalMultiPick(rayFunction, predicate?);
  2395. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  2396. private _tempPickingRay;
  2397. /** Launch a ray to try to pick a mesh in the scene
  2398. * @param x position on screen
  2399. * @param y position on screen
  2400. * @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
  2401. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2402. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2403. * @returns a PickingInfo
  2404. */
  2405. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2406. /** Launch a ray to try to pick a sprite in the scene
  2407. * @param x position on screen
  2408. * @param y position on screen
  2409. * @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
  2410. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2411. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2412. * @returns a PickingInfo
  2413. */
  2414. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2415. private _cachedRayForTransform;
  2416. /** Use the given ray to pick a mesh in the scene
  2417. * @param ray The ray to use to pick meshes
  2418. * @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
  2419. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2420. * @returns a PickingInfo
  2421. */
  2422. pickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2423. /**
  2424. * Launch a ray to try to pick a mesh in the scene
  2425. * @param x X position on screen
  2426. * @param y Y position on screen
  2427. * @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
  2428. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2429. * @returns an array of PickingInfo
  2430. */
  2431. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2432. /**
  2433. * Launch a ray to try to pick a mesh in the scene
  2434. * @param ray Ray to use
  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. * @returns an array of PickingInfo
  2437. */
  2438. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2439. /**
  2440. * Force the value of meshUnderPointer
  2441. * @param mesh defines the mesh to use
  2442. */
  2443. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2444. /**
  2445. * Gets the mesh under the pointer
  2446. * @returns a Mesh or null if no mesh is under the pointer
  2447. */
  2448. getPointerOverMesh(): Nullable<AbstractMesh>;
  2449. /**
  2450. * Force the sprite under the pointer
  2451. * @param sprite defines the sprite to use
  2452. */
  2453. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2454. /**
  2455. * Gets the sprite under the pointer
  2456. * @returns a Sprite or null if no sprite is under the pointer
  2457. */
  2458. getPointerOverSprite(): Nullable<Sprite>;
  2459. /**
  2460. * Gets the current physics engine
  2461. * @returns a PhysicsEngine or null if none attached
  2462. */
  2463. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2464. /**
  2465. * Enables physics to the current scene
  2466. * @param gravity defines the scene's gravity for the physics engine
  2467. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2468. * @return a boolean indicating if the physics engine was initialized
  2469. */
  2470. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2471. /**
  2472. * Disables and disposes the physics engine associated with the scene
  2473. */
  2474. disablePhysicsEngine(): void;
  2475. /**
  2476. * Gets a boolean indicating if there is an active physics engine
  2477. * @returns a boolean indicating if there is an active physics engine
  2478. */
  2479. isPhysicsEnabled(): boolean;
  2480. /**
  2481. * Deletes a physics compound impostor
  2482. * @param compound defines the compound to delete
  2483. */
  2484. deleteCompoundImpostor(compound: any): void;
  2485. /** @hidden */
  2486. _rebuildGeometries(): void;
  2487. /** @hidden */
  2488. _rebuildTextures(): void;
  2489. /**
  2490. * Creates a default light for the scene.
  2491. * @param replace Whether to replace the existing lights in the scene.
  2492. */
  2493. createDefaultLight(replace?: boolean): void;
  2494. /**
  2495. * Creates a default camera for the scene.
  2496. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  2497. * @param replace Whether to replace the existing active camera in the scene.
  2498. * @param attachCameraControls Whether to attach camera controls to the canvas.
  2499. */
  2500. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2501. /**
  2502. * Creates a default camera and a default light
  2503. * @param createArcRotateCamera defines that the camera will be an ArcRotateCamera
  2504. * @param replace defines if the camera and/or light will replace the existing ones
  2505. * @param attachCameraControls defines if attachControl will be called on the new camera
  2506. */
  2507. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2508. /**
  2509. * Creates a new sky box
  2510. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2511. * @param environmentTexture defines the texture to use as environment texture
  2512. * @param pbr defines if PBRMaterial must be used instead of StandardMaterial
  2513. * @param scale defines the overall scale of the skybox
  2514. * @param blur defines if blurring must be applied to the environment texture (works only with pbr === true)
  2515. * @param setGlobalEnvTexture defines a boolean indicating that scene.environmentTexture must match the current skybox texture (true by default)
  2516. * @returns a new mesh holding the sky box
  2517. */
  2518. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2519. /**
  2520. * Creates a new environment
  2521. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2522. * @param options defines the options you can use to configure the environment
  2523. * @returns the new EnvironmentHelper
  2524. */
  2525. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2526. /**
  2527. * Creates a new VREXperienceHelper
  2528. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2529. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2530. * @returns a new VREXperienceHelper
  2531. */
  2532. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2533. private _getByTags(list, tagsQuery, forEach?);
  2534. /**
  2535. * Get a list of meshes by tags
  2536. * @param tagsQuery defines the tags query to use
  2537. * @param forEach defines a predicate used to filter results
  2538. * @returns an array of Mesh
  2539. */
  2540. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2541. /**
  2542. * Get a list of cameras by tags
  2543. * @param tagsQuery defines the tags query to use
  2544. * @param forEach defines a predicate used to filter results
  2545. * @returns an array of Camera
  2546. */
  2547. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2548. /**
  2549. * Get a list of lights by tags
  2550. * @param tagsQuery defines the tags query to use
  2551. * @param forEach defines a predicate used to filter results
  2552. * @returns an array of Light
  2553. */
  2554. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2555. /**
  2556. * Get a list of materials by tags
  2557. * @param tagsQuery defines the tags query to use
  2558. * @param forEach defines a predicate used to filter results
  2559. * @returns an array of Material
  2560. */
  2561. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2562. /**
  2563. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2564. * This allowed control for front to back rendering or reversly depending of the special needs.
  2565. *
  2566. * @param renderingGroupId The rendering group id corresponding to its index
  2567. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2568. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2569. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2570. */
  2571. 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;
  2572. /**
  2573. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2574. *
  2575. * @param renderingGroupId The rendering group id corresponding to its index
  2576. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2577. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2578. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2579. */
  2580. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2581. /**
  2582. * Will flag all materials as dirty to trigger new shader compilation
  2583. * @param flag defines the flag used to specify which material part must be marked as dirty
  2584. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2585. */
  2586. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2587. /** @hidden */
  2588. _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;
  2589. /** @hidden */
  2590. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2591. }
  2592. }
  2593. declare module BABYLON {
  2594. type Nullable<T> = T | null;
  2595. type float = number;
  2596. type double = number;
  2597. type int = number;
  2598. type FloatArray = number[] | Float32Array;
  2599. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2600. /**
  2601. * Alias for types that can be used by a Buffer or VertexBuffer.
  2602. */
  2603. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2604. }
  2605. declare module BABYLON {
  2606. /**
  2607. * The action to be carried out following a trigger
  2608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2609. */
  2610. class Action {
  2611. /** the trigger, with or without parameters, for the action */
  2612. triggerOptions: any;
  2613. /**
  2614. * Trigger for the action
  2615. */
  2616. trigger: number;
  2617. /**
  2618. * Internal only - manager for action
  2619. * @hidden
  2620. */
  2621. _actionManager: ActionManager;
  2622. private _nextActiveAction;
  2623. private _child;
  2624. private _condition?;
  2625. private _triggerParameter;
  2626. /**
  2627. * An event triggered prior to action being executed.
  2628. */
  2629. onBeforeExecuteObservable: Observable<Action>;
  2630. /**
  2631. * Creates a new Action
  2632. * @param triggerOptions the trigger, with or without parameters, for the action
  2633. * @param condition an optional determinant of action
  2634. */
  2635. constructor(
  2636. /** the trigger, with or without parameters, for the action */
  2637. triggerOptions: any, condition?: Condition);
  2638. /**
  2639. * Internal only
  2640. * @hidden
  2641. */
  2642. _prepare(): void;
  2643. /**
  2644. * Gets the trigger parameters
  2645. * @returns the trigger parameters
  2646. */
  2647. getTriggerParameter(): any;
  2648. /**
  2649. * Internal only - executes current action event
  2650. * @hidden
  2651. */
  2652. _executeCurrent(evt?: ActionEvent): void;
  2653. /**
  2654. * Execute placeholder for child classes
  2655. * @param evt optional action event
  2656. */
  2657. execute(evt?: ActionEvent): void;
  2658. /**
  2659. * Skips to next active action
  2660. */
  2661. skipToNextActiveAction(): void;
  2662. /**
  2663. * Adds action to chain of actions, may be a DoNothingAction
  2664. * @param action defines the next action to execute
  2665. * @returns The action passed in
  2666. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2667. */
  2668. then(action: Action): Action;
  2669. /**
  2670. * Internal only
  2671. * @hidden
  2672. */
  2673. _getProperty(propertyPath: string): string;
  2674. /**
  2675. * Internal only
  2676. * @hidden
  2677. */
  2678. _getEffectiveTarget(target: any, propertyPath: string): any;
  2679. /**
  2680. * Serialize placeholder for child classes
  2681. * @param parent of child
  2682. * @returns the serialized object
  2683. */
  2684. serialize(parent: any): any;
  2685. /**
  2686. * Internal only called by serialize
  2687. * @hidden
  2688. */
  2689. protected _serialize(serializedAction: any, parent?: any): any;
  2690. /**
  2691. * Internal only
  2692. * @hidden
  2693. */
  2694. static _SerializeValueAsString: (value: any) => string;
  2695. /**
  2696. * Internal only
  2697. * @hidden
  2698. */
  2699. static _GetTargetProperty: (target: Scene | Node) => {
  2700. name: string;
  2701. targetType: string;
  2702. value: string;
  2703. };
  2704. }
  2705. }
  2706. declare module BABYLON {
  2707. /**
  2708. * ActionEvent is the event being sent when an action is triggered.
  2709. */
  2710. class ActionEvent {
  2711. /** The mesh or sprite that triggered the action */
  2712. source: any;
  2713. /** The X mouse cursor position at the time of the event */
  2714. pointerX: number;
  2715. /** The Y mouse cursor position at the time of the event */
  2716. pointerY: number;
  2717. /** The mesh that is currently pointed at (can be null) */
  2718. meshUnderPointer: Nullable<AbstractMesh>;
  2719. /** the original (browser) event that triggered the ActionEvent */
  2720. sourceEvent: any;
  2721. /** additional data for the event */
  2722. additionalData: any;
  2723. /**
  2724. * Creates a new ActionEvent
  2725. * @param source The mesh or sprite that triggered the action
  2726. * @param pointerX The X mouse cursor position at the time of the event
  2727. * @param pointerY The Y mouse cursor position at the time of the event
  2728. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2729. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2730. * @param additionalData additional data for the event
  2731. */
  2732. constructor(
  2733. /** The mesh or sprite that triggered the action */
  2734. source: any,
  2735. /** The X mouse cursor position at the time of the event */
  2736. pointerX: number,
  2737. /** The Y mouse cursor position at the time of the event */
  2738. pointerY: number,
  2739. /** The mesh that is currently pointed at (can be null) */
  2740. meshUnderPointer: Nullable<AbstractMesh>,
  2741. /** the original (browser) event that triggered the ActionEvent */
  2742. sourceEvent?: any,
  2743. /** additional data for the event */
  2744. additionalData?: any);
  2745. /**
  2746. * Helper function to auto-create an ActionEvent from a source mesh.
  2747. * @param source The source mesh that triggered the event
  2748. * @param evt The original (browser) event
  2749. * @param additionalData additional data for the event
  2750. * @returns the new ActionEvent
  2751. */
  2752. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2753. /**
  2754. * Helper function to auto-create an ActionEvent from a source sprite
  2755. * @param source The source sprite that triggered the event
  2756. * @param scene Scene associated with the sprite
  2757. * @param evt The original (browser) event
  2758. * @param additionalData additional data for the event
  2759. * @returns the new ActionEvent
  2760. */
  2761. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2762. /**
  2763. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2764. * @param scene the scene where the event occurred
  2765. * @param evt The original (browser) event
  2766. * @returns the new ActionEvent
  2767. */
  2768. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2769. /**
  2770. * Helper function to auto-create an ActionEvent from a primitive
  2771. * @param prim defines the target primitive
  2772. * @param pointerPos defines the pointer position
  2773. * @param evt The original (browser) event
  2774. * @param additionalData additional data for the event
  2775. * @returns the new ActionEvent
  2776. */
  2777. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2778. }
  2779. /**
  2780. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2781. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2783. */
  2784. class ActionManager {
  2785. private static _NothingTrigger;
  2786. private static _OnPickTrigger;
  2787. private static _OnLeftPickTrigger;
  2788. private static _OnRightPickTrigger;
  2789. private static _OnCenterPickTrigger;
  2790. private static _OnPickDownTrigger;
  2791. private static _OnDoublePickTrigger;
  2792. private static _OnPickUpTrigger;
  2793. private static _OnLongPressTrigger;
  2794. private static _OnPointerOverTrigger;
  2795. private static _OnPointerOutTrigger;
  2796. private static _OnEveryFrameTrigger;
  2797. private static _OnIntersectionEnterTrigger;
  2798. private static _OnIntersectionExitTrigger;
  2799. private static _OnKeyDownTrigger;
  2800. private static _OnKeyUpTrigger;
  2801. private static _OnPickOutTrigger;
  2802. /**
  2803. * Nothing
  2804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2805. */
  2806. static readonly NothingTrigger: number;
  2807. /**
  2808. * On pick
  2809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2810. */
  2811. static readonly OnPickTrigger: number;
  2812. /**
  2813. * On left pick
  2814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2815. */
  2816. static readonly OnLeftPickTrigger: number;
  2817. /**
  2818. * On right pick
  2819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2820. */
  2821. static readonly OnRightPickTrigger: number;
  2822. /**
  2823. * On center pick
  2824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2825. */
  2826. static readonly OnCenterPickTrigger: number;
  2827. /**
  2828. * On pick down
  2829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2830. */
  2831. static readonly OnPickDownTrigger: number;
  2832. /**
  2833. * On double pick
  2834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2835. */
  2836. static readonly OnDoublePickTrigger: number;
  2837. /**
  2838. * On pick up
  2839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2840. */
  2841. static readonly OnPickUpTrigger: number;
  2842. /**
  2843. * On pick out.
  2844. * This trigger will only be raised if you also declared a OnPickDown
  2845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2846. */
  2847. static readonly OnPickOutTrigger: number;
  2848. /**
  2849. * On long press
  2850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2851. */
  2852. static readonly OnLongPressTrigger: number;
  2853. /**
  2854. * On pointer over
  2855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2856. */
  2857. static readonly OnPointerOverTrigger: number;
  2858. /**
  2859. * On pointer out
  2860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2861. */
  2862. static readonly OnPointerOutTrigger: number;
  2863. /**
  2864. * On every frame
  2865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2866. */
  2867. static readonly OnEveryFrameTrigger: number;
  2868. /**
  2869. * On intersection enter
  2870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2871. */
  2872. static readonly OnIntersectionEnterTrigger: number;
  2873. /**
  2874. * On intersection exit
  2875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2876. */
  2877. static readonly OnIntersectionExitTrigger: number;
  2878. /**
  2879. * On key down
  2880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2881. */
  2882. static readonly OnKeyDownTrigger: number;
  2883. /**
  2884. * On key up
  2885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2886. */
  2887. static readonly OnKeyUpTrigger: number;
  2888. /** Gets the list of active triggers */
  2889. static Triggers: {
  2890. [key: string]: number;
  2891. };
  2892. /** Gets the list of actions */
  2893. actions: Action[];
  2894. /** Gets the cursor to use when hovering items */
  2895. hoverCursor: string;
  2896. private _scene;
  2897. /**
  2898. * Creates a new action manager
  2899. * @param scene defines the hosting scene
  2900. */
  2901. constructor(scene: Scene);
  2902. /**
  2903. * Releases all associated resources
  2904. */
  2905. dispose(): void;
  2906. /**
  2907. * Gets hosting scene
  2908. * @returns the hosting scene
  2909. */
  2910. getScene(): Scene;
  2911. /**
  2912. * Does this action manager handles actions of any of the given triggers
  2913. * @param triggers defines the triggers to be tested
  2914. * @return a boolean indicating whether one (or more) of the triggers is handled
  2915. */
  2916. hasSpecificTriggers(triggers: number[]): boolean;
  2917. /**
  2918. * Does this action manager handles actions of a given trigger
  2919. * @param trigger defines the trigger to be tested
  2920. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2921. * @return whether the trigger is handled
  2922. */
  2923. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2924. /**
  2925. * Does this action manager has pointer triggers
  2926. */
  2927. readonly hasPointerTriggers: boolean;
  2928. /**
  2929. * Does this action manager has pick triggers
  2930. */
  2931. readonly hasPickTriggers: boolean;
  2932. /**
  2933. * Does exist one action manager with at least one trigger
  2934. **/
  2935. static readonly HasTriggers: boolean;
  2936. /**
  2937. * Does exist one action manager with at least one pick trigger
  2938. **/
  2939. static readonly HasPickTriggers: boolean;
  2940. /**
  2941. * Does exist one action manager that handles actions of a given trigger
  2942. * @param trigger defines the trigger to be tested
  2943. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2944. **/
  2945. static HasSpecificTrigger(trigger: number): boolean;
  2946. /**
  2947. * Registers an action to this action manager
  2948. * @param action defines the action to be registered
  2949. * @return the action amended (prepared) after registration
  2950. */
  2951. registerAction(action: Action): Nullable<Action>;
  2952. /**
  2953. * Unregisters an action to this action manager
  2954. * @param action defines the action to be unregistered
  2955. * @return a boolean indicating whether the action has been unregistered
  2956. */
  2957. unregisterAction(action: Action): Boolean;
  2958. /**
  2959. * Process a specific trigger
  2960. * @param trigger defines the trigger to process
  2961. * @param evt defines the event details to be processed
  2962. */
  2963. processTrigger(trigger: number, evt?: ActionEvent): void;
  2964. /** @hidden */
  2965. _getEffectiveTarget(target: any, propertyPath: string): any;
  2966. /** @hidden */
  2967. _getProperty(propertyPath: string): string;
  2968. /**
  2969. * Serialize this manager to a JSON object
  2970. * @param name defines the property name to store this manager
  2971. * @returns a JSON representation of this manager
  2972. */
  2973. serialize(name: string): any;
  2974. /**
  2975. * Creates a new ActionManager from a JSON data
  2976. * @param parsedActions defines the JSON data to read from
  2977. * @param object defines the hosting mesh
  2978. * @param scene defines the hosting scene
  2979. */
  2980. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  2981. /**
  2982. * Get a trigger name by index
  2983. * @param trigger defines the trigger index
  2984. * @returns a trigger name
  2985. */
  2986. static GetTriggerName(trigger: number): string;
  2987. }
  2988. }
  2989. declare module BABYLON {
  2990. /**
  2991. * A Condition applied to an Action
  2992. */
  2993. class Condition {
  2994. /**
  2995. * Internal only - manager for action
  2996. * @hidden
  2997. */
  2998. _actionManager: ActionManager;
  2999. /**
  3000. * Internal only
  3001. * @hidden
  3002. */
  3003. _evaluationId: number;
  3004. /**
  3005. * Internal only
  3006. * @hidden
  3007. */
  3008. _currentResult: boolean;
  3009. /**
  3010. * Creates a new Condition
  3011. * @param actionManager the manager of the action the condition is applied to
  3012. */
  3013. constructor(actionManager: ActionManager);
  3014. /**
  3015. * Check if the current condition is valid
  3016. * @returns a boolean
  3017. */
  3018. isValid(): boolean;
  3019. /**
  3020. * Internal only
  3021. * @hidden
  3022. */
  3023. _getProperty(propertyPath: string): string;
  3024. /**
  3025. * Internal only
  3026. * @hidden
  3027. */
  3028. _getEffectiveTarget(target: any, propertyPath: string): any;
  3029. /**
  3030. * Serialize placeholder for child classes
  3031. * @returns the serialized object
  3032. */
  3033. serialize(): any;
  3034. /**
  3035. * Internal only
  3036. * @hidden
  3037. */
  3038. protected _serialize(serializedCondition: any): any;
  3039. }
  3040. /**
  3041. * Defines specific conditional operators as extensions of Condition
  3042. */
  3043. class ValueCondition extends Condition {
  3044. /** path to specify the property of the target the conditional operator uses */
  3045. propertyPath: string;
  3046. /** the value compared by the conditional operator against the current value of the property */
  3047. value: any;
  3048. /** the conditional operator, default ValueCondition.IsEqual */
  3049. operator: number;
  3050. /**
  3051. * Internal only
  3052. * @hidden
  3053. */
  3054. private static _IsEqual;
  3055. /**
  3056. * Internal only
  3057. * @hidden
  3058. */
  3059. private static _IsDifferent;
  3060. /**
  3061. * Internal only
  3062. * @hidden
  3063. */
  3064. private static _IsGreater;
  3065. /**
  3066. * Internal only
  3067. * @hidden
  3068. */
  3069. private static _IsLesser;
  3070. /**
  3071. * returns the number for IsEqual
  3072. */
  3073. static readonly IsEqual: number;
  3074. /**
  3075. * Returns the number for IsDifferent
  3076. */
  3077. static readonly IsDifferent: number;
  3078. /**
  3079. * Returns the number for IsGreater
  3080. */
  3081. static readonly IsGreater: number;
  3082. /**
  3083. * Returns the number for IsLesser
  3084. */
  3085. static readonly IsLesser: number;
  3086. /**
  3087. * Internal only The action manager for the condition
  3088. * @hidden
  3089. */
  3090. _actionManager: ActionManager;
  3091. /**
  3092. * Internal only
  3093. * @hidden
  3094. */
  3095. private _target;
  3096. /**
  3097. * Internal only
  3098. * @hidden
  3099. */
  3100. private _effectiveTarget;
  3101. /**
  3102. * Internal only
  3103. * @hidden
  3104. */
  3105. private _property;
  3106. /**
  3107. * Creates a new ValueCondition
  3108. * @param actionManager manager for the action the condition applies to
  3109. * @param target for the action
  3110. * @param propertyPath path to specify the property of the target the conditional operator uses
  3111. * @param value the value compared by the conditional operator against the current value of the property
  3112. * @param operator the conditional operator, default ValueCondition.IsEqual
  3113. */
  3114. constructor(actionManager: ActionManager, target: any,
  3115. /** path to specify the property of the target the conditional operator uses */
  3116. propertyPath: string,
  3117. /** the value compared by the conditional operator against the current value of the property */
  3118. value: any,
  3119. /** the conditional operator, default ValueCondition.IsEqual */
  3120. operator?: number);
  3121. /**
  3122. * Compares the given value with the property value for the specified conditional operator
  3123. * @returns the result of the comparison
  3124. */
  3125. isValid(): boolean;
  3126. /**
  3127. * Serialize the ValueCondition into a JSON compatible object
  3128. * @returns serialization object
  3129. */
  3130. serialize(): any;
  3131. /**
  3132. * Gets the name of the conditional operator for the ValueCondition
  3133. * @param operator the conditional operator
  3134. * @returns the name
  3135. */
  3136. static GetOperatorName(operator: number): string;
  3137. }
  3138. /**
  3139. * Defines a predicate condition as an extension of Condition
  3140. */
  3141. class PredicateCondition extends Condition {
  3142. /** defines the predicate function used to validate the condition */
  3143. predicate: () => boolean;
  3144. /**
  3145. * Internal only - manager for action
  3146. * @hidden
  3147. */
  3148. _actionManager: ActionManager;
  3149. /**
  3150. * Creates a new PredicateCondition
  3151. * @param actionManager manager for the action the condition applies to
  3152. * @param predicate defines the predicate function used to validate the condition
  3153. */
  3154. constructor(actionManager: ActionManager,
  3155. /** defines the predicate function used to validate the condition */
  3156. predicate: () => boolean);
  3157. /**
  3158. * @returns the validity of the predicate condition
  3159. */
  3160. isValid(): boolean;
  3161. }
  3162. /**
  3163. * Defines a state condition as an extension of Condition
  3164. */
  3165. class StateCondition extends Condition {
  3166. value: string;
  3167. /**
  3168. * Internal only - manager for action
  3169. * @hidden
  3170. */
  3171. _actionManager: ActionManager;
  3172. /**
  3173. * Internal only
  3174. * @hidden
  3175. */
  3176. private _target;
  3177. /**
  3178. * Creates a new StateCondition
  3179. * @param actionManager manager for the action the condition applies to
  3180. * @param target of the condition
  3181. * @param value to compare with target state
  3182. */
  3183. constructor(actionManager: ActionManager, target: any, value: string);
  3184. /**
  3185. * @returns the validity of the state
  3186. */
  3187. isValid(): boolean;
  3188. /**
  3189. * Serialize the StateCondition into a JSON compatible object
  3190. * @returns serialization object
  3191. */
  3192. serialize(): any;
  3193. }
  3194. }
  3195. declare module BABYLON {
  3196. class SwitchBooleanAction extends Action {
  3197. propertyPath: string;
  3198. private _target;
  3199. private _effectiveTarget;
  3200. private _property;
  3201. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3202. _prepare(): void;
  3203. execute(): void;
  3204. serialize(parent: any): any;
  3205. }
  3206. class SetStateAction extends Action {
  3207. value: string;
  3208. private _target;
  3209. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3210. execute(): void;
  3211. serialize(parent: any): any;
  3212. }
  3213. class SetValueAction extends Action {
  3214. propertyPath: string;
  3215. value: any;
  3216. private _target;
  3217. private _effectiveTarget;
  3218. private _property;
  3219. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3220. _prepare(): void;
  3221. execute(): void;
  3222. serialize(parent: any): any;
  3223. }
  3224. class IncrementValueAction extends Action {
  3225. propertyPath: string;
  3226. value: any;
  3227. private _target;
  3228. private _effectiveTarget;
  3229. private _property;
  3230. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3231. _prepare(): void;
  3232. execute(): void;
  3233. serialize(parent: any): any;
  3234. }
  3235. class PlayAnimationAction extends Action {
  3236. from: number;
  3237. to: number;
  3238. loop: boolean | undefined;
  3239. private _target;
  3240. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3241. _prepare(): void;
  3242. execute(): void;
  3243. serialize(parent: any): any;
  3244. }
  3245. class StopAnimationAction extends Action {
  3246. private _target;
  3247. constructor(triggerOptions: any, target: any, condition?: Condition);
  3248. _prepare(): void;
  3249. execute(): void;
  3250. serialize(parent: any): any;
  3251. }
  3252. class DoNothingAction extends Action {
  3253. constructor(triggerOptions?: any, condition?: Condition);
  3254. execute(): void;
  3255. serialize(parent: any): any;
  3256. }
  3257. class CombineAction extends Action {
  3258. children: Action[];
  3259. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3260. _prepare(): void;
  3261. execute(evt: ActionEvent): void;
  3262. serialize(parent: any): any;
  3263. }
  3264. class ExecuteCodeAction extends Action {
  3265. func: (evt: ActionEvent) => void;
  3266. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3267. execute(evt: ActionEvent): void;
  3268. }
  3269. class SetParentAction extends Action {
  3270. private _parent;
  3271. private _target;
  3272. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3273. _prepare(): void;
  3274. execute(): void;
  3275. serialize(parent: any): any;
  3276. }
  3277. class PlaySoundAction extends Action {
  3278. private _sound;
  3279. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3280. _prepare(): void;
  3281. execute(): void;
  3282. serialize(parent: any): any;
  3283. }
  3284. class StopSoundAction extends Action {
  3285. private _sound;
  3286. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3287. _prepare(): void;
  3288. execute(): void;
  3289. serialize(parent: any): any;
  3290. }
  3291. }
  3292. declare module BABYLON {
  3293. class InterpolateValueAction extends Action {
  3294. propertyPath: string;
  3295. value: any;
  3296. duration: number;
  3297. stopOtherAnimations: boolean | undefined;
  3298. onInterpolationDone: (() => void) | undefined;
  3299. private _target;
  3300. private _effectiveTarget;
  3301. private _property;
  3302. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3303. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3304. _prepare(): void;
  3305. execute(): void;
  3306. serialize(parent: any): any;
  3307. }
  3308. }
  3309. declare module BABYLON {
  3310. class Animatable {
  3311. target: any;
  3312. fromFrame: number;
  3313. toFrame: number;
  3314. loopAnimation: boolean;
  3315. onAnimationEnd: (() => void) | null | undefined;
  3316. private _localDelayOffset;
  3317. private _pausedDelay;
  3318. private _runtimeAnimations;
  3319. private _paused;
  3320. private _scene;
  3321. private _speedRatio;
  3322. private _weight;
  3323. private _syncRoot;
  3324. animationStarted: boolean;
  3325. /**
  3326. * Gets the root Animatable used to synchronize and normalize animations
  3327. */
  3328. readonly syncRoot: Animatable;
  3329. /**
  3330. * Gets the current frame of the first RuntimeAnimation
  3331. * Used to synchronize Animatables
  3332. */
  3333. readonly masterFrame: number;
  3334. /**
  3335. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3336. */
  3337. weight: number;
  3338. /**
  3339. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3340. */
  3341. speedRatio: number;
  3342. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  3343. /**
  3344. * Synchronize and normalize current Animatable with a source Animatable
  3345. * This is useful when using animation weights and when animations are not of the same length
  3346. * @param root defines the root Animatable to synchronize with
  3347. * @returns the current Animatable
  3348. */
  3349. syncWith(root: Animatable): Animatable;
  3350. getAnimations(): RuntimeAnimation[];
  3351. appendAnimations(target: any, animations: Animation[]): void;
  3352. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3353. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3354. reset(): void;
  3355. enableBlending(blendingSpeed: number): void;
  3356. disableBlending(): void;
  3357. goToFrame(frame: number): void;
  3358. pause(): void;
  3359. restart(): void;
  3360. stop(animationName?: string): void;
  3361. _animate(delay: number): boolean;
  3362. }
  3363. }
  3364. declare module BABYLON {
  3365. /**
  3366. * Represents the range of an animation
  3367. */
  3368. class AnimationRange {
  3369. /**The name of the animation range**/
  3370. name: string;
  3371. /**The starting frame of the animation */
  3372. from: number;
  3373. /**The ending frame of the animation*/
  3374. to: number;
  3375. /**
  3376. * Initializes the range of an animation
  3377. * @param name The name of the animation range
  3378. * @param from The starting frame of the animation
  3379. * @param to The ending frame of the animation
  3380. */
  3381. constructor(
  3382. /**The name of the animation range**/
  3383. name: string,
  3384. /**The starting frame of the animation */
  3385. from: number,
  3386. /**The ending frame of the animation*/
  3387. to: number);
  3388. /**
  3389. * Makes a copy of the animation range
  3390. * @returns A copy of the animation range
  3391. */
  3392. clone(): AnimationRange;
  3393. }
  3394. /**
  3395. * Composed of a frame, and an action function
  3396. */
  3397. class AnimationEvent {
  3398. /** The frame for which the event is triggered **/
  3399. frame: number;
  3400. /** The event to perform when triggered **/
  3401. action: () => void;
  3402. /** Specifies if the event should be triggered only once**/
  3403. onlyOnce: boolean | undefined;
  3404. /**
  3405. * Specifies if the animation event is done
  3406. */
  3407. isDone: boolean;
  3408. /**
  3409. * Initializes the animation event
  3410. * @param frame The frame for which the event is triggered
  3411. * @param action The event to perform when triggered
  3412. * @param onlyOnce Specifies if the event should be triggered only once
  3413. */
  3414. constructor(
  3415. /** The frame for which the event is triggered **/
  3416. frame: number,
  3417. /** The event to perform when triggered **/
  3418. action: () => void,
  3419. /** Specifies if the event should be triggered only once**/
  3420. onlyOnce?: boolean | undefined);
  3421. }
  3422. /**
  3423. * A cursor which tracks a point on a path
  3424. */
  3425. class PathCursor {
  3426. private path;
  3427. /**
  3428. * Stores path cursor callbacks for when an onchange event is triggered
  3429. */
  3430. private _onchange;
  3431. /**
  3432. * The value of the path cursor
  3433. */
  3434. value: number;
  3435. /**
  3436. * The animation array of the path cursor
  3437. */
  3438. animations: Animation[];
  3439. /**
  3440. * Initializes the path cursor
  3441. * @param path The path to track
  3442. */
  3443. constructor(path: Path2);
  3444. /**
  3445. * Gets the cursor point on the path
  3446. * @returns A point on the path cursor at the cursor location
  3447. */
  3448. getPoint(): Vector3;
  3449. /**
  3450. * Moves the cursor ahead by the step amount
  3451. * @param step The amount to move the cursor forward
  3452. * @returns This path cursor
  3453. */
  3454. moveAhead(step?: number): PathCursor;
  3455. /**
  3456. * Moves the cursor behind by the step amount
  3457. * @param step The amount to move the cursor back
  3458. * @returns This path cursor
  3459. */
  3460. moveBack(step?: number): PathCursor;
  3461. /**
  3462. * Moves the cursor by the step amount
  3463. * If the step amount is greater than one, an exception is thrown
  3464. * @param step The amount to move the cursor
  3465. * @returns This path cursor
  3466. */
  3467. move(step: number): PathCursor;
  3468. /**
  3469. * Ensures that the value is limited between zero and one
  3470. * @returns This path cursor
  3471. */
  3472. private ensureLimits();
  3473. /**
  3474. * Runs onchange callbacks on change (used by the animation engine)
  3475. * @returns This path cursor
  3476. */
  3477. private raiseOnChange();
  3478. /**
  3479. * Executes a function on change
  3480. * @param f A path cursor onchange callback
  3481. * @returns This path cursor
  3482. */
  3483. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3484. }
  3485. /**
  3486. * Defines an interface which represents an animation key frame
  3487. */
  3488. interface IAnimationKey {
  3489. /**
  3490. * Frame of the key frame
  3491. */
  3492. frame: number;
  3493. /**
  3494. * Value at the specifies key frame
  3495. */
  3496. value: any;
  3497. /**
  3498. * The input tangent for the cubic hermite spline
  3499. */
  3500. inTangent?: any;
  3501. /**
  3502. * The output tangent for the cubic hermite spline
  3503. */
  3504. outTangent?: any;
  3505. /**
  3506. * The animation interpolation type
  3507. */
  3508. interpolation?: AnimationKeyInterpolation;
  3509. }
  3510. /**
  3511. * Enum for the animation key frame interpolation type
  3512. */
  3513. enum AnimationKeyInterpolation {
  3514. /**
  3515. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3516. */
  3517. STEP = 1,
  3518. }
  3519. /**
  3520. * Class used to store any kind of animation
  3521. */
  3522. class Animation {
  3523. /**Name of the animation */
  3524. name: string;
  3525. /**Property to animate */
  3526. targetProperty: string;
  3527. /**The frames per second of the animation */
  3528. framePerSecond: number;
  3529. /**The data type of the animation */
  3530. dataType: number;
  3531. /**The loop mode of the animation */
  3532. loopMode: number | undefined;
  3533. /**Specifies if blending should be enabled */
  3534. enableBlending: boolean | undefined;
  3535. /**
  3536. * Use matrix interpolation instead of using direct key value when animating matrices
  3537. */
  3538. static AllowMatricesInterpolation: boolean;
  3539. /**
  3540. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3541. */
  3542. static AllowMatrixDecomposeForInterpolation: boolean;
  3543. /**
  3544. * Stores the key frames of the animation
  3545. */
  3546. private _keys;
  3547. /**
  3548. * Stores the easing function of the animation
  3549. */
  3550. private _easingFunction;
  3551. /**
  3552. * @hidden Internal use only
  3553. */
  3554. _runtimeAnimations: RuntimeAnimation[];
  3555. /**
  3556. * The set of event that will be linked to this animation
  3557. */
  3558. private _events;
  3559. /**
  3560. * Stores an array of target property paths
  3561. */
  3562. targetPropertyPath: string[];
  3563. /**
  3564. * Stores the blending speed of the animation
  3565. */
  3566. blendingSpeed: number;
  3567. /**
  3568. * Stores the animation ranges for the animation
  3569. */
  3570. private _ranges;
  3571. /**
  3572. * @hidden Internal use
  3573. */
  3574. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3575. /**
  3576. * Sets up an animation
  3577. * @param property The property to animate
  3578. * @param animationType The animation type to apply
  3579. * @param framePerSecond The frames per second of the animation
  3580. * @param easingFunction The easing function used in the animation
  3581. * @returns The created animation
  3582. */
  3583. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3584. /**
  3585. * Create and start an animation on a node
  3586. * @param name defines the name of the global animation that will be run on all nodes
  3587. * @param node defines the root node where the animation will take place
  3588. * @param targetProperty defines property to animate
  3589. * @param framePerSecond defines the number of frame per second yo use
  3590. * @param totalFrame defines the number of frames in total
  3591. * @param from defines the initial value
  3592. * @param to defines the final value
  3593. * @param loopMode defines which loop mode you want to use (off by default)
  3594. * @param easingFunction defines the easing function to use (linear by default)
  3595. * @param onAnimationEnd defines the callback to call when animation end
  3596. * @returns the animatable created for this animation
  3597. */
  3598. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3599. /**
  3600. * Create and start an animation on a node and its descendants
  3601. * @param name defines the name of the global animation that will be run on all nodes
  3602. * @param node defines the root node where the animation will take place
  3603. * @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
  3604. * @param targetProperty defines property to animate
  3605. * @param framePerSecond defines the number of frame per second to use
  3606. * @param totalFrame defines the number of frames in total
  3607. * @param from defines the initial value
  3608. * @param to defines the final value
  3609. * @param loopMode defines which loop mode you want to use (off by default)
  3610. * @param easingFunction defines the easing function to use (linear by default)
  3611. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3612. * @returns the list of animatables created for all nodes
  3613. * @example https://www.babylonjs-playground.com/#MH0VLI
  3614. */
  3615. 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[]>;
  3616. /**
  3617. * Creates a new animation, merges it with the existing animations and starts it
  3618. * @param name Name of the animation
  3619. * @param node Node which contains the scene that begins the animations
  3620. * @param targetProperty Specifies which property to animate
  3621. * @param framePerSecond The frames per second of the animation
  3622. * @param totalFrame The total number of frames
  3623. * @param from The frame at the beginning of the animation
  3624. * @param to The frame at the end of the animation
  3625. * @param loopMode Specifies the loop mode of the animation
  3626. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3627. * @param onAnimationEnd Callback to run once the animation is complete
  3628. * @returns Nullable animation
  3629. */
  3630. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3631. /**
  3632. * Transition property of the Camera to the target Value
  3633. * @param property The property to transition
  3634. * @param targetValue The target Value of the property
  3635. * @param host The object where the property to animate belongs
  3636. * @param scene Scene used to run the animation
  3637. * @param frameRate Framerate (in frame/s) to use
  3638. * @param transition The transition type we want to use
  3639. * @param duration The duration of the animation, in milliseconds
  3640. * @param onAnimationEnd Callback trigger at the end of the animation
  3641. * @returns Nullable animation
  3642. */
  3643. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3644. /**
  3645. * Return the array of runtime animations currently using this animation
  3646. */
  3647. readonly runtimeAnimations: RuntimeAnimation[];
  3648. /**
  3649. * Specifies if any of the runtime animations are currently running
  3650. */
  3651. readonly hasRunningRuntimeAnimations: boolean;
  3652. /**
  3653. * Initializes the animation
  3654. * @param name Name of the animation
  3655. * @param targetProperty Property to animate
  3656. * @param framePerSecond The frames per second of the animation
  3657. * @param dataType The data type of the animation
  3658. * @param loopMode The loop mode of the animation
  3659. * @param enableBlendings Specifies if blending should be enabled
  3660. */
  3661. constructor(
  3662. /**Name of the animation */
  3663. name: string,
  3664. /**Property to animate */
  3665. targetProperty: string,
  3666. /**The frames per second of the animation */
  3667. framePerSecond: number,
  3668. /**The data type of the animation */
  3669. dataType: number,
  3670. /**The loop mode of the animation */
  3671. loopMode?: number | undefined,
  3672. /**Specifies if blending should be enabled */
  3673. enableBlending?: boolean | undefined);
  3674. /**
  3675. * Converts the animation to a string
  3676. * @param fullDetails support for multiple levels of logging within scene loading
  3677. * @returns String form of the animation
  3678. */
  3679. toString(fullDetails?: boolean): string;
  3680. /**
  3681. * Add an event to this animation
  3682. * @param event Event to add
  3683. */
  3684. addEvent(event: AnimationEvent): void;
  3685. /**
  3686. * Remove all events found at the given frame
  3687. * @param frame The frame to remove events from
  3688. */
  3689. removeEvents(frame: number): void;
  3690. /**
  3691. * Retrieves all the events from the animation
  3692. * @returns Events from the animation
  3693. */
  3694. getEvents(): AnimationEvent[];
  3695. /**
  3696. * Creates an animation range
  3697. * @param name Name of the animation range
  3698. * @param from Starting frame of the animation range
  3699. * @param to Ending frame of the animation
  3700. */
  3701. createRange(name: string, from: number, to: number): void;
  3702. /**
  3703. * Deletes an animation range by name
  3704. * @param name Name of the animation range to delete
  3705. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3706. */
  3707. deleteRange(name: string, deleteFrames?: boolean): void;
  3708. /**
  3709. * Gets the animation range by name, or null if not defined
  3710. * @param name Name of the animation range
  3711. * @returns Nullable animation range
  3712. */
  3713. getRange(name: string): Nullable<AnimationRange>;
  3714. /**
  3715. * Gets the key frames from the animation
  3716. * @returns The key frames of the animation
  3717. */
  3718. getKeys(): Array<IAnimationKey>;
  3719. /**
  3720. * Gets the highest frame rate of the animation
  3721. * @returns Highest frame rate of the animation
  3722. */
  3723. getHighestFrame(): number;
  3724. /**
  3725. * Gets the easing function of the animation
  3726. * @returns Easing function of the animation
  3727. */
  3728. getEasingFunction(): IEasingFunction;
  3729. /**
  3730. * Sets the easing function of the animation
  3731. * @param easingFunction A custom mathematical formula for animation
  3732. */
  3733. setEasingFunction(easingFunction: EasingFunction): void;
  3734. /**
  3735. * Interpolates a scalar linearly
  3736. * @param startValue Start value of the animation curve
  3737. * @param endValue End value of the animation curve
  3738. * @param gradient Scalar amount to interpolate
  3739. * @returns Interpolated scalar value
  3740. */
  3741. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  3742. /**
  3743. * Interpolates a scalar cubically
  3744. * @param startValue Start value of the animation curve
  3745. * @param outTangent End tangent of the animation
  3746. * @param endValue End value of the animation curve
  3747. * @param inTangent Start tangent of the animation curve
  3748. * @param gradient Scalar amount to interpolate
  3749. * @returns Interpolated scalar value
  3750. */
  3751. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  3752. /**
  3753. * Interpolates a quaternion using a spherical linear interpolation
  3754. * @param startValue Start value of the animation curve
  3755. * @param endValue End value of the animation curve
  3756. * @param gradient Scalar amount to interpolate
  3757. * @returns Interpolated quaternion value
  3758. */
  3759. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  3760. /**
  3761. * Interpolates a quaternion cubically
  3762. * @param startValue Start value of the animation curve
  3763. * @param outTangent End tangent of the animation curve
  3764. * @param endValue End value of the animation curve
  3765. * @param inTangent Start tangent of the animation curve
  3766. * @param gradient Scalar amount to interpolate
  3767. * @returns Interpolated quaternion value
  3768. */
  3769. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  3770. /**
  3771. * Interpolates a Vector3 linearl
  3772. * @param startValue Start value of the animation curve
  3773. * @param endValue End value of the animation curve
  3774. * @param gradient Scalar amount to interpolate
  3775. * @returns Interpolated scalar value
  3776. */
  3777. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  3778. /**
  3779. * Interpolates a Vector3 cubically
  3780. * @param startValue Start value of the animation curve
  3781. * @param outTangent End tangent of the animation
  3782. * @param endValue End value of the animation curve
  3783. * @param inTangent Start tangent of the animation curve
  3784. * @param gradient Scalar amount to interpolate
  3785. * @returns InterpolatedVector3 value
  3786. */
  3787. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  3788. /**
  3789. * Interpolates a Vector2 linearly
  3790. * @param startValue Start value of the animation curve
  3791. * @param endValue End value of the animation curve
  3792. * @param gradient Scalar amount to interpolate
  3793. * @returns Interpolated Vector2 value
  3794. */
  3795. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  3796. /**
  3797. * Interpolates a Vector2 cubically
  3798. * @param startValue Start value of the animation curve
  3799. * @param outTangent End tangent of the animation
  3800. * @param endValue End value of the animation curve
  3801. * @param inTangent Start tangent of the animation curve
  3802. * @param gradient Scalar amount to interpolate
  3803. * @returns Interpolated Vector2 value
  3804. */
  3805. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  3806. /**
  3807. * Interpolates a size linearly
  3808. * @param startValue Start value of the animation curve
  3809. * @param endValue End value of the animation curve
  3810. * @param gradient Scalar amount to interpolate
  3811. * @returns Interpolated Size value
  3812. */
  3813. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  3814. /**
  3815. * Interpolates a Color3 linearly
  3816. * @param startValue Start value of the animation curve
  3817. * @param endValue End value of the animation curve
  3818. * @param gradient Scalar amount to interpolate
  3819. * @returns Interpolated Color3 value
  3820. */
  3821. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  3822. /**
  3823. * @hidden Internal use only
  3824. */
  3825. _getKeyValue(value: any): any;
  3826. /**
  3827. * @hidden Internal use only
  3828. */
  3829. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  3830. /**
  3831. * Defines the function to use to interpolate matrices
  3832. * @param startValue defines the start matrix
  3833. * @param endValue defines the end matrix
  3834. * @param gradient defines the gradient between both matrices
  3835. * @param result defines an optional target matrix where to store the interpolation
  3836. * @returns the interpolated matrix
  3837. */
  3838. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  3839. /**
  3840. * Makes a copy of the animation
  3841. * @returns Cloned animation
  3842. */
  3843. clone(): Animation;
  3844. /**
  3845. * Sets the key frames of the animation
  3846. * @param values The animation key frames to set
  3847. */
  3848. setKeys(values: Array<IAnimationKey>): void;
  3849. /**
  3850. * Serializes the animation to an object
  3851. * @returns Serialized object
  3852. */
  3853. serialize(): any;
  3854. /**
  3855. * Float animation type
  3856. */
  3857. private static _ANIMATIONTYPE_FLOAT;
  3858. /**
  3859. * Vector3 animation type
  3860. */
  3861. private static _ANIMATIONTYPE_VECTOR3;
  3862. /**
  3863. * Quaternion animation type
  3864. */
  3865. private static _ANIMATIONTYPE_QUATERNION;
  3866. /**
  3867. * Matrix animation type
  3868. */
  3869. private static _ANIMATIONTYPE_MATRIX;
  3870. /**
  3871. * Color3 animation type
  3872. */
  3873. private static _ANIMATIONTYPE_COLOR3;
  3874. /**
  3875. * Vector2 animation type
  3876. */
  3877. private static _ANIMATIONTYPE_VECTOR2;
  3878. /**
  3879. * Size animation type
  3880. */
  3881. private static _ANIMATIONTYPE_SIZE;
  3882. /**
  3883. * Relative Loop Mode
  3884. */
  3885. private static _ANIMATIONLOOPMODE_RELATIVE;
  3886. /**
  3887. * Cycle Loop Mode
  3888. */
  3889. private static _ANIMATIONLOOPMODE_CYCLE;
  3890. /**
  3891. * Constant Loop Mode
  3892. */
  3893. private static _ANIMATIONLOOPMODE_CONSTANT;
  3894. /**
  3895. * Get the float animation type
  3896. */
  3897. static readonly ANIMATIONTYPE_FLOAT: number;
  3898. /**
  3899. * Get the Vector3 animation type
  3900. */
  3901. static readonly ANIMATIONTYPE_VECTOR3: number;
  3902. /**
  3903. * Get the Vectpr2 animation type
  3904. */
  3905. static readonly ANIMATIONTYPE_VECTOR2: number;
  3906. /**
  3907. * Get the Size animation type
  3908. */
  3909. static readonly ANIMATIONTYPE_SIZE: number;
  3910. /**
  3911. * Get the Quaternion animation type
  3912. */
  3913. static readonly ANIMATIONTYPE_QUATERNION: number;
  3914. /**
  3915. * Get the Matrix animation type
  3916. */
  3917. static readonly ANIMATIONTYPE_MATRIX: number;
  3918. /**
  3919. * Get the Color3 animation type
  3920. */
  3921. static readonly ANIMATIONTYPE_COLOR3: number;
  3922. /**
  3923. * Get the Relative Loop Mode
  3924. */
  3925. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  3926. /**
  3927. * Get the Cycle Loop Mode
  3928. */
  3929. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  3930. /**
  3931. * Get the Constant Loop Mode
  3932. */
  3933. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  3934. /**
  3935. * Parses an animation object and creates an animation
  3936. * @param parsedAnimation Parsed animation object
  3937. * @returns Animation object
  3938. */
  3939. static Parse(parsedAnimation: any): Animation;
  3940. /**
  3941. * Appends the serialized animations from the source animations
  3942. * @param source Source containing the animations
  3943. * @param destination Target to store the animations
  3944. */
  3945. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  3946. }
  3947. }
  3948. declare module BABYLON {
  3949. /**
  3950. * This class defines the direct association between an animation and a target
  3951. */
  3952. class TargetedAnimation {
  3953. animation: Animation;
  3954. target: any;
  3955. }
  3956. /**
  3957. * Use this class to create coordinated animations on multiple targets
  3958. */
  3959. class AnimationGroup implements IDisposable {
  3960. name: string;
  3961. private _scene;
  3962. private _targetedAnimations;
  3963. private _animatables;
  3964. private _from;
  3965. private _to;
  3966. private _isStarted;
  3967. private _speedRatio;
  3968. onAnimationEndObservable: Observable<TargetedAnimation>;
  3969. /**
  3970. * Gets the first frame
  3971. */
  3972. readonly from: number;
  3973. /**
  3974. * Gets the last frame
  3975. */
  3976. readonly to: number;
  3977. /**
  3978. * Define if the animations are started
  3979. */
  3980. readonly isStarted: boolean;
  3981. /**
  3982. * Gets or sets the speed ratio to use for all animations
  3983. */
  3984. /**
  3985. * Gets or sets the speed ratio to use for all animations
  3986. */
  3987. speedRatio: number;
  3988. /**
  3989. * Gets the targeted animations for this animation group
  3990. */
  3991. readonly targetedAnimations: Array<TargetedAnimation>;
  3992. /**
  3993. * returning the list of animatables controlled by this animation group.
  3994. */
  3995. readonly animatables: Array<Animatable>;
  3996. constructor(name: string, scene?: Nullable<Scene>);
  3997. /**
  3998. * Add an animation (with its target) in the group
  3999. * @param animation defines the animation we want to add
  4000. * @param target defines the target of the animation
  4001. * @returns the {BABYLON.TargetedAnimation} object
  4002. */
  4003. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4004. /**
  4005. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4006. * It can add constant keys at begin or end
  4007. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4008. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4009. */
  4010. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4011. /**
  4012. * Start all animations on given targets
  4013. * @param loop defines if animations must loop
  4014. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4015. * @param from defines the from key (optional)
  4016. * @param to defines the to key (optional)
  4017. * @returns the current animation group
  4018. */
  4019. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4020. /**
  4021. * Pause all animations
  4022. */
  4023. pause(): AnimationGroup;
  4024. /**
  4025. * Play all animations to initial state
  4026. * This function will start() the animations if they were not started or will restart() them if they were paused
  4027. * @param loop defines if animations must loop
  4028. */
  4029. play(loop?: boolean): AnimationGroup;
  4030. /**
  4031. * Reset all animations to initial state
  4032. */
  4033. reset(): AnimationGroup;
  4034. /**
  4035. * Restart animations from key 0
  4036. */
  4037. restart(): AnimationGroup;
  4038. /**
  4039. * Stop all animations
  4040. */
  4041. stop(): AnimationGroup;
  4042. /**
  4043. * Set animation weight for all animatables
  4044. * @param weight defines the weight to use
  4045. * @return the animationGroup
  4046. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4047. */
  4048. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4049. /**
  4050. * Synchronize and normalize all animatables with a source animatable
  4051. * @param root defines the root animatable to synchronize with
  4052. * @return the animationGroup
  4053. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4054. */
  4055. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4056. /**
  4057. * Goes to a specific frame in this animation group
  4058. * @param frame the frame number to go to
  4059. * @return the animationGroup
  4060. */
  4061. goToFrame(frame: number): AnimationGroup;
  4062. /**
  4063. * Dispose all associated resources
  4064. */
  4065. dispose(): void;
  4066. }
  4067. }
  4068. declare module BABYLON {
  4069. /**
  4070. * Class used to override all child animations of a given target
  4071. */
  4072. class AnimationPropertiesOverride {
  4073. /**
  4074. * Gets or sets a value indicating if animation blending must be used
  4075. */
  4076. enableBlending: boolean;
  4077. /**
  4078. * Gets or sets the blending speed to use when enableBlending is true
  4079. */
  4080. blendingSpeed: number;
  4081. /**
  4082. * Gets or sets the default loop mode to use
  4083. */
  4084. loopMode: number;
  4085. }
  4086. }
  4087. declare module BABYLON {
  4088. interface IEasingFunction {
  4089. ease(gradient: number): number;
  4090. }
  4091. class EasingFunction implements IEasingFunction {
  4092. private static _EASINGMODE_EASEIN;
  4093. private static _EASINGMODE_EASEOUT;
  4094. private static _EASINGMODE_EASEINOUT;
  4095. static readonly EASINGMODE_EASEIN: number;
  4096. static readonly EASINGMODE_EASEOUT: number;
  4097. static readonly EASINGMODE_EASEINOUT: number;
  4098. private _easingMode;
  4099. setEasingMode(easingMode: number): void;
  4100. getEasingMode(): number;
  4101. easeInCore(gradient: number): number;
  4102. ease(gradient: number): number;
  4103. }
  4104. class CircleEase extends EasingFunction implements IEasingFunction {
  4105. easeInCore(gradient: number): number;
  4106. }
  4107. class BackEase extends EasingFunction implements IEasingFunction {
  4108. amplitude: number;
  4109. constructor(amplitude?: number);
  4110. easeInCore(gradient: number): number;
  4111. }
  4112. class BounceEase extends EasingFunction implements IEasingFunction {
  4113. bounces: number;
  4114. bounciness: number;
  4115. constructor(bounces?: number, bounciness?: number);
  4116. easeInCore(gradient: number): number;
  4117. }
  4118. class CubicEase extends EasingFunction implements IEasingFunction {
  4119. easeInCore(gradient: number): number;
  4120. }
  4121. class ElasticEase extends EasingFunction implements IEasingFunction {
  4122. oscillations: number;
  4123. springiness: number;
  4124. constructor(oscillations?: number, springiness?: number);
  4125. easeInCore(gradient: number): number;
  4126. }
  4127. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4128. exponent: number;
  4129. constructor(exponent?: number);
  4130. easeInCore(gradient: number): number;
  4131. }
  4132. class PowerEase extends EasingFunction implements IEasingFunction {
  4133. power: number;
  4134. constructor(power?: number);
  4135. easeInCore(gradient: number): number;
  4136. }
  4137. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4138. easeInCore(gradient: number): number;
  4139. }
  4140. class QuarticEase extends EasingFunction implements IEasingFunction {
  4141. easeInCore(gradient: number): number;
  4142. }
  4143. class QuinticEase extends EasingFunction implements IEasingFunction {
  4144. easeInCore(gradient: number): number;
  4145. }
  4146. class SineEase extends EasingFunction implements IEasingFunction {
  4147. easeInCore(gradient: number): number;
  4148. }
  4149. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4150. x1: number;
  4151. y1: number;
  4152. x2: number;
  4153. y2: number;
  4154. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4155. easeInCore(gradient: number): number;
  4156. }
  4157. }
  4158. declare module BABYLON {
  4159. /**
  4160. * Defines a runtime animation
  4161. */
  4162. class RuntimeAnimation {
  4163. /**
  4164. * The current frame of the runtime animation
  4165. */
  4166. private _currentFrame;
  4167. /**
  4168. * The animation used by the runtime animation
  4169. */
  4170. private _animation;
  4171. /**
  4172. * The target of the runtime animation
  4173. */
  4174. private _target;
  4175. /**
  4176. * The initiating animatable
  4177. */
  4178. private _host;
  4179. /**
  4180. * The original value of the runtime animation
  4181. */
  4182. private _originalValue;
  4183. /**
  4184. * The original blend value of the runtime animation
  4185. */
  4186. private _originalBlendValue;
  4187. /**
  4188. * The offsets cache of the runtime animation
  4189. */
  4190. private _offsetsCache;
  4191. /**
  4192. * The high limits cache of the runtime animation
  4193. */
  4194. private _highLimitsCache;
  4195. /**
  4196. * Specifies if the runtime animation has been stopped
  4197. */
  4198. private _stopped;
  4199. /**
  4200. * The blending factor of the runtime animation
  4201. */
  4202. private _blendingFactor;
  4203. /**
  4204. * The BabylonJS scene
  4205. */
  4206. private _scene;
  4207. /**
  4208. * The current value of the runtime animation
  4209. */
  4210. private _currentValue;
  4211. /** @hidden */
  4212. _workValue: any;
  4213. /**
  4214. * The active target of the runtime animation
  4215. */
  4216. private _activeTarget;
  4217. /**
  4218. * The target path of the runtime animation
  4219. */
  4220. private _targetPath;
  4221. /**
  4222. * The weight of the runtime animation
  4223. */
  4224. private _weight;
  4225. /**
  4226. * The ratio offset of the runtime animation
  4227. */
  4228. private _ratioOffset;
  4229. /**
  4230. * The previous delay of the runtime animation
  4231. */
  4232. private _previousDelay;
  4233. /**
  4234. * The previous ratio of the runtime animation
  4235. */
  4236. private _previousRatio;
  4237. /**
  4238. * Gets the current frame of the runtime animation
  4239. */
  4240. readonly currentFrame: number;
  4241. /**
  4242. * Gets the weight of the runtime animation
  4243. */
  4244. readonly weight: number;
  4245. /**
  4246. * Gets the original value of the runtime animation
  4247. */
  4248. readonly originalValue: any;
  4249. /**
  4250. * Gets the current value of the runtime animation
  4251. */
  4252. readonly currentValue: any;
  4253. /**
  4254. * Gets the target path of the runtime animation
  4255. */
  4256. readonly targetPath: string;
  4257. /**
  4258. * Gets the actual target of the runtime animation
  4259. */
  4260. readonly target: any;
  4261. /**
  4262. * Create a new RuntimeAnimation object
  4263. * @param target defines the target of the animation
  4264. * @param animation defines the source animation object
  4265. * @param scene defines the hosting scene
  4266. * @param host defines the initiating Animatable
  4267. */
  4268. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4269. /**
  4270. * Gets the animation from the runtime animation
  4271. */
  4272. readonly animation: Animation;
  4273. /**
  4274. * Resets the runtime animation to the beginning
  4275. * @param restoreOriginal defines whether to restore the target property to the original value
  4276. */
  4277. reset(restoreOriginal?: boolean): void;
  4278. /**
  4279. * Specifies if the runtime animation is stopped
  4280. * @returns Boolean specifying if the runtime animation is stopped
  4281. */
  4282. isStopped(): boolean;
  4283. /**
  4284. * Disposes of the runtime animation
  4285. */
  4286. dispose(): void;
  4287. /**
  4288. * Interpolates the animation from the current frame
  4289. * @param currentFrame The frame to interpolate the animation to
  4290. * @param repeatCount The number of times that the animation should loop
  4291. * @param loopMode The type of looping mode to use
  4292. * @param offsetValue Animation offset value
  4293. * @param highLimitValue The high limit value
  4294. * @returns The interpolated value
  4295. */
  4296. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  4297. /**
  4298. * Apply the interpolated value to the target
  4299. * @param currentValue defines the value computed by the animation
  4300. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4301. */
  4302. setValue(currentValue: any, weight?: number): void;
  4303. private _setValue(target, currentValue, weight);
  4304. /**
  4305. * Gets the loop pmode of the runtime animation
  4306. * @returns Loop Mode
  4307. */
  4308. private _getCorrectLoopMode();
  4309. /**
  4310. * Move the current animation to a given frame
  4311. * @param frame defines the frame to move to
  4312. */
  4313. goToFrame(frame: number): void;
  4314. /**
  4315. * @hidden Internal use only
  4316. */
  4317. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4318. /**
  4319. * Execute the current animation
  4320. * @param delay defines the delay to add to the current frame
  4321. * @param from defines the lower bound of the animation range
  4322. * @param to defines the upper bound of the animation range
  4323. * @param loop defines if the current animation must loop
  4324. * @param speedRatio defines the current speed ratio
  4325. * @param weight defines the weight of the animation (default is -1 so no weight)
  4326. * @returns a boolean indicating if the animation has ended
  4327. */
  4328. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4329. }
  4330. }
  4331. declare module BABYLON {
  4332. /**
  4333. * Class used to work with sound analyzer using fast fourier transform (FFT)
  4334. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4335. */
  4336. class Analyser {
  4337. /**
  4338. * Gets or sets the smoothing
  4339. * @ignorenaming
  4340. */
  4341. SMOOTHING: number;
  4342. /**
  4343. * Gets or sets the FFT table size
  4344. * @ignorenaming
  4345. */
  4346. FFT_SIZE: number;
  4347. /**
  4348. * Gets or sets the bar graph amplitude
  4349. * @ignorenaming
  4350. */
  4351. BARGRAPHAMPLITUDE: number;
  4352. /**
  4353. * Gets or sets the position of the debug canvas
  4354. * @ignorenaming
  4355. */
  4356. DEBUGCANVASPOS: {
  4357. x: number;
  4358. y: number;
  4359. };
  4360. /**
  4361. * Gets or sets the debug canvas size
  4362. * @ignorenaming
  4363. */
  4364. DEBUGCANVASSIZE: {
  4365. width: number;
  4366. height: number;
  4367. };
  4368. private _byteFreqs;
  4369. private _byteTime;
  4370. private _floatFreqs;
  4371. private _webAudioAnalyser;
  4372. private _debugCanvas;
  4373. private _debugCanvasContext;
  4374. private _scene;
  4375. private _registerFunc;
  4376. private _audioEngine;
  4377. /**
  4378. * Creates a new analyser
  4379. * @param scene defines hosting scene
  4380. */
  4381. constructor(scene: Scene);
  4382. /**
  4383. * Get the number of data values you will have to play with for the visualization
  4384. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  4385. * @returns a number
  4386. */
  4387. getFrequencyBinCount(): number;
  4388. /**
  4389. * Gets the current frequency data as a byte array
  4390. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4391. * @returns a Uint8Array
  4392. */
  4393. getByteFrequencyData(): Uint8Array;
  4394. /**
  4395. * Gets the current waveform as a byte array
  4396. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  4397. * @returns a Uint8Array
  4398. */
  4399. getByteTimeDomainData(): Uint8Array;
  4400. /**
  4401. * Gets the current frequency data as a float array
  4402. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  4403. * @returns a Float32Array
  4404. */
  4405. getFloatFrequencyData(): Float32Array;
  4406. /**
  4407. * Renders the debug canvas
  4408. */
  4409. drawDebugCanvas(): void;
  4410. /**
  4411. * Stops rendering the debug canvas and removes it
  4412. */
  4413. stopDebugCanvas(): void;
  4414. /**
  4415. * Connects two audio nodes
  4416. * @param inputAudioNode defines first node to connect
  4417. * @param outputAudioNode defines second node to connect
  4418. */
  4419. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  4420. /**
  4421. * Releases all associated resources
  4422. */
  4423. dispose(): void;
  4424. }
  4425. }
  4426. declare module BABYLON {
  4427. class AudioEngine {
  4428. private _audioContext;
  4429. private _audioContextInitialized;
  4430. canUseWebAudio: boolean;
  4431. masterGain: GainNode;
  4432. private _connectedAnalyser;
  4433. WarnedWebAudioUnsupported: boolean;
  4434. unlocked: boolean;
  4435. onAudioUnlocked: () => any;
  4436. isMP3supported: boolean;
  4437. isOGGsupported: boolean;
  4438. readonly audioContext: Nullable<AudioContext>;
  4439. constructor();
  4440. private _unlockiOSaudio();
  4441. private _initializeAudioContext();
  4442. dispose(): void;
  4443. getGlobalVolume(): number;
  4444. setGlobalVolume(newVolume: number): void;
  4445. connectToAnalyser(analyser: Analyser): void;
  4446. }
  4447. }
  4448. declare module BABYLON {
  4449. class Sound {
  4450. name: string;
  4451. autoplay: boolean;
  4452. loop: boolean;
  4453. useCustomAttenuation: boolean;
  4454. soundTrackId: number;
  4455. spatialSound: boolean;
  4456. refDistance: number;
  4457. rolloffFactor: number;
  4458. maxDistance: number;
  4459. distanceModel: string;
  4460. private _panningModel;
  4461. onended: () => any;
  4462. private _playbackRate;
  4463. private _streaming;
  4464. private _startTime;
  4465. private _startOffset;
  4466. private _position;
  4467. private _localDirection;
  4468. private _volume;
  4469. private _isReadyToPlay;
  4470. isPlaying: boolean;
  4471. isPaused: boolean;
  4472. private _isDirectional;
  4473. private _readyToPlayCallback;
  4474. private _audioBuffer;
  4475. private _soundSource;
  4476. private _streamingSource;
  4477. private _soundPanner;
  4478. private _soundGain;
  4479. private _inputAudioNode;
  4480. private _ouputAudioNode;
  4481. private _coneInnerAngle;
  4482. private _coneOuterAngle;
  4483. private _coneOuterGain;
  4484. private _scene;
  4485. private _connectedMesh;
  4486. private _customAttenuationFunction;
  4487. private _registerFunc;
  4488. private _isOutputConnected;
  4489. private _htmlAudioElement;
  4490. private _urlType;
  4491. /**
  4492. * Create a sound and attach it to a scene
  4493. * @param name Name of your sound
  4494. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  4495. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4496. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4497. */
  4498. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4499. dispose(): void;
  4500. isReady(): boolean;
  4501. private _soundLoaded(audioData);
  4502. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4503. updateOptions(options: any): void;
  4504. private _createSpatialParameters();
  4505. private _updateSpatialParameters();
  4506. switchPanningModelToHRTF(): void;
  4507. switchPanningModelToEqualPower(): void;
  4508. private _switchPanningModel();
  4509. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4510. /**
  4511. * Transform this sound into a directional source
  4512. * @param coneInnerAngle Size of the inner cone in degree
  4513. * @param coneOuterAngle Size of the outer cone in degree
  4514. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4515. */
  4516. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4517. setPosition(newPosition: Vector3): void;
  4518. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4519. private _updateDirection();
  4520. updateDistanceFromListener(): void;
  4521. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4522. /**
  4523. * Play the sound
  4524. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4525. * @param offset (optional) Start the sound setting it at a specific time
  4526. */
  4527. play(time?: number, offset?: number): void;
  4528. private _onended();
  4529. /**
  4530. * Stop the sound
  4531. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4532. */
  4533. stop(time?: number): void;
  4534. pause(): void;
  4535. setVolume(newVolume: number, time?: number): void;
  4536. setPlaybackRate(newPlaybackRate: number): void;
  4537. getVolume(): number;
  4538. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4539. detachFromMesh(): void;
  4540. private _onRegisterAfterWorldMatrixUpdate(node);
  4541. clone(): Nullable<Sound>;
  4542. getAudioBuffer(): AudioBuffer | null;
  4543. serialize(): any;
  4544. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4545. }
  4546. }
  4547. declare module BABYLON {
  4548. class SoundTrack {
  4549. private _outputAudioNode;
  4550. private _scene;
  4551. id: number;
  4552. soundCollection: Array<Sound>;
  4553. private _isMainTrack;
  4554. private _connectedAnalyser;
  4555. private _options;
  4556. private _isInitialized;
  4557. constructor(scene: Scene, options?: any);
  4558. private _initializeSoundTrackAudioGraph();
  4559. dispose(): void;
  4560. AddSound(sound: Sound): void;
  4561. RemoveSound(sound: Sound): void;
  4562. setVolume(newVolume: number): void;
  4563. switchPanningModelToHRTF(): void;
  4564. switchPanningModelToEqualPower(): void;
  4565. connectToAnalyser(analyser: Analyser): void;
  4566. }
  4567. }
  4568. declare module BABYLON {
  4569. interface Behavior<T extends Node> {
  4570. name: string;
  4571. init(): void;
  4572. attach(node: T): void;
  4573. detach(): void;
  4574. }
  4575. }
  4576. declare module BABYLON {
  4577. /**
  4578. * Class used to store bone information
  4579. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4580. */
  4581. class Bone extends Node {
  4582. /**
  4583. * defines the bone name
  4584. */
  4585. name: string;
  4586. private static _tmpVecs;
  4587. private static _tmpQuat;
  4588. private static _tmpMats;
  4589. /**
  4590. * Gets the list of child bones
  4591. */
  4592. children: Bone[];
  4593. /** Gets the animations associated with this bone */
  4594. animations: Animation[];
  4595. /**
  4596. * Gets or sets bone length
  4597. */
  4598. length: number;
  4599. /**
  4600. * @hidden Internal only
  4601. * Set this value to map this bone to a different index in the transform matrices
  4602. * Set this value to -1 to exclude the bone from the transform matrices
  4603. */
  4604. _index: Nullable<number>;
  4605. private _skeleton;
  4606. private _localMatrix;
  4607. private _restPose;
  4608. private _baseMatrix;
  4609. private _absoluteTransform;
  4610. private _invertedAbsoluteTransform;
  4611. private _parent;
  4612. private _scalingDeterminant;
  4613. private _worldTransform;
  4614. private _localScaling;
  4615. private _localRotation;
  4616. private _localPosition;
  4617. private _needToDecompose;
  4618. private _needToCompose;
  4619. /** @hidden */
  4620. /** @hidden */
  4621. _matrix: Matrix;
  4622. /**
  4623. * Create a new bone
  4624. * @param name defines the bone name
  4625. * @param skeleton defines the parent skeleton
  4626. * @param parentBone defines the parent (can be null if the bone is the root)
  4627. * @param localMatrix defines the local matrix
  4628. * @param restPose defines the rest pose matrix
  4629. * @param baseMatrix defines the base matrix
  4630. * @param index defines index of the bone in the hiearchy
  4631. */
  4632. constructor(
  4633. /**
  4634. * defines the bone name
  4635. */
  4636. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4637. /**
  4638. * Gets the parent skeleton
  4639. * @returns a skeleton
  4640. */
  4641. getSkeleton(): Skeleton;
  4642. /**
  4643. * Gets parent bone
  4644. * @returns a bone or null if the bone is the root of the bone hierarchy
  4645. */
  4646. getParent(): Nullable<Bone>;
  4647. /**
  4648. * Sets the parent bone
  4649. * @param parent defines the parent (can be null if the bone is the root)
  4650. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4651. */
  4652. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4653. /**
  4654. * Gets the local matrix
  4655. * @returns a matrix
  4656. */
  4657. getLocalMatrix(): Matrix;
  4658. /**
  4659. * Gets the base matrix (initial matrix which remains unchanged)
  4660. * @returns a matrix
  4661. */
  4662. getBaseMatrix(): Matrix;
  4663. /**
  4664. * Gets the rest pose matrix
  4665. * @returns a matrix
  4666. */
  4667. getRestPose(): Matrix;
  4668. /**
  4669. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  4670. */
  4671. getWorldMatrix(): Matrix;
  4672. /**
  4673. * Sets the local matrix to rest pose matrix
  4674. */
  4675. returnToRest(): void;
  4676. /**
  4677. * Gets the inverse of the absolute transform matrix.
  4678. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  4679. * @returns a matrix
  4680. */
  4681. getInvertedAbsoluteTransform(): Matrix;
  4682. /**
  4683. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  4684. * @returns a matrix
  4685. */
  4686. getAbsoluteTransform(): Matrix;
  4687. /** Gets or sets current position (in local space) */
  4688. position: Vector3;
  4689. /** Gets or sets current rotation (in local space) */
  4690. rotation: Vector3;
  4691. /** Gets or sets current rotation quaternion (in local space) */
  4692. rotationQuaternion: Quaternion;
  4693. /** Gets or sets current scaling (in local space) */
  4694. scaling: Vector3;
  4695. /**
  4696. * Gets the animation properties override
  4697. */
  4698. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4699. private _decompose();
  4700. private _compose();
  4701. /**
  4702. * Update the base and local matrices
  4703. * @param matrix defines the new base or local matrix
  4704. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4705. * @param updateLocalMatrix defines if the local matrix should be updated
  4706. */
  4707. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  4708. /** @hidden */
  4709. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  4710. /**
  4711. * Flag the bone as dirty (Forcing it to update everything)
  4712. */
  4713. markAsDirty(): void;
  4714. private _markAsDirtyAndCompose();
  4715. private _markAsDirtyAndDecompose();
  4716. /**
  4717. * Copy an animation range from another bone
  4718. * @param source defines the source bone
  4719. * @param rangeName defines the range name to copy
  4720. * @param frameOffset defines the frame offset
  4721. * @param rescaleAsRequired defines if rescaling must be applied if required
  4722. * @param skelDimensionsRatio defines the scaling ratio
  4723. * @returns true if operation was successful
  4724. */
  4725. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  4726. /**
  4727. * Translate the bone in local or world space
  4728. * @param vec The amount to translate the bone
  4729. * @param space The space that the translation is in
  4730. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4731. */
  4732. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4733. /**
  4734. * Set the postion of the bone in local or world space
  4735. * @param position The position to set the bone
  4736. * @param space The space that the position is in
  4737. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4738. */
  4739. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4740. /**
  4741. * Set the absolute position of the bone (world space)
  4742. * @param position The position to set the bone
  4743. * @param mesh The mesh that this bone is attached to
  4744. */
  4745. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  4746. /**
  4747. * Scale the bone on the x, y and z axes (in local space)
  4748. * @param x The amount to scale the bone on the x axis
  4749. * @param y The amount to scale the bone on the y axis
  4750. * @param z The amount to scale the bone on the z axis
  4751. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  4752. */
  4753. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  4754. /**
  4755. * Set the bone scaling in local space
  4756. * @param scale defines the scaling vector
  4757. */
  4758. setScale(scale: Vector3): void;
  4759. /**
  4760. * Gets the current scaling in local space
  4761. * @returns the current scaling vector
  4762. */
  4763. getScale(): Vector3;
  4764. /**
  4765. * Gets the current scaling in local space and stores it in a target vector
  4766. * @param result defines the target vector
  4767. */
  4768. getScaleToRef(result: Vector3): void;
  4769. /**
  4770. * Set the yaw, pitch, and roll of the bone in local or world space
  4771. * @param yaw The rotation of the bone on the y axis
  4772. * @param pitch The rotation of the bone on the x axis
  4773. * @param roll The rotation of the bone on the z axis
  4774. * @param space The space that the axes of rotation are in
  4775. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4776. */
  4777. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  4778. /**
  4779. * Add a rotation to the bone on an axis in local or world space
  4780. * @param axis The axis to rotate the bone on
  4781. * @param amount The amount to rotate the bone
  4782. * @param space The space that the axis is in
  4783. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4784. */
  4785. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  4786. /**
  4787. * Set the rotation of the bone to a particular axis angle in local or world space
  4788. * @param axis The axis to rotate the bone on
  4789. * @param angle The angle that the bone should be rotated to
  4790. * @param space The space that the axis is in
  4791. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4792. */
  4793. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  4794. /**
  4795. * Set the euler rotation of the bone in local of world space
  4796. * @param rotation The euler rotation that the bone should be set to
  4797. * @param space The space that the rotation is in
  4798. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4799. */
  4800. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4801. /**
  4802. * Set the quaternion rotation of the bone in local of world space
  4803. * @param quat The quaternion rotation that the bone should be set to
  4804. * @param space The space that the rotation is in
  4805. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4806. */
  4807. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  4808. /**
  4809. * Set the rotation matrix of the bone in local of world space
  4810. * @param rotMat The rotation matrix that the bone should be set to
  4811. * @param space The space that the rotation is in
  4812. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4813. */
  4814. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  4815. private _rotateWithMatrix(rmat, space?, mesh?);
  4816. private _getNegativeRotationToRef(rotMatInv, mesh?);
  4817. /**
  4818. * Get the position of the bone in local or world space
  4819. * @param space The space that the returned position is in
  4820. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4821. * @returns The position of the bone
  4822. */
  4823. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4824. /**
  4825. * Copy the position of the bone to a vector3 in local or world space
  4826. * @param space The space that the returned position is in
  4827. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4828. * @param result The vector3 to copy the position to
  4829. */
  4830. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  4831. /**
  4832. * Get the absolute position of the bone (world space)
  4833. * @param mesh The mesh that this bone is attached to
  4834. * @returns The absolute position of the bone
  4835. */
  4836. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  4837. /**
  4838. * Copy the absolute position of the bone (world space) to the result param
  4839. * @param mesh The mesh that this bone is attached to
  4840. * @param result The vector3 to copy the absolute position to
  4841. */
  4842. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  4843. /**
  4844. * Compute the absolute transforms of this bone and its children
  4845. */
  4846. computeAbsoluteTransforms(): void;
  4847. /**
  4848. * Get the world direction from an axis that is in the local space of the bone
  4849. * @param localAxis The local direction that is used to compute the world direction
  4850. * @param mesh The mesh that this bone is attached to
  4851. * @returns The world direction
  4852. */
  4853. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4854. /**
  4855. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  4856. * @param localAxis The local direction that is used to compute the world direction
  4857. * @param mesh The mesh that this bone is attached to
  4858. * @param result The vector3 that the world direction will be copied to
  4859. */
  4860. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4861. /**
  4862. * Get the euler rotation of the bone in local or world space
  4863. * @param space The space that the rotation should be in
  4864. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4865. * @returns The euler rotation
  4866. */
  4867. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4868. /**
  4869. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  4870. * @param space The space that the rotation should be in
  4871. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4872. * @param result The vector3 that the rotation should be copied to
  4873. */
  4874. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4875. /**
  4876. * Get the quaternion rotation of the bone in either local or world space
  4877. * @param space The space that the rotation should be in
  4878. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4879. * @returns The quaternion rotation
  4880. */
  4881. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  4882. /**
  4883. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  4884. * @param space The space that the rotation should be in
  4885. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4886. * @param result The quaternion that the rotation should be copied to
  4887. */
  4888. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  4889. /**
  4890. * Get the rotation matrix of the bone in local or world space
  4891. * @param space The space that the rotation should be in
  4892. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4893. * @returns The rotation matrix
  4894. */
  4895. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  4896. /**
  4897. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  4898. * @param space The space that the rotation should be in
  4899. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4900. * @param result The quaternion that the rotation should be copied to
  4901. */
  4902. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  4903. /**
  4904. * Get the world position of a point that is in the local space of the bone
  4905. * @param position The local position
  4906. * @param mesh The mesh that this bone is attached to
  4907. * @returns The world position
  4908. */
  4909. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4910. /**
  4911. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  4912. * @param position The local position
  4913. * @param mesh The mesh that this bone is attached to
  4914. * @param result The vector3 that the world position should be copied to
  4915. */
  4916. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4917. /**
  4918. * Get the local position of a point that is in world space
  4919. * @param position The world position
  4920. * @param mesh The mesh that this bone is attached to
  4921. * @returns The local position
  4922. */
  4923. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4924. /**
  4925. * Get the local position of a point that is in world space and copy it to the result param
  4926. * @param position The world position
  4927. * @param mesh The mesh that this bone is attached to
  4928. * @param result The vector3 that the local position should be copied to
  4929. */
  4930. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4931. }
  4932. }
  4933. declare module BABYLON {
  4934. /**
  4935. * Class used to apply inverse kinematics to bones
  4936. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  4937. */
  4938. class BoneIKController {
  4939. private static _tmpVecs;
  4940. private static _tmpQuat;
  4941. private static _tmpMats;
  4942. /**
  4943. * Gets or sets the target mesh
  4944. */
  4945. targetMesh: AbstractMesh;
  4946. /** Gets or sets the mesh used as pole */
  4947. poleTargetMesh: AbstractMesh;
  4948. /**
  4949. * Gets or sets the bone used as pole
  4950. */
  4951. poleTargetBone: Nullable<Bone>;
  4952. /**
  4953. * Gets or sets the target position
  4954. */
  4955. targetPosition: Vector3;
  4956. /**
  4957. * Gets or sets the pole target position
  4958. */
  4959. poleTargetPosition: Vector3;
  4960. /**
  4961. * Gets or sets the pole target local offset
  4962. */
  4963. poleTargetLocalOffset: Vector3;
  4964. /**
  4965. * Gets or sets the pole angle
  4966. */
  4967. poleAngle: number;
  4968. /**
  4969. * Gets or sets the mesh associated with the controller
  4970. */
  4971. mesh: AbstractMesh;
  4972. /**
  4973. * 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)
  4974. */
  4975. slerpAmount: number;
  4976. private _bone1Quat;
  4977. private _bone1Mat;
  4978. private _bone2Ang;
  4979. private _bone1;
  4980. private _bone2;
  4981. private _bone1Length;
  4982. private _bone2Length;
  4983. private _maxAngle;
  4984. private _maxReach;
  4985. private _rightHandedSystem;
  4986. private _bendAxis;
  4987. private _slerping;
  4988. private _adjustRoll;
  4989. /**
  4990. * Gets or sets maximum allowed angle
  4991. */
  4992. maxAngle: number;
  4993. /**
  4994. * Creates a new BoneIKController
  4995. * @param mesh defines the mesh to control
  4996. * @param bone defines the bone to control
  4997. * @param options defines options to set up the controller
  4998. */
  4999. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5000. targetMesh?: AbstractMesh;
  5001. poleTargetMesh?: AbstractMesh;
  5002. poleTargetBone?: Bone;
  5003. poleTargetLocalOffset?: Vector3;
  5004. poleAngle?: number;
  5005. bendAxis?: Vector3;
  5006. maxAngle?: number;
  5007. slerpAmount?: number;
  5008. });
  5009. private _setMaxAngle(ang);
  5010. /**
  5011. * Force the controller to update the bones
  5012. */
  5013. update(): void;
  5014. }
  5015. }
  5016. declare module BABYLON {
  5017. /**
  5018. * Class used to make a bone look toward a point in space
  5019. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5020. */
  5021. class BoneLookController {
  5022. private static _tmpVecs;
  5023. private static _tmpQuat;
  5024. private static _tmpMats;
  5025. /**
  5026. * The target Vector3 that the bone will look at
  5027. */
  5028. target: Vector3;
  5029. /**
  5030. * The mesh that the bone is attached to
  5031. */
  5032. mesh: AbstractMesh;
  5033. /**
  5034. * The bone that will be looking to the target
  5035. */
  5036. bone: Bone;
  5037. /**
  5038. * The up axis of the coordinate system that is used when the bone is rotated
  5039. */
  5040. upAxis: Vector3;
  5041. /**
  5042. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5043. */
  5044. upAxisSpace: Space;
  5045. /**
  5046. * Used to make an adjustment to the yaw of the bone
  5047. */
  5048. adjustYaw: number;
  5049. /**
  5050. * Used to make an adjustment to the pitch of the bone
  5051. */
  5052. adjustPitch: number;
  5053. /**
  5054. * Used to make an adjustment to the roll of the bone
  5055. */
  5056. adjustRoll: number;
  5057. /**
  5058. * 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)
  5059. */
  5060. slerpAmount: number;
  5061. private _minYaw;
  5062. private _maxYaw;
  5063. private _minPitch;
  5064. private _maxPitch;
  5065. private _minYawSin;
  5066. private _minYawCos;
  5067. private _maxYawSin;
  5068. private _maxYawCos;
  5069. private _midYawConstraint;
  5070. private _minPitchTan;
  5071. private _maxPitchTan;
  5072. private _boneQuat;
  5073. private _slerping;
  5074. private _transformYawPitch;
  5075. private _transformYawPitchInv;
  5076. private _firstFrameSkipped;
  5077. private _yawRange;
  5078. private _fowardAxis;
  5079. /**
  5080. * Gets or sets the minimum yaw angle that the bone can look to
  5081. */
  5082. minYaw: number;
  5083. /**
  5084. * Gets or sets the maximum yaw angle that the bone can look to
  5085. */
  5086. maxYaw: number;
  5087. /**
  5088. * Gets or sets the minimum pitch angle that the bone can look to
  5089. */
  5090. minPitch: number;
  5091. /**
  5092. * Gets or sets the maximum pitch angle that the bone can look to
  5093. */
  5094. maxPitch: number;
  5095. /**
  5096. * Create a BoneLookController
  5097. * @param mesh the mesh that the bone belongs to
  5098. * @param bone the bone that will be looking to the target
  5099. * @param target the target Vector3 to look at
  5100. * @param settings optional settings:
  5101. * * maxYaw: the maximum angle the bone will yaw to
  5102. * * minYaw: the minimum angle the bone will yaw to
  5103. * * maxPitch: the maximum angle the bone will pitch to
  5104. * * minPitch: the minimum angle the bone will yaw to
  5105. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5106. * * upAxis: the up axis of the coordinate system
  5107. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5108. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5109. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5110. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5111. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5112. * * adjustRoll: used to make an adjustment to the roll of the bone
  5113. **/
  5114. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5115. maxYaw?: number;
  5116. minYaw?: number;
  5117. maxPitch?: number;
  5118. minPitch?: number;
  5119. slerpAmount?: number;
  5120. upAxis?: Vector3;
  5121. upAxisSpace?: Space;
  5122. yawAxis?: Vector3;
  5123. pitchAxis?: Vector3;
  5124. adjustYaw?: number;
  5125. adjustPitch?: number;
  5126. adjustRoll?: number;
  5127. });
  5128. /**
  5129. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5130. */
  5131. update(): void;
  5132. private _getAngleDiff(ang1, ang2);
  5133. private _getAngleBetween(ang1, ang2);
  5134. private _isAngleBetween(ang, ang1, ang2);
  5135. }
  5136. }
  5137. declare module BABYLON {
  5138. /**
  5139. * Class used to handle skinning animations
  5140. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5141. */
  5142. class Skeleton implements IAnimatable {
  5143. /** defines the skeleton name */
  5144. name: string;
  5145. /** defines the skeleton Id */
  5146. id: string;
  5147. /**
  5148. * Gets the list of child bones
  5149. */
  5150. bones: Bone[];
  5151. /**
  5152. * Gets an estimate of the dimension of the skeleton at rest
  5153. */
  5154. dimensionsAtRest: Vector3;
  5155. /**
  5156. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5157. */
  5158. needInitialSkinMatrix: boolean;
  5159. /**
  5160. * Gets the list of animations attached to this skeleton
  5161. */
  5162. animations: Array<Animation>;
  5163. private _scene;
  5164. private _isDirty;
  5165. private _transformMatrices;
  5166. private _meshesWithPoseMatrix;
  5167. private _animatables;
  5168. private _identity;
  5169. private _synchronizedWithMesh;
  5170. private _ranges;
  5171. private _lastAbsoluteTransformsUpdateId;
  5172. /**
  5173. * Specifies if the skeleton should be serialized
  5174. */
  5175. doNotSerialize: boolean;
  5176. private _animationPropertiesOverride;
  5177. /**
  5178. * Gets or sets the animation properties override
  5179. */
  5180. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5181. /**
  5182. * An observable triggered before computing the skeleton's matrices
  5183. */
  5184. onBeforeComputeObservable: Observable<Skeleton>;
  5185. /**
  5186. * Creates a new skeleton
  5187. * @param name defines the skeleton name
  5188. * @param id defines the skeleton Id
  5189. * @param scene defines the hosting scene
  5190. */
  5191. constructor(
  5192. /** defines the skeleton name */
  5193. name: string,
  5194. /** defines the skeleton Id */
  5195. id: string, scene: Scene);
  5196. /**
  5197. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5198. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5199. * @returns a Float32Array containing matrices data
  5200. */
  5201. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5202. /**
  5203. * Gets the current hosting scene
  5204. * @returns a scene object
  5205. */
  5206. getScene(): Scene;
  5207. /**
  5208. * Gets a string representing the current skeleton data
  5209. * @param fullDetails defines a boolean indicating if we want a verbose version
  5210. * @returns a string representing the current skeleton data
  5211. */
  5212. toString(fullDetails?: boolean): string;
  5213. /**
  5214. * Get bone's index searching by name
  5215. * @param name defines bone's name to search for
  5216. * @return the indice of the bone. Returns -1 if not found
  5217. */
  5218. getBoneIndexByName(name: string): number;
  5219. /**
  5220. * Creater a new animation range
  5221. * @param name defines the name of the range
  5222. * @param from defines the start key
  5223. * @param to defines the end key
  5224. */
  5225. createAnimationRange(name: string, from: number, to: number): void;
  5226. /**
  5227. * Delete a specific animation range
  5228. * @param name defines the name of the range
  5229. * @param deleteFrames defines if frames must be removed as well
  5230. */
  5231. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5232. /**
  5233. * Gets a specific animation range
  5234. * @param name defines the name of the range to look for
  5235. * @returns the requested animation range or null if not found
  5236. */
  5237. getAnimationRange(name: string): Nullable<AnimationRange>;
  5238. /**
  5239. * Gets the list of all animation ranges defined on this skeleton
  5240. * @returns an array
  5241. */
  5242. getAnimationRanges(): Nullable<AnimationRange>[];
  5243. /**
  5244. * Copy animation range from a source skeleton.
  5245. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5246. * @param source defines the source skeleton
  5247. * @param name defines the name of the range to copy
  5248. * @param rescaleAsRequired defines if rescaling must be applied if required
  5249. * @returns true if operation was successful
  5250. */
  5251. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5252. /**
  5253. * Forces the skeleton to go to rest pose
  5254. */
  5255. returnToRest(): void;
  5256. private _getHighestAnimationFrame();
  5257. /**
  5258. * Begin a specific animation range
  5259. * @param name defines the name of the range to start
  5260. * @param loop defines if looping must be turned on (false by default)
  5261. * @param speedRatio defines the speed ratio to apply (1 by default)
  5262. * @param onAnimationEnd defines a callback which will be called when animation will end
  5263. * @returns a new animatable
  5264. */
  5265. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5266. /** @hidden */
  5267. _markAsDirty(): void;
  5268. /** @hidden */
  5269. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5270. /** @hidden */
  5271. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5272. /** @hidden */
  5273. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5274. /**
  5275. * Build all resources required to render a skeleton
  5276. */
  5277. prepare(): void;
  5278. /**
  5279. * Gets the list of animatables currently running for this skeleton
  5280. * @returns an array of animatables
  5281. */
  5282. getAnimatables(): IAnimatable[];
  5283. /**
  5284. * Clone the current skeleton
  5285. * @param name defines the name of the new skeleton
  5286. * @param id defines the id of the enw skeleton
  5287. * @returns the new skeleton
  5288. */
  5289. clone(name: string, id: string): Skeleton;
  5290. /**
  5291. * Enable animation blending for this skeleton
  5292. * @param blendingSpeed defines the blending speed to apply
  5293. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5294. */
  5295. enableBlending(blendingSpeed?: number): void;
  5296. /**
  5297. * Releases all resources associated with the current skeleton
  5298. */
  5299. dispose(): void;
  5300. /**
  5301. * Serialize the skeleton in a JSON object
  5302. * @returns a JSON object
  5303. */
  5304. serialize(): any;
  5305. /**
  5306. * Creates a new skeleton from serialized data
  5307. * @param parsedSkeleton defines the serialized data
  5308. * @param scene defines the hosting scene
  5309. * @returns a new skeleton
  5310. */
  5311. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5312. /**
  5313. * Compute all node absolute transforms
  5314. * @param forceUpdate defines if computation must be done even if cache is up to date
  5315. */
  5316. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5317. /**
  5318. * Gets the root pose matrix
  5319. * @returns a matrix
  5320. */
  5321. getPoseMatrix(): Nullable<Matrix>;
  5322. /**
  5323. * Sorts bones per internal index
  5324. */
  5325. sortBones(): void;
  5326. private _sortBones(index, bones, visited);
  5327. }
  5328. }
  5329. declare module BABYLON {
  5330. class Collider {
  5331. /** Define if a collision was found */
  5332. collisionFound: boolean;
  5333. /**
  5334. * Define last intersection point in local space
  5335. */
  5336. intersectionPoint: Vector3;
  5337. /**
  5338. * Define last collided mesh
  5339. */
  5340. collidedMesh: Nullable<AbstractMesh>;
  5341. private _collisionPoint;
  5342. private _planeIntersectionPoint;
  5343. private _tempVector;
  5344. private _tempVector2;
  5345. private _tempVector3;
  5346. private _tempVector4;
  5347. private _edge;
  5348. private _baseToVertex;
  5349. private _destinationPoint;
  5350. private _slidePlaneNormal;
  5351. private _displacementVector;
  5352. _radius: Vector3;
  5353. _retry: number;
  5354. private _velocity;
  5355. private _basePoint;
  5356. private _epsilon;
  5357. _velocityWorldLength: number;
  5358. _basePointWorld: Vector3;
  5359. private _velocityWorld;
  5360. private _normalizedVelocity;
  5361. _initialVelocity: Vector3;
  5362. _initialPosition: Vector3;
  5363. private _nearestDistance;
  5364. private _collisionMask;
  5365. collisionMask: number;
  5366. /**
  5367. * Gets the plane normal used to compute the sliding response (in local space)
  5368. */
  5369. readonly slidePlaneNormal: Vector3;
  5370. _initialize(source: Vector3, dir: Vector3, e: number): void;
  5371. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  5372. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  5373. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  5374. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  5375. _getResponse(pos: Vector3, vel: Vector3): void;
  5376. }
  5377. }
  5378. declare module BABYLON {
  5379. var CollisionWorker: string;
  5380. interface ICollisionCoordinator {
  5381. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5382. init(scene: Scene): void;
  5383. destroy(): void;
  5384. onMeshAdded(mesh: AbstractMesh): void;
  5385. onMeshUpdated(mesh: AbstractMesh): void;
  5386. onMeshRemoved(mesh: AbstractMesh): void;
  5387. onGeometryAdded(geometry: Geometry): void;
  5388. onGeometryUpdated(geometry: Geometry): void;
  5389. onGeometryDeleted(geometry: Geometry): void;
  5390. }
  5391. interface SerializedMesh {
  5392. id: string;
  5393. name: string;
  5394. uniqueId: number;
  5395. geometryId: Nullable<string>;
  5396. sphereCenter: Array<number>;
  5397. sphereRadius: number;
  5398. boxMinimum: Array<number>;
  5399. boxMaximum: Array<number>;
  5400. worldMatrixFromCache: any;
  5401. subMeshes: Array<SerializedSubMesh>;
  5402. checkCollisions: boolean;
  5403. }
  5404. interface SerializedSubMesh {
  5405. position: number;
  5406. verticesStart: number;
  5407. verticesCount: number;
  5408. indexStart: number;
  5409. indexCount: number;
  5410. hasMaterial: boolean;
  5411. sphereCenter: Array<number>;
  5412. sphereRadius: number;
  5413. boxMinimum: Array<number>;
  5414. boxMaximum: Array<number>;
  5415. }
  5416. /**
  5417. * Interface describing the value associated with a geometry
  5418. */
  5419. interface SerializedGeometry {
  5420. /**
  5421. * Defines the unique ID of the geometry
  5422. */
  5423. id: string;
  5424. /**
  5425. * Defines the array containing the positions
  5426. */
  5427. positions: Float32Array;
  5428. /**
  5429. * Defines the array containing the indices
  5430. */
  5431. indices: Uint32Array;
  5432. /**
  5433. * Defines the array containing the normals
  5434. */
  5435. normals: Float32Array;
  5436. }
  5437. interface BabylonMessage {
  5438. taskType: WorkerTaskType;
  5439. payload: InitPayload | CollidePayload | UpdatePayload;
  5440. }
  5441. interface SerializedColliderToWorker {
  5442. position: Array<number>;
  5443. velocity: Array<number>;
  5444. radius: Array<number>;
  5445. }
  5446. /** Defines supported task for worker process */
  5447. enum WorkerTaskType {
  5448. /** Initialization */
  5449. INIT = 0,
  5450. /** Update of geometry */
  5451. UPDATE = 1,
  5452. /** Evaluate collision */
  5453. COLLIDE = 2,
  5454. }
  5455. interface WorkerReply {
  5456. error: WorkerReplyType;
  5457. taskType: WorkerTaskType;
  5458. payload?: any;
  5459. }
  5460. interface CollisionReplyPayload {
  5461. newPosition: Array<number>;
  5462. collisionId: number;
  5463. collidedMeshUniqueId: number;
  5464. }
  5465. interface InitPayload {
  5466. }
  5467. interface CollidePayload {
  5468. collisionId: number;
  5469. collider: SerializedColliderToWorker;
  5470. maximumRetry: number;
  5471. excludedMeshUniqueId: Nullable<number>;
  5472. }
  5473. interface UpdatePayload {
  5474. updatedMeshes: {
  5475. [n: number]: SerializedMesh;
  5476. };
  5477. updatedGeometries: {
  5478. [s: string]: SerializedGeometry;
  5479. };
  5480. removedMeshes: Array<number>;
  5481. removedGeometries: Array<string>;
  5482. }
  5483. /** Defines kind of replies returned by worker */
  5484. enum WorkerReplyType {
  5485. /** Success */
  5486. SUCCESS = 0,
  5487. /** Unkown error */
  5488. UNKNOWN_ERROR = 1,
  5489. }
  5490. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  5491. private _scene;
  5492. private _scaledPosition;
  5493. private _scaledVelocity;
  5494. private _collisionsCallbackArray;
  5495. private _init;
  5496. private _runningUpdated;
  5497. private _worker;
  5498. private _addUpdateMeshesList;
  5499. private _addUpdateGeometriesList;
  5500. private _toRemoveMeshesArray;
  5501. private _toRemoveGeometryArray;
  5502. constructor();
  5503. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  5504. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  5505. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5506. init(scene: Scene): void;
  5507. destroy(): void;
  5508. onMeshAdded(mesh: AbstractMesh): void;
  5509. onMeshUpdated: (transformNode: TransformNode) => void;
  5510. onMeshRemoved(mesh: AbstractMesh): void;
  5511. onGeometryAdded(geometry: Geometry): void;
  5512. onGeometryUpdated: (geometry: Geometry) => void;
  5513. onGeometryDeleted(geometry: Geometry): void;
  5514. private _afterRender;
  5515. private _onMessageFromWorker;
  5516. }
  5517. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  5518. private _scene;
  5519. private _scaledPosition;
  5520. private _scaledVelocity;
  5521. private _finalPosition;
  5522. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5523. init(scene: Scene): void;
  5524. destroy(): void;
  5525. onMeshAdded(mesh: AbstractMesh): void;
  5526. onMeshUpdated(mesh: AbstractMesh): void;
  5527. onMeshRemoved(mesh: AbstractMesh): void;
  5528. onGeometryAdded(geometry: Geometry): void;
  5529. onGeometryUpdated(geometry: Geometry): void;
  5530. onGeometryDeleted(geometry: Geometry): void;
  5531. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  5532. }
  5533. }
  5534. declare function importScripts(...urls: string[]): void;
  5535. declare const safePostMessage: any;
  5536. declare module BABYLON {
  5537. var WorkerIncluded: boolean;
  5538. class CollisionCache {
  5539. private _meshes;
  5540. private _geometries;
  5541. getMeshes(): {
  5542. [n: number]: SerializedMesh;
  5543. };
  5544. getGeometries(): {
  5545. [s: number]: SerializedGeometry;
  5546. };
  5547. getMesh(id: any): SerializedMesh;
  5548. addMesh(mesh: SerializedMesh): void;
  5549. removeMesh(uniqueId: number): void;
  5550. getGeometry(id: string): SerializedGeometry;
  5551. addGeometry(geometry: SerializedGeometry): void;
  5552. removeGeometry(id: string): void;
  5553. }
  5554. class CollideWorker {
  5555. collider: Collider;
  5556. private _collisionCache;
  5557. private finalPosition;
  5558. private collisionsScalingMatrix;
  5559. private collisionTranformationMatrix;
  5560. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5561. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  5562. private checkCollision(mesh);
  5563. private processCollisionsForSubMeshes(transformMatrix, mesh);
  5564. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  5565. private checkSubmeshCollision(subMesh);
  5566. }
  5567. interface ICollisionDetector {
  5568. onInit(payload: InitPayload): void;
  5569. onUpdate(payload: UpdatePayload): void;
  5570. onCollision(payload: CollidePayload): void;
  5571. }
  5572. class CollisionDetectorTransferable implements ICollisionDetector {
  5573. private _collisionCache;
  5574. onInit(payload: InitPayload): void;
  5575. onUpdate(payload: UpdatePayload): void;
  5576. onCollision(payload: CollidePayload): void;
  5577. }
  5578. }
  5579. declare module BABYLON {
  5580. class IntersectionInfo {
  5581. bu: Nullable<number>;
  5582. bv: Nullable<number>;
  5583. distance: number;
  5584. faceId: number;
  5585. subMeshId: number;
  5586. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  5587. }
  5588. class PickingInfo {
  5589. hit: boolean;
  5590. distance: number;
  5591. pickedPoint: Nullable<Vector3>;
  5592. pickedMesh: Nullable<AbstractMesh>;
  5593. bu: number;
  5594. bv: number;
  5595. faceId: number;
  5596. subMeshId: number;
  5597. pickedSprite: Nullable<Sprite>;
  5598. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  5599. getTextureCoordinates(): Nullable<Vector2>;
  5600. }
  5601. }
  5602. declare module BABYLON {
  5603. class BoundingBox implements ICullable {
  5604. vectors: Vector3[];
  5605. center: Vector3;
  5606. centerWorld: Vector3;
  5607. extendSize: Vector3;
  5608. extendSizeWorld: Vector3;
  5609. directions: Vector3[];
  5610. vectorsWorld: Vector3[];
  5611. minimumWorld: Vector3;
  5612. maximumWorld: Vector3;
  5613. minimum: Vector3;
  5614. maximum: Vector3;
  5615. private _worldMatrix;
  5616. /**
  5617. * Creates a new bounding box
  5618. * @param min defines the minimum vector (in local space)
  5619. * @param max defines the maximum vector (in local space)
  5620. */
  5621. constructor(min: Vector3, max: Vector3);
  5622. /**
  5623. * Recreates the entire bounding box from scratch
  5624. * @param min defines the new minimum vector (in local space)
  5625. * @param max defines the new maximum vector (in local space)
  5626. */
  5627. reConstruct(min: Vector3, max: Vector3): void;
  5628. getWorldMatrix(): Matrix;
  5629. setWorldMatrix(matrix: Matrix): BoundingBox;
  5630. _update(world: Matrix): void;
  5631. isInFrustum(frustumPlanes: Plane[]): boolean;
  5632. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5633. intersectsPoint(point: Vector3): boolean;
  5634. intersectsSphere(sphere: BoundingSphere): boolean;
  5635. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  5636. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  5637. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  5638. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5639. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5640. }
  5641. }
  5642. declare module BABYLON {
  5643. interface ICullable {
  5644. isInFrustum(frustumPlanes: Plane[]): boolean;
  5645. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5646. }
  5647. class BoundingInfo implements ICullable {
  5648. minimum: Vector3;
  5649. maximum: Vector3;
  5650. boundingBox: BoundingBox;
  5651. boundingSphere: BoundingSphere;
  5652. private _isLocked;
  5653. constructor(minimum: Vector3, maximum: Vector3);
  5654. isLocked: boolean;
  5655. update(world: Matrix): void;
  5656. /**
  5657. * Recreate the bounding info to be centered around a specific point given a specific extend.
  5658. * @param center New center of the bounding info
  5659. * @param extend New extend of the bounding info
  5660. */
  5661. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  5662. isInFrustum(frustumPlanes: Plane[]): boolean;
  5663. /**
  5664. * Gets the world distance between the min and max points of the bounding box
  5665. */
  5666. readonly diagonalLength: number;
  5667. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5668. _checkCollision(collider: Collider): boolean;
  5669. intersectsPoint(point: Vector3): boolean;
  5670. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  5671. }
  5672. }
  5673. declare module BABYLON {
  5674. class BoundingSphere {
  5675. center: Vector3;
  5676. radius: number;
  5677. centerWorld: Vector3;
  5678. radiusWorld: number;
  5679. minimum: Vector3;
  5680. maximum: Vector3;
  5681. private _tempRadiusVector;
  5682. /**
  5683. * Creates a new bounding sphere
  5684. * @param min defines the minimum vector (in local space)
  5685. * @param max defines the maximum vector (in local space)
  5686. */
  5687. constructor(min: Vector3, max: Vector3);
  5688. /**
  5689. * Recreates the entire bounding sphere from scratch
  5690. * @param min defines the new minimum vector (in local space)
  5691. * @param max defines the new maximum vector (in local space)
  5692. */
  5693. reConstruct(min: Vector3, max: Vector3): void;
  5694. _update(world: Matrix): void;
  5695. isInFrustum(frustumPlanes: Plane[]): boolean;
  5696. intersectsPoint(point: Vector3): boolean;
  5697. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  5698. }
  5699. }
  5700. declare module BABYLON {
  5701. class Ray {
  5702. origin: Vector3;
  5703. direction: Vector3;
  5704. length: number;
  5705. private _edge1;
  5706. private _edge2;
  5707. private _pvec;
  5708. private _tvec;
  5709. private _qvec;
  5710. private _tmpRay;
  5711. constructor(origin: Vector3, direction: Vector3, length?: number);
  5712. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  5713. intersectsBox(box: BoundingBox): boolean;
  5714. intersectsSphere(sphere: BoundingSphere): boolean;
  5715. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  5716. intersectsPlane(plane: Plane): Nullable<number>;
  5717. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  5718. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  5719. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  5720. private static smallnum;
  5721. private static rayl;
  5722. /**
  5723. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  5724. * @param sega the first point of the segment to test the intersection against
  5725. * @param segb the second point of the segment to test the intersection against
  5726. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  5727. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  5728. */
  5729. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  5730. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5731. static Zero(): Ray;
  5732. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5733. /**
  5734. * 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
  5735. * transformed to the given world matrix.
  5736. * @param origin The origin point
  5737. * @param end The end point
  5738. * @param world a matrix to transform the ray to. Default is the identity matrix.
  5739. */
  5740. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  5741. static Transform(ray: Ray, matrix: Matrix): Ray;
  5742. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  5743. }
  5744. }
  5745. /**
  5746. * Module Debug contains the (visual) components to debug a scene correctly
  5747. */
  5748. declare module BABYLON.Debug {
  5749. /**
  5750. * The Axes viewer will show 3 axes in a specific point in space
  5751. */
  5752. class AxesViewer {
  5753. private _xline;
  5754. private _yline;
  5755. private _zline;
  5756. private _xmesh;
  5757. private _ymesh;
  5758. private _zmesh;
  5759. scene: Nullable<Scene>;
  5760. scaleLines: number;
  5761. constructor(scene: Scene, scaleLines?: number);
  5762. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  5763. dispose(): void;
  5764. }
  5765. }
  5766. declare module BABYLON.Debug {
  5767. /**
  5768. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  5769. */
  5770. class BoneAxesViewer extends AxesViewer {
  5771. mesh: Nullable<Mesh>;
  5772. bone: Nullable<Bone>;
  5773. pos: Vector3;
  5774. xaxis: Vector3;
  5775. yaxis: Vector3;
  5776. zaxis: Vector3;
  5777. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  5778. update(): void;
  5779. dispose(): void;
  5780. }
  5781. }
  5782. declare module BABYLON {
  5783. class DebugLayer {
  5784. private _scene;
  5785. static InspectorURL: string;
  5786. private _inspector;
  5787. private BJSINSPECTOR;
  5788. constructor(scene: Scene);
  5789. /** Creates the inspector window. */
  5790. private _createInspector(config?);
  5791. isVisible(): boolean;
  5792. hide(): void;
  5793. show(config?: {
  5794. popup?: boolean;
  5795. initialTab?: number;
  5796. parentElement?: HTMLElement;
  5797. newColors?: {
  5798. backgroundColor?: string;
  5799. backgroundColorLighter?: string;
  5800. backgroundColorLighter2?: string;
  5801. backgroundColorLighter3?: string;
  5802. color?: string;
  5803. colorTop?: string;
  5804. colorBot?: string;
  5805. };
  5806. }): void;
  5807. }
  5808. }
  5809. declare module BABYLON.Debug {
  5810. /**
  5811. * Used to show the physics impostor around the specific mesh.
  5812. */
  5813. class PhysicsViewer {
  5814. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  5815. protected _meshes: Array<Nullable<AbstractMesh>>;
  5816. protected _scene: Nullable<Scene>;
  5817. protected _numMeshes: number;
  5818. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  5819. private _renderFunction;
  5820. private _debugBoxMesh;
  5821. private _debugSphereMesh;
  5822. private _debugMaterial;
  5823. constructor(scene: Scene);
  5824. protected _updateDebugMeshes(): void;
  5825. showImpostor(impostor: PhysicsImpostor): void;
  5826. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  5827. private _getDebugMaterial(scene);
  5828. private _getDebugBoxMesh(scene);
  5829. private _getDebugSphereMesh(scene);
  5830. private _getDebugMesh(impostor, scene);
  5831. dispose(): void;
  5832. }
  5833. }
  5834. declare module BABYLON {
  5835. class RayHelper {
  5836. ray: Nullable<Ray>;
  5837. private _renderPoints;
  5838. private _renderLine;
  5839. private _renderFunction;
  5840. private _scene;
  5841. private _updateToMeshFunction;
  5842. private _attachedToMesh;
  5843. private _meshSpaceDirection;
  5844. private _meshSpaceOrigin;
  5845. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  5846. constructor(ray: Ray);
  5847. show(scene: Scene, color: Color3): void;
  5848. hide(): void;
  5849. private _render();
  5850. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  5851. detachFromMesh(): void;
  5852. private _updateToMesh();
  5853. dispose(): void;
  5854. }
  5855. }
  5856. declare module BABYLON.Debug {
  5857. /**
  5858. * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8
  5859. */
  5860. class SkeletonViewer {
  5861. skeleton: Skeleton;
  5862. mesh: AbstractMesh;
  5863. autoUpdateBonesMatrices: boolean;
  5864. renderingGroupId: number;
  5865. color: Color3;
  5866. private _scene;
  5867. private _debugLines;
  5868. private _debugMesh;
  5869. private _isEnabled;
  5870. private _renderFunction;
  5871. constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number);
  5872. isEnabled: boolean;
  5873. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  5874. private _getLinesForBonesWithLength(bones, meshMat);
  5875. private _getLinesForBonesNoLength(bones, meshMat);
  5876. update(): void;
  5877. dispose(): void;
  5878. }
  5879. }
  5880. declare module BABYLON {
  5881. class ArcRotateCamera extends TargetCamera {
  5882. alpha: number;
  5883. beta: number;
  5884. radius: number;
  5885. protected _target: Vector3;
  5886. protected _targetHost: Nullable<AbstractMesh>;
  5887. target: Vector3;
  5888. inertialAlphaOffset: number;
  5889. inertialBetaOffset: number;
  5890. inertialRadiusOffset: number;
  5891. lowerAlphaLimit: Nullable<number>;
  5892. upperAlphaLimit: Nullable<number>;
  5893. lowerBetaLimit: number;
  5894. upperBetaLimit: number;
  5895. lowerRadiusLimit: Nullable<number>;
  5896. upperRadiusLimit: Nullable<number>;
  5897. inertialPanningX: number;
  5898. inertialPanningY: number;
  5899. pinchToPanMaxDistance: number;
  5900. panningDistanceLimit: Nullable<number>;
  5901. panningOriginTarget: Vector3;
  5902. panningInertia: number;
  5903. angularSensibilityX: number;
  5904. angularSensibilityY: number;
  5905. pinchPrecision: number;
  5906. pinchDeltaPercentage: number;
  5907. panningSensibility: number;
  5908. keysUp: number[];
  5909. keysDown: number[];
  5910. keysLeft: number[];
  5911. keysRight: number[];
  5912. wheelPrecision: number;
  5913. wheelDeltaPercentage: number;
  5914. zoomOnFactor: number;
  5915. targetScreenOffset: Vector2;
  5916. allowUpsideDown: boolean;
  5917. _viewMatrix: Matrix;
  5918. _useCtrlForPanning: boolean;
  5919. _panningMouseButton: number;
  5920. inputs: ArcRotateCameraInputsManager;
  5921. _reset: () => void;
  5922. panningAxis: Vector3;
  5923. protected _localDirection: Vector3;
  5924. protected _transformedDirection: Vector3;
  5925. private _bouncingBehavior;
  5926. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  5927. useBouncingBehavior: boolean;
  5928. private _framingBehavior;
  5929. readonly framingBehavior: Nullable<FramingBehavior>;
  5930. useFramingBehavior: boolean;
  5931. private _autoRotationBehavior;
  5932. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  5933. useAutoRotationBehavior: boolean;
  5934. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  5935. onCollide: (collidedMesh: AbstractMesh) => void;
  5936. checkCollisions: boolean;
  5937. collisionRadius: Vector3;
  5938. protected _collider: Collider;
  5939. protected _previousPosition: Vector3;
  5940. protected _collisionVelocity: Vector3;
  5941. protected _newPosition: Vector3;
  5942. protected _previousAlpha: number;
  5943. protected _previousBeta: number;
  5944. protected _previousRadius: number;
  5945. protected _collisionTriggered: boolean;
  5946. protected _targetBoundingCenter: Nullable<Vector3>;
  5947. private _computationVector;
  5948. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  5949. _initCache(): void;
  5950. _updateCache(ignoreParentClass?: boolean): void;
  5951. protected _getTargetPosition(): Vector3;
  5952. /**
  5953. * Store current camera state (fov, position, etc..)
  5954. */
  5955. private _storedAlpha;
  5956. private _storedBeta;
  5957. private _storedRadius;
  5958. private _storedTarget;
  5959. storeState(): Camera;
  5960. /**
  5961. * Restored camera state. You must call storeState() first
  5962. */
  5963. _restoreStateValues(): boolean;
  5964. _isSynchronizedViewMatrix(): boolean;
  5965. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  5966. detachControl(element: HTMLElement): void;
  5967. _checkInputs(): void;
  5968. protected _checkLimits(): void;
  5969. rebuildAnglesAndRadius(): void;
  5970. setPosition(position: Vector3): void;
  5971. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  5972. _getViewMatrix(): Matrix;
  5973. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  5974. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  5975. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  5976. min: Vector3;
  5977. max: Vector3;
  5978. distance: number;
  5979. }, doNotUpdateMaxZ?: boolean): void;
  5980. /**
  5981. * @override
  5982. * Override Camera.createRigCamera
  5983. */
  5984. createRigCamera(name: string, cameraIndex: number): Camera;
  5985. /**
  5986. * @override
  5987. * Override Camera._updateRigCameras
  5988. */
  5989. _updateRigCameras(): void;
  5990. dispose(): void;
  5991. getClassName(): string;
  5992. }
  5993. }
  5994. declare module BABYLON {
  5995. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  5996. constructor(camera: ArcRotateCamera);
  5997. addMouseWheel(): ArcRotateCameraInputsManager;
  5998. addPointers(): ArcRotateCameraInputsManager;
  5999. addKeyboard(): ArcRotateCameraInputsManager;
  6000. addGamepad(): ArcRotateCameraInputsManager;
  6001. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  6002. }
  6003. }
  6004. declare module BABYLON {
  6005. class Camera extends Node {
  6006. inputs: CameraInputsManager<Camera>;
  6007. private static _PERSPECTIVE_CAMERA;
  6008. private static _ORTHOGRAPHIC_CAMERA;
  6009. private static _FOVMODE_VERTICAL_FIXED;
  6010. private static _FOVMODE_HORIZONTAL_FIXED;
  6011. private static _RIG_MODE_NONE;
  6012. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  6013. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  6014. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  6015. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  6016. private static _RIG_MODE_VR;
  6017. private static _RIG_MODE_WEBVR;
  6018. static readonly PERSPECTIVE_CAMERA: number;
  6019. static readonly ORTHOGRAPHIC_CAMERA: number;
  6020. /**
  6021. * This is the default FOV mode for perspective cameras.
  6022. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  6023. *
  6024. */
  6025. static readonly FOVMODE_VERTICAL_FIXED: number;
  6026. /**
  6027. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  6028. *
  6029. */
  6030. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  6031. static readonly RIG_MODE_NONE: number;
  6032. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  6033. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  6034. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  6035. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  6036. static readonly RIG_MODE_VR: number;
  6037. static readonly RIG_MODE_WEBVR: number;
  6038. static ForceAttachControlToAlwaysPreventDefault: boolean;
  6039. static UseAlternateWebVRRendering: boolean;
  6040. position: Vector3;
  6041. /**
  6042. * The vector the camera should consider as up.
  6043. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  6044. */
  6045. upVector: Vector3;
  6046. orthoLeft: Nullable<number>;
  6047. orthoRight: Nullable<number>;
  6048. orthoBottom: Nullable<number>;
  6049. orthoTop: Nullable<number>;
  6050. /**
  6051. * FOV is set in Radians. (default is 0.8)
  6052. */
  6053. fov: number;
  6054. minZ: number;
  6055. maxZ: number;
  6056. inertia: number;
  6057. mode: number;
  6058. isIntermediate: boolean;
  6059. viewport: Viewport;
  6060. /**
  6061. * Restricts the camera to viewing objects with the same layerMask.
  6062. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  6063. */
  6064. layerMask: number;
  6065. /**
  6066. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  6067. */
  6068. fovMode: number;
  6069. cameraRigMode: number;
  6070. interaxialDistance: number;
  6071. isStereoscopicSideBySide: boolean;
  6072. _cameraRigParams: any;
  6073. _rigCameras: Camera[];
  6074. _rigPostProcess: Nullable<PostProcess>;
  6075. protected _webvrViewMatrix: Matrix;
  6076. _skipRendering: boolean;
  6077. _alternateCamera: Camera;
  6078. customRenderTargets: RenderTargetTexture[];
  6079. onViewMatrixChangedObservable: Observable<Camera>;
  6080. onProjectionMatrixChangedObservable: Observable<Camera>;
  6081. onAfterCheckInputsObservable: Observable<Camera>;
  6082. onRestoreStateObservable: Observable<Camera>;
  6083. private _computedViewMatrix;
  6084. _projectionMatrix: Matrix;
  6085. private _doNotComputeProjectionMatrix;
  6086. private _worldMatrix;
  6087. _postProcesses: Nullable<PostProcess>[];
  6088. private _transformMatrix;
  6089. _activeMeshes: SmartArray<AbstractMesh>;
  6090. protected _globalPosition: Vector3;
  6091. private _frustumPlanes;
  6092. private _refreshFrustumPlanes;
  6093. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6094. private _storedFov;
  6095. private _stateStored;
  6096. /**
  6097. * Store current camera state (fov, position, etc..)
  6098. */
  6099. storeState(): Camera;
  6100. /**
  6101. * Restores the camera state values if it has been stored. You must call storeState() first
  6102. */
  6103. protected _restoreStateValues(): boolean;
  6104. /**
  6105. * Restored camera state. You must call storeState() first
  6106. */
  6107. restoreState(): boolean;
  6108. getClassName(): string;
  6109. /**
  6110. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  6111. */
  6112. toString(fullDetails?: boolean): string;
  6113. readonly globalPosition: Vector3;
  6114. getActiveMeshes(): SmartArray<AbstractMesh>;
  6115. isActiveMesh(mesh: Mesh): boolean;
  6116. /**
  6117. * Is this camera ready to be used/rendered
  6118. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  6119. * @return true if the camera is ready
  6120. */
  6121. isReady(completeCheck?: boolean): boolean;
  6122. _initCache(): void;
  6123. _updateCache(ignoreParentClass?: boolean): void;
  6124. _isSynchronized(): boolean;
  6125. _isSynchronizedViewMatrix(): boolean;
  6126. _isSynchronizedProjectionMatrix(): boolean;
  6127. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6128. detachControl(element: HTMLElement): void;
  6129. update(): void;
  6130. _checkInputs(): void;
  6131. readonly rigCameras: Camera[];
  6132. readonly rigPostProcess: Nullable<PostProcess>;
  6133. /**
  6134. * Internal, gets the first post proces.
  6135. * @returns the first post process to be run on this camera.
  6136. */
  6137. _getFirstPostProcess(): Nullable<PostProcess>;
  6138. private _cascadePostProcessesToRigCams();
  6139. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  6140. detachPostProcess(postProcess: PostProcess): void;
  6141. getWorldMatrix(): Matrix;
  6142. _getViewMatrix(): Matrix;
  6143. getViewMatrix(force?: boolean): Matrix;
  6144. freezeProjectionMatrix(projection?: Matrix): void;
  6145. unfreezeProjectionMatrix(): void;
  6146. getProjectionMatrix(force?: boolean): Matrix;
  6147. getTranformationMatrix(): Matrix;
  6148. private updateFrustumPlanes();
  6149. isInFrustum(target: ICullable): boolean;
  6150. isCompletelyInFrustum(target: ICullable): boolean;
  6151. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  6152. /**
  6153. * Releases resources associated with this node.
  6154. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  6155. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  6156. */
  6157. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  6158. readonly leftCamera: Nullable<FreeCamera>;
  6159. readonly rightCamera: Nullable<FreeCamera>;
  6160. getLeftTarget(): Nullable<Vector3>;
  6161. getRightTarget(): Nullable<Vector3>;
  6162. setCameraRigMode(mode: number, rigParams: any): void;
  6163. private _getVRProjectionMatrix();
  6164. protected _updateCameraRotationMatrix(): void;
  6165. protected _updateWebVRCameraRotationMatrix(): void;
  6166. /**
  6167. * This function MUST be overwritten by the different WebVR cameras available.
  6168. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6169. */
  6170. protected _getWebVRProjectionMatrix(): Matrix;
  6171. /**
  6172. * This function MUST be overwritten by the different WebVR cameras available.
  6173. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6174. */
  6175. protected _getWebVRViewMatrix(): Matrix;
  6176. setCameraRigParameter(name: string, value: any): void;
  6177. /**
  6178. * needs to be overridden by children so sub has required properties to be copied
  6179. */
  6180. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6181. /**
  6182. * May need to be overridden by children
  6183. */
  6184. _updateRigCameras(): void;
  6185. _setupInputs(): void;
  6186. serialize(): any;
  6187. clone(name: string): Camera;
  6188. getDirection(localAxis: Vector3): Vector3;
  6189. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  6190. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  6191. computeWorldMatrix(): Matrix;
  6192. static Parse(parsedCamera: any, scene: Scene): Camera;
  6193. }
  6194. }
  6195. declare module BABYLON {
  6196. var CameraInputTypes: {};
  6197. interface ICameraInput<TCamera extends Camera> {
  6198. camera: Nullable<TCamera>;
  6199. getClassName(): string;
  6200. getSimpleName(): string;
  6201. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  6202. detachControl: (element: Nullable<HTMLElement>) => void;
  6203. checkInputs?: () => void;
  6204. }
  6205. interface CameraInputsMap<TCamera extends Camera> {
  6206. [name: string]: ICameraInput<TCamera>;
  6207. [idx: number]: ICameraInput<TCamera>;
  6208. }
  6209. class CameraInputsManager<TCamera extends Camera> {
  6210. attached: CameraInputsMap<TCamera>;
  6211. attachedElement: Nullable<HTMLElement>;
  6212. noPreventDefault: boolean;
  6213. camera: TCamera;
  6214. checkInputs: () => void;
  6215. constructor(camera: TCamera);
  6216. /**
  6217. * Add an input method to a camera.
  6218. * builtin inputs example: camera.inputs.addGamepad();
  6219. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  6220. * @param input camera input method
  6221. */
  6222. add(input: ICameraInput<TCamera>): void;
  6223. /**
  6224. * Remove a specific input method from a camera
  6225. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6226. * @param inputToRemove camera input method
  6227. */
  6228. remove(inputToRemove: ICameraInput<TCamera>): void;
  6229. removeByType(inputType: string): void;
  6230. private _addCheckInputs(fn);
  6231. attachInput(input: ICameraInput<TCamera>): void;
  6232. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6233. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6234. rebuildInputCheck(): void;
  6235. /**
  6236. * Remove all attached input methods from a camera
  6237. */
  6238. clear(): void;
  6239. serialize(serializedCamera: any): void;
  6240. parse(parsedCamera: any): void;
  6241. }
  6242. }
  6243. declare module BABYLON {
  6244. /**
  6245. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  6246. * being tilted forward or back and left or right.
  6247. */
  6248. class DeviceOrientationCamera extends FreeCamera {
  6249. private _initialQuaternion;
  6250. private _quaternionCache;
  6251. /**
  6252. * Creates a new device orientation camera
  6253. * @param name The name of the camera
  6254. * @param position The start position camera
  6255. * @param scene The scene the camera belongs to
  6256. */
  6257. constructor(name: string, position: Vector3, scene: Scene);
  6258. /**
  6259. * Gets the current instance class name ("DeviceOrientationCamera").
  6260. * This helps avoiding instanceof at run time.
  6261. * @returns the class name
  6262. */
  6263. getClassName(): string;
  6264. /**
  6265. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  6266. */
  6267. _checkInputs(): void;
  6268. /**
  6269. * Reset the camera to its default orientation on the specified axis only.
  6270. * @param axis The axis to reset
  6271. */
  6272. resetToCurrentRotation(axis?: Axis): void;
  6273. }
  6274. }
  6275. declare module BABYLON {
  6276. class FollowCamera extends TargetCamera {
  6277. radius: number;
  6278. rotationOffset: number;
  6279. heightOffset: number;
  6280. cameraAcceleration: number;
  6281. maxCameraSpeed: number;
  6282. lockedTarget: Nullable<AbstractMesh>;
  6283. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  6284. private getRadians(degrees);
  6285. private follow(cameraTarget);
  6286. _checkInputs(): void;
  6287. getClassName(): string;
  6288. }
  6289. class ArcFollowCamera extends TargetCamera {
  6290. alpha: number;
  6291. beta: number;
  6292. radius: number;
  6293. target: Nullable<AbstractMesh>;
  6294. private _cartesianCoordinates;
  6295. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  6296. private follow();
  6297. _checkInputs(): void;
  6298. getClassName(): string;
  6299. }
  6300. }
  6301. declare module BABYLON {
  6302. class FreeCamera extends TargetCamera {
  6303. ellipsoid: Vector3;
  6304. ellipsoidOffset: Vector3;
  6305. checkCollisions: boolean;
  6306. applyGravity: boolean;
  6307. inputs: FreeCameraInputsManager;
  6308. /**
  6309. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6310. * Higher values reduce sensitivity.
  6311. */
  6312. /**
  6313. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6314. * Higher values reduce sensitivity.
  6315. */
  6316. angularSensibility: number;
  6317. keysUp: number[];
  6318. keysDown: number[];
  6319. keysLeft: number[];
  6320. keysRight: number[];
  6321. onCollide: (collidedMesh: AbstractMesh) => void;
  6322. private _collider;
  6323. private _needMoveForGravity;
  6324. private _oldPosition;
  6325. private _diffPosition;
  6326. private _newPosition;
  6327. _localDirection: Vector3;
  6328. _transformedDirection: Vector3;
  6329. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6330. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6331. detachControl(element: HTMLElement): void;
  6332. private _collisionMask;
  6333. collisionMask: number;
  6334. _collideWithWorld(displacement: Vector3): void;
  6335. private _onCollisionPositionChange;
  6336. _checkInputs(): void;
  6337. _decideIfNeedsToMove(): boolean;
  6338. _updatePosition(): void;
  6339. dispose(): void;
  6340. getClassName(): string;
  6341. }
  6342. }
  6343. declare module BABYLON {
  6344. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6345. constructor(camera: FreeCamera);
  6346. addKeyboard(): FreeCameraInputsManager;
  6347. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6348. addGamepad(): FreeCameraInputsManager;
  6349. addDeviceOrientation(): FreeCameraInputsManager;
  6350. addTouch(): FreeCameraInputsManager;
  6351. addVirtualJoystick(): FreeCameraInputsManager;
  6352. }
  6353. }
  6354. declare module BABYLON {
  6355. class GamepadCamera extends UniversalCamera {
  6356. gamepadAngularSensibility: number;
  6357. gamepadMoveSensibility: number;
  6358. constructor(name: string, position: Vector3, scene: Scene);
  6359. getClassName(): string;
  6360. }
  6361. }
  6362. declare module BABYLON {
  6363. /**
  6364. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  6365. */
  6366. class AnaglyphFreeCamera extends FreeCamera {
  6367. /**
  6368. * Creates a new AnaglyphFreeCamera
  6369. * @param name defines camera name
  6370. * @param position defines initial position
  6371. * @param interaxialDistance defines distance between each color axis
  6372. * @param scene defines the hosting scene
  6373. */
  6374. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6375. /**
  6376. * Gets camera class name
  6377. * @returns AnaglyphFreeCamera
  6378. */
  6379. getClassName(): string;
  6380. }
  6381. /**
  6382. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  6383. */
  6384. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  6385. /**
  6386. * Creates a new AnaglyphArcRotateCamera
  6387. * @param name defines camera name
  6388. * @param alpha defines alpha angle (in radians)
  6389. * @param beta defines beta angle (in radians)
  6390. * @param radius defines radius
  6391. * @param target defines camera target
  6392. * @param interaxialDistance defines distance between each color axis
  6393. * @param scene defines the hosting scene
  6394. */
  6395. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  6396. /**
  6397. * Gets camera class name
  6398. * @returns AnaglyphArcRotateCamera
  6399. */
  6400. getClassName(): string;
  6401. }
  6402. /**
  6403. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  6404. */
  6405. class AnaglyphGamepadCamera extends GamepadCamera {
  6406. /**
  6407. * Creates a new AnaglyphGamepadCamera
  6408. * @param name defines camera name
  6409. * @param position defines initial position
  6410. * @param interaxialDistance defines distance between each color axis
  6411. * @param scene defines the hosting scene
  6412. */
  6413. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6414. /**
  6415. * Gets camera class name
  6416. * @returns AnaglyphGamepadCamera
  6417. */
  6418. getClassName(): string;
  6419. }
  6420. /**
  6421. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  6422. */
  6423. class AnaglyphUniversalCamera extends UniversalCamera {
  6424. /**
  6425. * Creates a new AnaglyphUniversalCamera
  6426. * @param name defines camera name
  6427. * @param position defines initial position
  6428. * @param interaxialDistance defines distance between each color axis
  6429. * @param scene defines the hosting scene
  6430. */
  6431. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6432. /**
  6433. * Gets camera class name
  6434. * @returns AnaglyphUniversalCamera
  6435. */
  6436. getClassName(): string;
  6437. }
  6438. /**
  6439. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  6440. */
  6441. class StereoscopicFreeCamera extends FreeCamera {
  6442. /**
  6443. * Creates a new StereoscopicFreeCamera
  6444. * @param name defines camera name
  6445. * @param position defines initial position
  6446. * @param interaxialDistance defines distance between each color axis
  6447. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6448. * @param scene defines the hosting scene
  6449. */
  6450. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6451. /**
  6452. * Gets camera class name
  6453. * @returns StereoscopicFreeCamera
  6454. */
  6455. getClassName(): string;
  6456. }
  6457. /**
  6458. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  6459. */
  6460. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  6461. /**
  6462. * Creates a new StereoscopicArcRotateCamera
  6463. * @param name defines camera name
  6464. * @param alpha defines alpha angle (in radians)
  6465. * @param beta defines beta angle (in radians)
  6466. * @param radius defines radius
  6467. * @param target defines camera target
  6468. * @param interaxialDistance defines distance between each color axis
  6469. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6470. * @param scene defines the hosting scene
  6471. */
  6472. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6473. /**
  6474. * Gets camera class name
  6475. * @returns StereoscopicArcRotateCamera
  6476. */
  6477. getClassName(): string;
  6478. }
  6479. /**
  6480. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  6481. */
  6482. class StereoscopicGamepadCamera extends GamepadCamera {
  6483. /**
  6484. * Creates a new StereoscopicGamepadCamera
  6485. * @param name defines camera name
  6486. * @param position defines initial position
  6487. * @param interaxialDistance defines distance between each color axis
  6488. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6489. * @param scene defines the hosting scene
  6490. */
  6491. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6492. /**
  6493. * Gets camera class name
  6494. * @returns StereoscopicGamepadCamera
  6495. */
  6496. getClassName(): string;
  6497. }
  6498. /**
  6499. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  6500. */
  6501. class StereoscopicUniversalCamera extends UniversalCamera {
  6502. /**
  6503. * Creates a new StereoscopicUniversalCamera
  6504. * @param name defines camera name
  6505. * @param position defines initial position
  6506. * @param interaxialDistance defines distance between each color axis
  6507. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6508. * @param scene defines the hosting scene
  6509. */
  6510. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6511. /**
  6512. * Gets camera class name
  6513. * @returns StereoscopicUniversalCamera
  6514. */
  6515. getClassName(): string;
  6516. }
  6517. }
  6518. declare module BABYLON {
  6519. class TargetCamera extends Camera {
  6520. cameraDirection: Vector3;
  6521. cameraRotation: Vector2;
  6522. rotation: Vector3;
  6523. rotationQuaternion: Quaternion;
  6524. speed: number;
  6525. noRotationConstraint: boolean;
  6526. lockedTarget: any;
  6527. _currentTarget: Vector3;
  6528. _viewMatrix: Matrix;
  6529. _camMatrix: Matrix;
  6530. _cameraTransformMatrix: Matrix;
  6531. _cameraRotationMatrix: Matrix;
  6532. private _rigCamTransformMatrix;
  6533. _referencePoint: Vector3;
  6534. private _currentUpVector;
  6535. _transformedReferencePoint: Vector3;
  6536. protected _globalCurrentTarget: Vector3;
  6537. protected _globalCurrentUpVector: Vector3;
  6538. _reset: () => void;
  6539. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6540. getFrontPosition(distance: number): Vector3;
  6541. _getLockedTargetPosition(): Nullable<Vector3>;
  6542. /**
  6543. * Store current camera state (fov, position, etc..)
  6544. */
  6545. private _storedPosition;
  6546. private _storedRotation;
  6547. private _storedRotationQuaternion;
  6548. storeState(): Camera;
  6549. /**
  6550. * Restored camera state. You must call storeState() first
  6551. */
  6552. _restoreStateValues(): boolean;
  6553. _initCache(): void;
  6554. _updateCache(ignoreParentClass?: boolean): void;
  6555. _isSynchronizedViewMatrix(): boolean;
  6556. _computeLocalCameraSpeed(): number;
  6557. setTarget(target: Vector3): void;
  6558. /**
  6559. * Return the current target position of the camera. This value is expressed in local space.
  6560. */
  6561. getTarget(): Vector3;
  6562. _decideIfNeedsToMove(): boolean;
  6563. _updatePosition(): void;
  6564. _checkInputs(): void;
  6565. protected _updateCameraRotationMatrix(): void;
  6566. _getViewMatrix(): Matrix;
  6567. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6568. /**
  6569. * @override
  6570. * Override Camera.createRigCamera
  6571. */
  6572. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6573. /**
  6574. * @override
  6575. * Override Camera._updateRigCameras
  6576. */
  6577. _updateRigCameras(): void;
  6578. private _getRigCamPosition(halfSpace, result);
  6579. getClassName(): string;
  6580. }
  6581. }
  6582. declare module BABYLON {
  6583. class TouchCamera extends FreeCamera {
  6584. touchAngularSensibility: number;
  6585. touchMoveSensibility: number;
  6586. constructor(name: string, position: Vector3, scene: Scene);
  6587. getClassName(): string;
  6588. _setupInputs(): void;
  6589. }
  6590. }
  6591. declare module BABYLON {
  6592. class UniversalCamera extends TouchCamera {
  6593. gamepadAngularSensibility: number;
  6594. gamepadMoveSensibility: number;
  6595. constructor(name: string, position: Vector3, scene: Scene);
  6596. getClassName(): string;
  6597. }
  6598. }
  6599. declare module BABYLON {
  6600. class VirtualJoysticksCamera extends FreeCamera {
  6601. constructor(name: string, position: Vector3, scene: Scene);
  6602. getClassName(): string;
  6603. }
  6604. }
  6605. interface VRDisplay extends EventTarget {
  6606. /**
  6607. * Dictionary of capabilities describing the VRDisplay.
  6608. */
  6609. readonly capabilities: VRDisplayCapabilities;
  6610. /**
  6611. * z-depth defining the far plane of the eye view frustum
  6612. * enables mapping of values in the render target depth
  6613. * attachment to scene coordinates. Initially set to 10000.0.
  6614. */
  6615. depthFar: number;
  6616. /**
  6617. * z-depth defining the near plane of the eye view frustum
  6618. * enables mapping of values in the render target depth
  6619. * attachment to scene coordinates. Initially set to 0.01.
  6620. */
  6621. depthNear: number;
  6622. /**
  6623. * An identifier for this distinct VRDisplay. Used as an
  6624. * association point in the Gamepad API.
  6625. */
  6626. readonly displayId: number;
  6627. /**
  6628. * A display name, a user-readable name identifying it.
  6629. */
  6630. readonly displayName: string;
  6631. readonly isConnected: boolean;
  6632. readonly isPresenting: boolean;
  6633. /**
  6634. * If this VRDisplay supports room-scale experiences, the optional
  6635. * stage attribute contains details on the room-scale parameters.
  6636. */
  6637. readonly stageParameters: VRStageParameters | null;
  6638. /**
  6639. * Passing the value returned by `requestAnimationFrame` to
  6640. * `cancelAnimationFrame` will unregister the callback.
  6641. */
  6642. cancelAnimationFrame(handle: number): void;
  6643. /**
  6644. * Stops presenting to the VRDisplay.
  6645. */
  6646. exitPresent(): Promise<void>;
  6647. getEyeParameters(whichEye: string): VREyeParameters;
  6648. /**
  6649. * Populates the passed VRFrameData with the information required to render
  6650. * the current frame.
  6651. */
  6652. getFrameData(frameData: VRFrameData): boolean;
  6653. /**
  6654. * Get the layers currently being presented.
  6655. */
  6656. getLayers(): VRLayer[];
  6657. /**
  6658. * Return a VRPose containing the future predicted pose of the VRDisplay
  6659. * when the current frame will be presented. The value returned will not
  6660. * change until JavaScript has returned control to the browser.
  6661. *
  6662. * The VRPose will contain the position, orientation, velocity,
  6663. * and acceleration of each of these properties.
  6664. */
  6665. getPose(): VRPose;
  6666. /**
  6667. * Return the current instantaneous pose of the VRDisplay, with no
  6668. * prediction applied.
  6669. */
  6670. getImmediatePose(): VRPose;
  6671. /**
  6672. * The callback passed to `requestAnimationFrame` will be called
  6673. * any time a new frame should be rendered. When the VRDisplay is
  6674. * presenting the callback will be called at the native refresh
  6675. * rate of the HMD. When not presenting this function acts
  6676. * identically to how window.requestAnimationFrame acts. Content should
  6677. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6678. * asynchronously from other displays and at differing refresh rates.
  6679. */
  6680. requestAnimationFrame(callback: FrameRequestCallback): number;
  6681. /**
  6682. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6683. * Repeat calls while already presenting will update the VRLayers being displayed.
  6684. */
  6685. requestPresent(layers: VRLayer[]): Promise<void>;
  6686. /**
  6687. * Reset the pose for this display, treating its current position and
  6688. * orientation as the "origin/zero" values. VRPose.position,
  6689. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6690. * updated when calling resetPose(). This should be called in only
  6691. * sitting-space experiences.
  6692. */
  6693. resetPose(): void;
  6694. /**
  6695. * The VRLayer provided to the VRDisplay will be captured and presented
  6696. * in the HMD. Calling this function has the same effect on the source
  6697. * canvas as any other operation that uses its source image, and canvases
  6698. * created without preserveDrawingBuffer set to true will be cleared.
  6699. */
  6700. submitFrame(pose?: VRPose): void;
  6701. }
  6702. declare var VRDisplay: {
  6703. prototype: VRDisplay;
  6704. new (): VRDisplay;
  6705. };
  6706. interface VRLayer {
  6707. leftBounds?: number[] | null;
  6708. rightBounds?: number[] | null;
  6709. source?: HTMLCanvasElement | null;
  6710. }
  6711. interface VRDisplayCapabilities {
  6712. readonly canPresent: boolean;
  6713. readonly hasExternalDisplay: boolean;
  6714. readonly hasOrientation: boolean;
  6715. readonly hasPosition: boolean;
  6716. readonly maxLayers: number;
  6717. }
  6718. interface VREyeParameters {
  6719. /** @deprecated */
  6720. readonly fieldOfView: VRFieldOfView;
  6721. readonly offset: Float32Array;
  6722. readonly renderHeight: number;
  6723. readonly renderWidth: number;
  6724. }
  6725. interface VRFieldOfView {
  6726. readonly downDegrees: number;
  6727. readonly leftDegrees: number;
  6728. readonly rightDegrees: number;
  6729. readonly upDegrees: number;
  6730. }
  6731. interface VRFrameData {
  6732. readonly leftProjectionMatrix: Float32Array;
  6733. readonly leftViewMatrix: Float32Array;
  6734. readonly pose: VRPose;
  6735. readonly rightProjectionMatrix: Float32Array;
  6736. readonly rightViewMatrix: Float32Array;
  6737. readonly timestamp: number;
  6738. }
  6739. interface VRPose {
  6740. readonly angularAcceleration: Float32Array | null;
  6741. readonly angularVelocity: Float32Array | null;
  6742. readonly linearAcceleration: Float32Array | null;
  6743. readonly linearVelocity: Float32Array | null;
  6744. readonly orientation: Float32Array | null;
  6745. readonly position: Float32Array | null;
  6746. readonly timestamp: number;
  6747. }
  6748. interface VRStageParameters {
  6749. sittingToStandingTransform?: Float32Array;
  6750. sizeX?: number;
  6751. sizeY?: number;
  6752. }
  6753. interface Navigator {
  6754. getVRDisplays(): Promise<VRDisplay[]>;
  6755. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6756. }
  6757. interface Window {
  6758. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6759. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6760. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6761. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6762. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6763. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6764. }
  6765. interface Gamepad {
  6766. readonly displayId: number;
  6767. }
  6768. declare module BABYLON {
  6769. /**
  6770. * Interface for attribute information associated with buffer instanciation
  6771. */
  6772. class InstancingAttributeInfo {
  6773. /**
  6774. * Index/offset of the attribute in the vertex shader
  6775. */
  6776. index: number;
  6777. /**
  6778. * size of the attribute, 1, 2, 3 or 4
  6779. */
  6780. attributeSize: number;
  6781. /**
  6782. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  6783. * default is FLOAT
  6784. */
  6785. attribyteType: number;
  6786. /**
  6787. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  6788. */
  6789. normalized: boolean;
  6790. /**
  6791. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  6792. */
  6793. offset: number;
  6794. /**
  6795. * Name of the GLSL attribute, for debugging purpose only
  6796. */
  6797. attributeName: string;
  6798. }
  6799. /**
  6800. * Define options used to create a render target texture
  6801. */
  6802. class RenderTargetCreationOptions {
  6803. /**
  6804. * Specifies is mipmaps must be generated
  6805. */
  6806. generateMipMaps?: boolean;
  6807. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6808. generateDepthBuffer?: boolean;
  6809. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6810. generateStencilBuffer?: boolean;
  6811. /** Defines texture type (int by default) */
  6812. type?: number;
  6813. /** Defines sampling mode (trilinear by default) */
  6814. samplingMode?: number;
  6815. /** Defines format (RGBA by default) */
  6816. format?: number;
  6817. }
  6818. /**
  6819. * Define options used to create a depth texture
  6820. */
  6821. class DepthTextureCreationOptions {
  6822. /** Specifies whether or not a stencil should be allocated in the texture */
  6823. generateStencil?: boolean;
  6824. /** Specifies whether or not bilinear filtering is enable on the texture */
  6825. bilinearFiltering?: boolean;
  6826. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  6827. comparisonFunction?: number;
  6828. /** Specifies if the created texture is a cube texture */
  6829. isCube?: boolean;
  6830. }
  6831. /**
  6832. * Class used to describe the capabilities of the engine relatively to the current browser
  6833. */
  6834. class EngineCapabilities {
  6835. /** Maximum textures units per fragment shader */
  6836. maxTexturesImageUnits: number;
  6837. /** Maximum texture units per vertex shader */
  6838. maxVertexTextureImageUnits: number;
  6839. /** Maximum textures units in the entire pipeline */
  6840. maxCombinedTexturesImageUnits: number;
  6841. /** Maximum texture size */
  6842. maxTextureSize: number;
  6843. /** Maximum cube texture size */
  6844. maxCubemapTextureSize: number;
  6845. /** Maximum render texture size */
  6846. maxRenderTextureSize: number;
  6847. /** Maximum number of vertex attributes */
  6848. maxVertexAttribs: number;
  6849. /** Maximum number of varyings */
  6850. maxVaryingVectors: number;
  6851. /** Maximum number of uniforms per vertex shader */
  6852. maxVertexUniformVectors: number;
  6853. /** Maximum number of uniforms per fragment shader */
  6854. maxFragmentUniformVectors: number;
  6855. /** Defines if standard derivates (dx/dy) are supported */
  6856. standardDerivatives: boolean;
  6857. /** Defines if s3tc texture compression is supported */
  6858. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  6859. /** Defines if pvrtc texture compression is supported */
  6860. pvrtc: any;
  6861. /** Defines if etc1 texture compression is supported */
  6862. etc1: any;
  6863. /** Defines if etc2 texture compression is supported */
  6864. etc2: any;
  6865. /** Defines if astc texture compression is supported */
  6866. astc: any;
  6867. /** Defines if float textures are supported */
  6868. textureFloat: boolean;
  6869. /** Defines if vertex array objects are supported */
  6870. vertexArrayObject: boolean;
  6871. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  6872. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  6873. /** Gets the maximum level of anisotropy supported */
  6874. maxAnisotropy: number;
  6875. /** Defines if instancing is supported */
  6876. instancedArrays: boolean;
  6877. /** Defines if 32 bits indices are supported */
  6878. uintIndices: boolean;
  6879. /** Defines if high precision shaders are supported */
  6880. highPrecisionShaderSupported: boolean;
  6881. /** Defines if depth reading in the fragment shader is supported */
  6882. fragmentDepthSupported: boolean;
  6883. /** Defines if float texture linear filtering is supported*/
  6884. textureFloatLinearFiltering: boolean;
  6885. /** Defines if rendering to float textures is supported */
  6886. textureFloatRender: boolean;
  6887. /** Defines if half float textures are supported*/
  6888. textureHalfFloat: boolean;
  6889. /** Defines if half float texture linear filtering is supported*/
  6890. textureHalfFloatLinearFiltering: boolean;
  6891. /** Defines if rendering to half float textures is supported */
  6892. textureHalfFloatRender: boolean;
  6893. /** Defines if textureLOD shader command is supported */
  6894. textureLOD: boolean;
  6895. /** Defines if draw buffers extension is supported */
  6896. drawBuffersExtension: boolean;
  6897. /** Defines if depth textures are supported */
  6898. depthTextureExtension: boolean;
  6899. /** Defines if float color buffer are supported */
  6900. colorBufferFloat: boolean;
  6901. /** Gets disjoint timer query extension (null if not supported) */
  6902. timerQuery: EXT_disjoint_timer_query;
  6903. /** Defines if timestamp can be used with timer query */
  6904. canUseTimestampForTimerQuery: boolean;
  6905. }
  6906. /** Interface defining initialization parameters for Engine class */
  6907. interface EngineOptions extends WebGLContextAttributes {
  6908. /**
  6909. * Defines if the engine should no exceed a specified device ratio
  6910. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  6911. */
  6912. limitDeviceRatio?: number;
  6913. /**
  6914. * Defines if webvr should be enabled automatically
  6915. * @see http://doc.babylonjs.com/how_to/webvr_camera
  6916. */
  6917. autoEnableWebVR?: boolean;
  6918. /**
  6919. * Defines if webgl2 should be turned off even if supported
  6920. * @see http://doc.babylonjs.com/features/webgl2
  6921. */
  6922. disableWebGL2Support?: boolean;
  6923. /**
  6924. * Defines if webaudio should be initialized as well
  6925. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6926. */
  6927. audioEngine?: boolean;
  6928. /**
  6929. * Defines if animations should run using a deterministic lock step
  6930. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  6931. */
  6932. deterministicLockstep?: boolean;
  6933. /** Defines the maximum steps to use with deterministic lock step mode */
  6934. lockstepMaxSteps?: number;
  6935. /**
  6936. * Defines that engine should ignore context lost events
  6937. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  6938. */
  6939. doNotHandleContextLost?: boolean;
  6940. }
  6941. /**
  6942. * Defines the interface used by display changed events
  6943. */
  6944. interface IDisplayChangedEventArgs {
  6945. /** Gets the vrDisplay object (if any) */
  6946. vrDisplay: Nullable<any>;
  6947. /** Gets a boolean indicating if webVR is supported */
  6948. vrSupported: boolean;
  6949. }
  6950. /**
  6951. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  6952. */
  6953. class Engine {
  6954. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  6955. static ExceptionList: ({
  6956. key: string;
  6957. capture: string;
  6958. captureConstraint: number;
  6959. targets: string[];
  6960. } | {
  6961. key: string;
  6962. capture: null;
  6963. captureConstraint: null;
  6964. targets: string[];
  6965. })[];
  6966. /** Gets the list of created engines */
  6967. static Instances: Engine[];
  6968. /**
  6969. * Gets the latest created engine
  6970. */
  6971. static readonly LastCreatedEngine: Nullable<Engine>;
  6972. /**
  6973. * Gets the latest created scene
  6974. */
  6975. static readonly LastCreatedScene: Nullable<Scene>;
  6976. /**
  6977. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  6978. * @param flag defines which part of the materials must be marked as dirty
  6979. * @param predicate defines a predicate used to filter which materials should be affected
  6980. */
  6981. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  6982. private static _ALPHA_DISABLE;
  6983. private static _ALPHA_ADD;
  6984. private static _ALPHA_COMBINE;
  6985. private static _ALPHA_SUBTRACT;
  6986. private static _ALPHA_MULTIPLY;
  6987. private static _ALPHA_MAXIMIZED;
  6988. private static _ALPHA_ONEONE;
  6989. private static _ALPHA_PREMULTIPLIED;
  6990. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  6991. private static _ALPHA_INTERPOLATE;
  6992. private static _ALPHA_SCREENMODE;
  6993. private static _DELAYLOADSTATE_NONE;
  6994. private static _DELAYLOADSTATE_LOADED;
  6995. private static _DELAYLOADSTATE_LOADING;
  6996. private static _DELAYLOADSTATE_NOTLOADED;
  6997. private static _TEXTUREFORMAT_ALPHA;
  6998. private static _TEXTUREFORMAT_LUMINANCE;
  6999. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  7000. private static _TEXTUREFORMAT_RGB;
  7001. private static _TEXTUREFORMAT_RGBA;
  7002. private static _TEXTUREFORMAT_R32F;
  7003. private static _TEXTUREFORMAT_RG32F;
  7004. private static _TEXTUREFORMAT_RGB32F;
  7005. private static _TEXTUREFORMAT_RGBA32F;
  7006. private static _TEXTURETYPE_UNSIGNED_INT;
  7007. private static _TEXTURETYPE_FLOAT;
  7008. private static _TEXTURETYPE_HALF_FLOAT;
  7009. private static _NEVER;
  7010. private static _ALWAYS;
  7011. private static _LESS;
  7012. private static _EQUAL;
  7013. private static _LEQUAL;
  7014. private static _GREATER;
  7015. private static _GEQUAL;
  7016. private static _NOTEQUAL;
  7017. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  7018. static readonly NEVER: number;
  7019. /** 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 */
  7020. static readonly ALWAYS: number;
  7021. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  7022. static readonly LESS: number;
  7023. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  7024. static readonly EQUAL: number;
  7025. /** 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 */
  7026. static readonly LEQUAL: number;
  7027. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  7028. static readonly GREATER: number;
  7029. /** 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 */
  7030. static readonly GEQUAL: number;
  7031. /** 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 */
  7032. static readonly NOTEQUAL: number;
  7033. private static _KEEP;
  7034. private static _REPLACE;
  7035. private static _INCR;
  7036. private static _DECR;
  7037. private static _INVERT;
  7038. private static _INCR_WRAP;
  7039. private static _DECR_WRAP;
  7040. /** Passed to stencilOperation to specify that stencil value must be kept */
  7041. static readonly KEEP: number;
  7042. /** Passed to stencilOperation to specify that stencil value must be replaced */
  7043. static readonly REPLACE: number;
  7044. /** Passed to stencilOperation to specify that stencil value must be incremented */
  7045. static readonly INCR: number;
  7046. /** Passed to stencilOperation to specify that stencil value must be decremented */
  7047. static readonly DECR: number;
  7048. /** Passed to stencilOperation to specify that stencil value must be inverted */
  7049. static readonly INVERT: number;
  7050. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  7051. static readonly INCR_WRAP: number;
  7052. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  7053. static readonly DECR_WRAP: number;
  7054. /** Defines that alpha blending is disabled */
  7055. static readonly ALPHA_DISABLE: number;
  7056. /** Defines that alpha blending to SRC + DEST */
  7057. static readonly ALPHA_ONEONE: number;
  7058. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  7059. static readonly ALPHA_ADD: number;
  7060. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  7061. static readonly ALPHA_COMBINE: number;
  7062. /** Defines that alpha blending to DEST - SRC * DEST */
  7063. static readonly ALPHA_SUBTRACT: number;
  7064. /** Defines that alpha blending to SRC * DEST */
  7065. static readonly ALPHA_MULTIPLY: number;
  7066. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  7067. static readonly ALPHA_MAXIMIZED: number;
  7068. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  7069. static readonly ALPHA_PREMULTIPLIED: number;
  7070. /**
  7071. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  7072. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  7073. */
  7074. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  7075. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  7076. static readonly ALPHA_INTERPOLATE: number;
  7077. /**
  7078. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  7079. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  7080. */
  7081. static readonly ALPHA_SCREENMODE: number;
  7082. /** Defines that the ressource is not delayed*/
  7083. static readonly DELAYLOADSTATE_NONE: number;
  7084. /** Defines that the ressource was successfully delay loaded */
  7085. static readonly DELAYLOADSTATE_LOADED: number;
  7086. /** Defines that the ressource is currently delay loading */
  7087. static readonly DELAYLOADSTATE_LOADING: number;
  7088. /** Defines that the ressource is delayed and has not started loading */
  7089. static readonly DELAYLOADSTATE_NOTLOADED: number;
  7090. /** ALPHA */
  7091. static readonly TEXTUREFORMAT_ALPHA: number;
  7092. /** LUMINANCE */
  7093. static readonly TEXTUREFORMAT_LUMINANCE: number;
  7094. /**
  7095. * R32F
  7096. */
  7097. static readonly TEXTUREFORMAT_R32F: number;
  7098. /**
  7099. * RG32F
  7100. */
  7101. static readonly TEXTUREFORMAT_RG32F: number;
  7102. /**
  7103. * RGB32F
  7104. */
  7105. static readonly TEXTUREFORMAT_RGB32F: number;
  7106. /**
  7107. * RGBA32F
  7108. */
  7109. static readonly TEXTUREFORMAT_RGBA32F: number;
  7110. /** LUMINANCE_ALPHA */
  7111. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  7112. /** RGB */
  7113. static readonly TEXTUREFORMAT_RGB: number;
  7114. /** RGBA */
  7115. static readonly TEXTUREFORMAT_RGBA: number;
  7116. /** UNSIGNED_INT */
  7117. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  7118. /** FLOAT */
  7119. static readonly TEXTURETYPE_FLOAT: number;
  7120. /** HALF_FLOAT */
  7121. static readonly TEXTURETYPE_HALF_FLOAT: number;
  7122. private static _SCALEMODE_FLOOR;
  7123. private static _SCALEMODE_NEAREST;
  7124. private static _SCALEMODE_CEILING;
  7125. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  7126. static readonly SCALEMODE_FLOOR: number;
  7127. /** Defines that texture rescaling will look for the nearest power of 2 size */
  7128. static readonly SCALEMODE_NEAREST: number;
  7129. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  7130. static readonly SCALEMODE_CEILING: number;
  7131. /**
  7132. * Returns the current version of the framework
  7133. */
  7134. static readonly Version: string;
  7135. /**
  7136. * Gets or sets the epsilon value used by collision engine
  7137. */
  7138. static CollisionsEpsilon: number;
  7139. /**
  7140. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  7141. */
  7142. static CodeRepository: string;
  7143. /**
  7144. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7145. */
  7146. static ShadersRepository: string;
  7147. /**
  7148. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7149. */
  7150. forcePOTTextures: boolean;
  7151. /**
  7152. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7153. */
  7154. isFullscreen: boolean;
  7155. /**
  7156. * Gets a boolean indicating if the pointer is currently locked
  7157. */
  7158. isPointerLock: boolean;
  7159. /**
  7160. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7161. */
  7162. cullBackFaces: boolean;
  7163. /**
  7164. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7165. */
  7166. renderEvenInBackground: boolean;
  7167. /**
  7168. * Gets or sets a boolean indicating that cache can be kept between frames
  7169. */
  7170. preventCacheWipeBetweenFrames: boolean;
  7171. /**
  7172. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7173. **/
  7174. enableOfflineSupport: boolean;
  7175. /**
  7176. * 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)
  7177. **/
  7178. disableManifestCheck: boolean;
  7179. /**
  7180. * Gets the list of created scenes
  7181. */
  7182. scenes: Scene[];
  7183. /**
  7184. * Gets the list of created postprocesses
  7185. */
  7186. postProcesses: PostProcess[];
  7187. /**
  7188. * Observable event triggered each time the rendering canvas is resized
  7189. */
  7190. onResizeObservable: Observable<Engine>;
  7191. /**
  7192. * Observable event triggered each time the canvas loses focus
  7193. */
  7194. onCanvasBlurObservable: Observable<Engine>;
  7195. /**
  7196. * Observable event triggered each time the canvas gains focus
  7197. */
  7198. onCanvasFocusObservable: Observable<Engine>;
  7199. /**
  7200. * Observable event triggered each time the canvas receives pointerout event
  7201. */
  7202. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7203. /**
  7204. * Observable event triggered before each texture is initialized
  7205. */
  7206. onBeforeTextureInitObservable: Observable<Texture>;
  7207. private _vrDisplay;
  7208. private _vrSupported;
  7209. private _oldSize;
  7210. private _oldHardwareScaleFactor;
  7211. private _vrExclusivePointerMode;
  7212. private _webVRInitPromise;
  7213. /**
  7214. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7215. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7216. */
  7217. readonly isInVRExclusivePointerMode: boolean;
  7218. /**
  7219. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7220. */
  7221. disableUniformBuffers: boolean;
  7222. /** @hidden */
  7223. _uniformBuffers: UniformBuffer[];
  7224. /**
  7225. * Gets a boolean indicating that the engine supports uniform buffers
  7226. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7227. */
  7228. readonly supportsUniformBuffers: boolean;
  7229. /**
  7230. * Observable raised when the engine begins a new frame
  7231. */
  7232. onBeginFrameObservable: Observable<Engine>;
  7233. /**
  7234. * Observable raised when the engine ends the current frame
  7235. */
  7236. onEndFrameObservable: Observable<Engine>;
  7237. /**
  7238. * Observable raised when the engine is about to compile a shader
  7239. */
  7240. onBeforeShaderCompilationObservable: Observable<Engine>;
  7241. /**
  7242. * Observable raised when the engine has jsut compiled a shader
  7243. */
  7244. onAfterShaderCompilationObservable: Observable<Engine>;
  7245. private _gl;
  7246. private _renderingCanvas;
  7247. private _windowIsBackground;
  7248. private _webGLVersion;
  7249. /**
  7250. * Gets a boolean indicating that only power of 2 textures are supported
  7251. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7252. */
  7253. readonly needPOTTextures: boolean;
  7254. /** @hidden */
  7255. _badOS: boolean;
  7256. /** @hidden */
  7257. _badDesktopOS: boolean;
  7258. /**
  7259. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7260. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7261. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7262. */
  7263. disableTextureBindingOptimization: boolean;
  7264. /**
  7265. * Gets the audio engine
  7266. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7267. * @ignorenaming
  7268. */
  7269. static audioEngine: AudioEngine;
  7270. private _onFocus;
  7271. private _onBlur;
  7272. private _onCanvasPointerOut;
  7273. private _onCanvasBlur;
  7274. private _onCanvasFocus;
  7275. private _onFullscreenChange;
  7276. private _onPointerLockChange;
  7277. private _onVRDisplayPointerRestricted;
  7278. private _onVRDisplayPointerUnrestricted;
  7279. private _onVrDisplayConnect;
  7280. private _onVrDisplayDisconnect;
  7281. private _onVrDisplayPresentChange;
  7282. /**
  7283. * Observable signaled when VR display mode changes
  7284. */
  7285. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7286. /**
  7287. * Observable signaled when VR request present is complete
  7288. */
  7289. onVRRequestPresentComplete: Observable<boolean>;
  7290. /**
  7291. * Observable signaled when VR request present starts
  7292. */
  7293. onVRRequestPresentStart: Observable<Engine>;
  7294. private _hardwareScalingLevel;
  7295. /** @hidden */
  7296. protected _caps: EngineCapabilities;
  7297. private _pointerLockRequested;
  7298. private _isStencilEnable;
  7299. private _colorWrite;
  7300. private _loadingScreen;
  7301. /** @hidden */
  7302. _drawCalls: PerfCounter;
  7303. /** @hidden */
  7304. _textureCollisions: PerfCounter;
  7305. private _glVersion;
  7306. private _glRenderer;
  7307. private _glVendor;
  7308. private _videoTextureSupported;
  7309. private _renderingQueueLaunched;
  7310. private _activeRenderLoops;
  7311. private _deterministicLockstep;
  7312. private _lockstepMaxSteps;
  7313. /**
  7314. * Observable signaled when a context lost event is raised
  7315. */
  7316. onContextLostObservable: Observable<Engine>;
  7317. /**
  7318. * Observable signaled when a context restored event is raised
  7319. */
  7320. onContextRestoredObservable: Observable<Engine>;
  7321. private _onContextLost;
  7322. private _onContextRestored;
  7323. private _contextWasLost;
  7324. private _doNotHandleContextLost;
  7325. private _performanceMonitor;
  7326. private _fps;
  7327. private _deltaTime;
  7328. /**
  7329. * Turn this value on if you want to pause FPS computation when in background
  7330. */
  7331. disablePerformanceMonitorInBackground: boolean;
  7332. /**
  7333. * Gets the performance monitor attached to this engine
  7334. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7335. */
  7336. readonly performanceMonitor: PerformanceMonitor;
  7337. /** @hidden */
  7338. protected _depthCullingState: _DepthCullingState;
  7339. /** @hidden */
  7340. protected _stencilState: _StencilState;
  7341. /** @hidden */
  7342. protected _alphaState: _AlphaState;
  7343. /** @hidden */
  7344. protected _alphaMode: number;
  7345. private _internalTexturesCache;
  7346. /** @hidden */
  7347. protected _activeChannel: number;
  7348. private _currentTextureChannel;
  7349. /** @hidden */
  7350. protected _boundTexturesCache: {
  7351. [key: string]: Nullable<InternalTexture>;
  7352. };
  7353. /** @hidden */
  7354. protected _currentEffect: Nullable<Effect>;
  7355. /** @hidden */
  7356. protected _currentProgram: Nullable<WebGLProgram>;
  7357. private _compiledEffects;
  7358. private _vertexAttribArraysEnabled;
  7359. /** @hidden */
  7360. protected _cachedViewport: Nullable<Viewport>;
  7361. private _cachedVertexArrayObject;
  7362. /** @hidden */
  7363. protected _cachedVertexBuffers: any;
  7364. /** @hidden */
  7365. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7366. /** @hidden */
  7367. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7368. /** @hidden */
  7369. protected _currentRenderTarget: Nullable<InternalTexture>;
  7370. private _uintIndicesCurrentlySet;
  7371. private _currentBoundBuffer;
  7372. /** @hidden */
  7373. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7374. private _currentBufferPointers;
  7375. private _currentInstanceLocations;
  7376. private _currentInstanceBuffers;
  7377. private _textureUnits;
  7378. private _firstBoundInternalTextureTracker;
  7379. private _lastBoundInternalTextureTracker;
  7380. private _workingCanvas;
  7381. private _workingContext;
  7382. private _rescalePostProcess;
  7383. private _dummyFramebuffer;
  7384. private _externalData;
  7385. private _bindedRenderFunction;
  7386. private _vaoRecordInProgress;
  7387. private _mustWipeVertexAttributes;
  7388. private _emptyTexture;
  7389. private _emptyCubeTexture;
  7390. private _emptyTexture3D;
  7391. private _frameHandler;
  7392. private _nextFreeTextureSlots;
  7393. private _maxSimultaneousTextures;
  7394. private _activeRequests;
  7395. private _texturesSupported;
  7396. private _textureFormatInUse;
  7397. /**
  7398. * Gets the list of texture formats supported
  7399. */
  7400. readonly texturesSupported: Array<string>;
  7401. /**
  7402. * Gets the list of texture formats in use
  7403. */
  7404. readonly textureFormatInUse: Nullable<string>;
  7405. /**
  7406. * Gets the current viewport
  7407. */
  7408. readonly currentViewport: Nullable<Viewport>;
  7409. /**
  7410. * Gets the default empty texture
  7411. */
  7412. readonly emptyTexture: InternalTexture;
  7413. /**
  7414. * Gets the default empty 3D texture
  7415. */
  7416. readonly emptyTexture3D: InternalTexture;
  7417. /**
  7418. * Gets the default empty cube texture
  7419. */
  7420. readonly emptyCubeTexture: InternalTexture;
  7421. /**
  7422. * Creates a new engine
  7423. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  7424. * @param antialias defines enable antialiasing (default: false)
  7425. * @param options defines further options to be sent to the getContext() function
  7426. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7427. */
  7428. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7429. private _rebuildInternalTextures();
  7430. private _rebuildEffects();
  7431. private _rebuildBuffers();
  7432. private _initGLContext();
  7433. /**
  7434. * Gets version of the current webGL context
  7435. */
  7436. readonly webGLVersion: number;
  7437. /**
  7438. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7439. */
  7440. readonly isStencilEnable: boolean;
  7441. private _prepareWorkingCanvas();
  7442. /**
  7443. * Reset the texture cache to empty state
  7444. */
  7445. resetTextureCache(): void;
  7446. /**
  7447. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7448. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7449. * @returns true if engine is in deterministic lock step mode
  7450. */
  7451. isDeterministicLockStep(): boolean;
  7452. /**
  7453. * Gets the max steps when engine is running in deterministic lock step
  7454. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7455. * @returns the max steps
  7456. */
  7457. getLockstepMaxSteps(): number;
  7458. /**
  7459. * Gets an object containing information about the current webGL context
  7460. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7461. */
  7462. getGlInfo(): {
  7463. vendor: string;
  7464. renderer: string;
  7465. version: string;
  7466. };
  7467. /**
  7468. * Gets current aspect ratio
  7469. * @param camera defines the camera to use to get the aspect ratio
  7470. * @param useScreen defines if screen size must be used (or the current render target if any)
  7471. * @returns a number defining the aspect ratio
  7472. */
  7473. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7474. /**
  7475. * Gets the current render width
  7476. * @param useScreen defines if screen size must be used (or the current render target if any)
  7477. * @returns a number defining the current render width
  7478. */
  7479. getRenderWidth(useScreen?: boolean): number;
  7480. /**
  7481. * Gets the current render height
  7482. * @param useScreen defines if screen size must be used (or the current render target if any)
  7483. * @returns a number defining the current render height
  7484. */
  7485. getRenderHeight(useScreen?: boolean): number;
  7486. /**
  7487. * Gets the HTML canvas attached with the current webGL context
  7488. * @returns a HTML canvas
  7489. */
  7490. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7491. /**
  7492. * Gets the client rect of the HTML canvas attached with the current webGL context
  7493. * @returns a client rectanglee
  7494. */
  7495. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7496. /**
  7497. * Defines the hardware scaling level.
  7498. * By default the hardware scaling level is computed from the window device ratio.
  7499. * 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.
  7500. * @param level defines the level to use
  7501. */
  7502. setHardwareScalingLevel(level: number): void;
  7503. /**
  7504. * Gets the current hardware scaling level.
  7505. * By default the hardware scaling level is computed from the window device ratio.
  7506. * 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.
  7507. * @returns a number indicating the current hardware scaling level
  7508. */
  7509. getHardwareScalingLevel(): number;
  7510. /**
  7511. * Gets the list of loaded textures
  7512. * @returns an array containing all loaded textures
  7513. */
  7514. getLoadedTexturesCache(): InternalTexture[];
  7515. /**
  7516. * Gets the object containing all engine capabilities
  7517. * @returns the EngineCapabilities object
  7518. */
  7519. getCaps(): EngineCapabilities;
  7520. /** @hidden */
  7521. readonly drawCalls: number;
  7522. /** @hidden */
  7523. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  7524. /**
  7525. * Gets the current depth function
  7526. * @returns a number defining the depth function
  7527. */
  7528. getDepthFunction(): Nullable<number>;
  7529. /**
  7530. * Sets the current depth function
  7531. * @param depthFunc defines the function to use
  7532. */
  7533. setDepthFunction(depthFunc: number): void;
  7534. /**
  7535. * Sets the current depth function to GREATER
  7536. */
  7537. setDepthFunctionToGreater(): void;
  7538. /**
  7539. * Sets the current depth function to GEQUAL
  7540. */
  7541. setDepthFunctionToGreaterOrEqual(): void;
  7542. /**
  7543. * Sets the current depth function to LESS
  7544. */
  7545. setDepthFunctionToLess(): void;
  7546. /**
  7547. * Sets the current depth function to LEQUAL
  7548. */
  7549. setDepthFunctionToLessOrEqual(): void;
  7550. /**
  7551. * Gets a boolean indicating if stencil buffer is enabled
  7552. * @returns the current stencil buffer state
  7553. */
  7554. getStencilBuffer(): boolean;
  7555. /**
  7556. * Enable or disable the stencil buffer
  7557. * @param enable defines if the stencil buffer must be enabled or disabled
  7558. */
  7559. setStencilBuffer(enable: boolean): void;
  7560. /**
  7561. * Gets the current stencil mask
  7562. * @returns a number defining the new stencil mask to use
  7563. */
  7564. getStencilMask(): number;
  7565. /**
  7566. * Sets the current stencil mask
  7567. * @param mask defines the new stencil mask to use
  7568. */
  7569. setStencilMask(mask: number): void;
  7570. /**
  7571. * Gets the current stencil function
  7572. * @returns a number defining the stencil function to use
  7573. */
  7574. getStencilFunction(): number;
  7575. /**
  7576. * Gets the current stencil reference value
  7577. * @returns a number defining the stencil reference value to use
  7578. */
  7579. getStencilFunctionReference(): number;
  7580. /**
  7581. * Gets the current stencil mask
  7582. * @returns a number defining the stencil mask to use
  7583. */
  7584. getStencilFunctionMask(): number;
  7585. /**
  7586. * Sets the current stencil function
  7587. * @param stencilFunc defines the new stencil function to use
  7588. */
  7589. setStencilFunction(stencilFunc: number): void;
  7590. /**
  7591. * Sets the current stencil reference
  7592. * @param reference defines the new stencil reference to use
  7593. */
  7594. setStencilFunctionReference(reference: number): void;
  7595. /**
  7596. * Sets the current stencil mask
  7597. * @param mask defines the new stencil mask to use
  7598. */
  7599. setStencilFunctionMask(mask: number): void;
  7600. /**
  7601. * Gets the current stencil operation when stencil fails
  7602. * @returns a number defining stencil operation to use when stencil fails
  7603. */
  7604. getStencilOperationFail(): number;
  7605. /**
  7606. * Gets the current stencil operation when depth fails
  7607. * @returns a number defining stencil operation to use when depth fails
  7608. */
  7609. getStencilOperationDepthFail(): number;
  7610. /**
  7611. * Gets the current stencil operation when stencil passes
  7612. * @returns a number defining stencil operation to use when stencil passes
  7613. */
  7614. getStencilOperationPass(): number;
  7615. /**
  7616. * Sets the stencil operation to use when stencil fails
  7617. * @param operation defines the stencil operation to use when stencil fails
  7618. */
  7619. setStencilOperationFail(operation: number): void;
  7620. /**
  7621. * Sets the stencil operation to use when depth fails
  7622. * @param operation defines the stencil operation to use when depth fails
  7623. */
  7624. setStencilOperationDepthFail(operation: number): void;
  7625. /**
  7626. * Sets the stencil operation to use when stencil passes
  7627. * @param operation defines the stencil operation to use when stencil passes
  7628. */
  7629. setStencilOperationPass(operation: number): void;
  7630. /**
  7631. * Sets a boolean indicating if the dithering state is enabled or disabled
  7632. * @param value defines the dithering state
  7633. */
  7634. setDitheringState(value: boolean): void;
  7635. /**
  7636. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  7637. * @param value defines the rasterizer state
  7638. */
  7639. setRasterizerState(value: boolean): void;
  7640. /**
  7641. * stop executing a render loop function and remove it from the execution array
  7642. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  7643. */
  7644. stopRenderLoop(renderFunction?: () => void): void;
  7645. /** @hidden */
  7646. _renderLoop(): void;
  7647. /**
  7648. * Register and execute a render loop. The engine can have more than one render function
  7649. * @param renderFunction defines the function to continuously execute
  7650. */
  7651. runRenderLoop(renderFunction: () => void): void;
  7652. /**
  7653. * Toggle full screen mode
  7654. * @param requestPointerLock defines if a pointer lock should be requested from the user
  7655. * @param options defines an option object to be sent to the requestFullscreen function
  7656. */
  7657. switchFullscreen(requestPointerLock: boolean): void;
  7658. /**
  7659. * Clear the current render buffer or the current render target (if any is set up)
  7660. * @param color defines the color to use
  7661. * @param backBuffer defines if the back buffer must be cleared
  7662. * @param depth defines if the depth buffer must be cleared
  7663. * @param stencil defines if the stencil buffer must be cleared
  7664. */
  7665. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  7666. /**
  7667. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  7668. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  7669. * @param y defines the y-coordinate of the corner of the clear rectangle
  7670. * @param width defines the width of the clear rectangle
  7671. * @param height defines the height of the clear rectangle
  7672. * @param clearColor defines the clear color
  7673. */
  7674. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  7675. /**
  7676. * Set the WebGL's viewport
  7677. * @param viewport defines the viewport element to be used
  7678. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  7679. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  7680. */
  7681. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  7682. /**
  7683. * Directly set the WebGL Viewport
  7684. * @param x defines the x coordinate of the viewport (in screen space)
  7685. * @param y defines the y coordinate of the viewport (in screen space)
  7686. * @param width defines the width of the viewport (in screen space)
  7687. * @param height defines the height of the viewport (in screen space)
  7688. * @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
  7689. */
  7690. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  7691. /**
  7692. * Begin a new frame
  7693. */
  7694. beginFrame(): void;
  7695. /**
  7696. * Enf the current frame
  7697. */
  7698. endFrame(): void;
  7699. /**
  7700. * Resize the view according to the canvas' size
  7701. */
  7702. resize(): void;
  7703. /**
  7704. * Force a specific size of the canvas
  7705. * @param width defines the new canvas' width
  7706. * @param height defines the new canvas' height
  7707. */
  7708. setSize(width: number, height: number): void;
  7709. /**
  7710. * Gets a boolean indicating if a webVR device was detected
  7711. * @returns true if a webVR device was detected
  7712. */
  7713. isVRDevicePresent(): boolean;
  7714. /**
  7715. * Gets the current webVR device
  7716. * @returns the current webVR device (or null)
  7717. */
  7718. getVRDevice(): any;
  7719. /**
  7720. * Initializes a webVR display and starts listening to display change events
  7721. * The onVRDisplayChangedObservable will be notified upon these changes
  7722. * @returns The onVRDisplayChangedObservable
  7723. */
  7724. initWebVR(): Observable<IDisplayChangedEventArgs>;
  7725. /**
  7726. * Initializes a webVR display and starts listening to display change events
  7727. * The onVRDisplayChangedObservable will be notified upon these changes
  7728. * @returns A promise containing a VRDisplay and if vr is supported
  7729. */
  7730. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  7731. /**
  7732. * Call this function to switch to webVR mode
  7733. * Will do nothing if webVR is not supported or if there is no webVR device
  7734. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7735. */
  7736. enableVR(): void;
  7737. /**
  7738. * Call this function to leave webVR mode
  7739. * Will do nothing if webVR is not supported or if there is no webVR device
  7740. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7741. */
  7742. disableVR(): void;
  7743. private _onVRFullScreenTriggered;
  7744. private _getVRDisplaysAsync();
  7745. /**
  7746. * Binds the frame buffer to the specified texture.
  7747. * @param texture The texture to render to or null for the default canvas
  7748. * @param faceIndex The face of the texture to render to in case of cube texture
  7749. * @param requiredWidth The width of the target to render to
  7750. * @param requiredHeight The height of the target to render to
  7751. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  7752. * @param depthStencilTexture The depth stencil texture to use to render
  7753. */
  7754. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture): void;
  7755. private bindUnboundFramebuffer(framebuffer);
  7756. /**
  7757. * Unbind the current render target texture from the webGL context
  7758. * @param texture defines the render target texture to unbind
  7759. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7760. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7761. */
  7762. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7763. /**
  7764. * Unbind a list of render target textures from the webGL context
  7765. * This is used only when drawBuffer extension or webGL2 are active
  7766. * @param textures defines the render target textures to unbind
  7767. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  7768. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  7769. */
  7770. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  7771. /**
  7772. * Force the mipmap generation for the given render target texture
  7773. * @param texture defines the render target texture to use
  7774. */
  7775. generateMipMapsForCubemap(texture: InternalTexture): void;
  7776. /**
  7777. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  7778. */
  7779. flushFramebuffer(): void;
  7780. /**
  7781. * Unbind the current render target and bind the default framebuffer
  7782. */
  7783. restoreDefaultFramebuffer(): void;
  7784. /**
  7785. * Create an uniform buffer
  7786. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7787. * @param elements defines the content of the uniform buffer
  7788. * @returns the webGL uniform buffer
  7789. */
  7790. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  7791. /**
  7792. * Create a dynamic uniform buffer
  7793. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7794. * @param elements defines the content of the uniform buffer
  7795. * @returns the webGL uniform buffer
  7796. */
  7797. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  7798. /**
  7799. * Update an existing uniform buffer
  7800. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7801. * @param uniformBuffer defines the target uniform buffer
  7802. * @param elements defines the content to update
  7803. * @param offset defines the offset in the uniform buffer where update should start
  7804. * @param count defines the size of the data to update
  7805. */
  7806. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7807. private _resetVertexBufferBinding();
  7808. /**
  7809. * Creates a vertex buffer
  7810. * @param data the data for the vertex buffer
  7811. * @returns the new WebGL static buffer
  7812. */
  7813. createVertexBuffer(data: DataArray): WebGLBuffer;
  7814. /**
  7815. * Creates a dynamic vertex buffer
  7816. * @param data the data for the dynamic vertex buffer
  7817. * @returns the new WebGL dynamic buffer
  7818. */
  7819. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  7820. /**
  7821. * Update a dynamic index buffer
  7822. * @param indexBuffer defines the target index buffer
  7823. * @param indices defines the data to update
  7824. * @param offset defines the offset in the target index buffer where update should start
  7825. */
  7826. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  7827. /**
  7828. * Updates a dynamic vertex buffer.
  7829. * @param vertexBuffer the vertex buffer to update
  7830. * @param data the data used to update the vertex buffer
  7831. * @param byteOffset the byte offset of the data
  7832. * @param byteLength the byte length of the data
  7833. */
  7834. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  7835. private _resetIndexBufferBinding();
  7836. /**
  7837. * Creates a new index buffer
  7838. * @param indices defines the content of the index buffer
  7839. * @param updatable defines if the index buffer must be updatable
  7840. * @returns a new webGL buffer
  7841. */
  7842. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  7843. /**
  7844. * Bind a webGL buffer to the webGL context
  7845. * @param buffer defines the buffer to bind
  7846. */
  7847. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  7848. /**
  7849. * Bind an uniform buffer to the current webGL context
  7850. * @param buffer defines the buffer to bind
  7851. */
  7852. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  7853. /**
  7854. * Bind a buffer to the current webGL context at a given location
  7855. * @param buffer defines the buffer to bind
  7856. * @param location defines the index where to bind the buffer
  7857. */
  7858. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  7859. /**
  7860. * Bind a specific block at a given index in a specific shader program
  7861. * @param shaderProgram defines the shader program
  7862. * @param blockName defines the block name
  7863. * @param index defines the index where to bind the block
  7864. */
  7865. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  7866. private bindIndexBuffer(buffer);
  7867. private bindBuffer(buffer, target);
  7868. /**
  7869. * update the bound buffer with the given data
  7870. * @param data defines the data to update
  7871. */
  7872. updateArrayBuffer(data: Float32Array): void;
  7873. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  7874. private _bindIndexBufferWithCache(indexBuffer);
  7875. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  7876. /**
  7877. * Records a vertex array object
  7878. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7879. * @param vertexBuffers defines the list of vertex buffers to store
  7880. * @param indexBuffer defines the index buffer to store
  7881. * @param effect defines the effect to store
  7882. * @returns the new vertex array object
  7883. */
  7884. recordVertexArrayObject(vertexBuffers: {
  7885. [key: string]: VertexBuffer;
  7886. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  7887. /**
  7888. * Bind a specific vertex array object
  7889. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  7890. * @param vertexArrayObject defines the vertex array object to bind
  7891. * @param indexBuffer defines the index buffer to bind
  7892. */
  7893. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  7894. /**
  7895. * Bind webGl buffers directly to the webGL context
  7896. * @param vertexBuffer defines the vertex buffer to bind
  7897. * @param indexBuffer defines the index buffer to bind
  7898. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  7899. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  7900. * @param effect defines the effect associated with the vertex buffer
  7901. */
  7902. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  7903. private _unbindVertexArrayObject();
  7904. /**
  7905. * Bind a list of vertex buffers to the webGL context
  7906. * @param vertexBuffers defines the list of vertex buffers to bind
  7907. * @param indexBuffer defines the index buffer to bind
  7908. * @param effect defines the effect associated with the vertex buffers
  7909. */
  7910. bindBuffers(vertexBuffers: {
  7911. [key: string]: Nullable<VertexBuffer>;
  7912. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  7913. /**
  7914. * Unbind all instance attributes
  7915. */
  7916. unbindInstanceAttributes(): void;
  7917. /**
  7918. * Release and free the memory of a vertex array object
  7919. * @param vao defines the vertex array object to delete
  7920. */
  7921. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  7922. /** @hidden */
  7923. _releaseBuffer(buffer: WebGLBuffer): boolean;
  7924. /**
  7925. * Creates a webGL buffer to use with instanciation
  7926. * @param capacity defines the size of the buffer
  7927. * @returns the webGL buffer
  7928. */
  7929. createInstancesBuffer(capacity: number): WebGLBuffer;
  7930. /**
  7931. * Delete a webGL buffer used with instanciation
  7932. * @param buffer defines the webGL buffer to delete
  7933. */
  7934. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  7935. /**
  7936. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  7937. * @param instancesBuffer defines the webGL buffer to update and bind
  7938. * @param data defines the data to store in the buffer
  7939. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  7940. */
  7941. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  7942. /**
  7943. * Apply all cached states (depth, culling, stencil and alpha)
  7944. */
  7945. applyStates(): void;
  7946. /**
  7947. * Send a draw order
  7948. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7949. * @param indexStart defines the starting index
  7950. * @param indexCount defines the number of index to draw
  7951. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7952. */
  7953. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  7954. /**
  7955. * Draw a list of points
  7956. * @param verticesStart defines the index of first vertex to draw
  7957. * @param verticesCount defines the count of vertices to draw
  7958. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7959. */
  7960. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7961. /**
  7962. * Draw a list of unindexed primitives
  7963. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  7964. * @param verticesStart defines the index of first vertex to draw
  7965. * @param verticesCount defines the count of vertices to draw
  7966. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7967. */
  7968. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7969. /**
  7970. * Draw a list of indexed primitives
  7971. * @param fillMode defines the primitive to use
  7972. * @param indexStart defines the starting index
  7973. * @param indexCount defines the number of index to draw
  7974. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7975. */
  7976. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  7977. /**
  7978. * Draw a list of unindexed primitives
  7979. * @param fillMode defines the primitive to use
  7980. * @param verticesStart defines the index of first vertex to draw
  7981. * @param verticesCount defines the count of vertices to draw
  7982. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  7983. */
  7984. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  7985. private _drawMode(fillMode);
  7986. /** @hidden */
  7987. _releaseEffect(effect: Effect): void;
  7988. /** @hidden */
  7989. _deleteProgram(program: WebGLProgram): void;
  7990. /**
  7991. * Create a new effect (used to store vertex/fragment shaders)
  7992. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  7993. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  7994. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  7995. * @param samplers defines an array of string used to represent textures
  7996. * @param defines defines the string containing the defines to use to compile the shaders
  7997. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  7998. * @param onCompiled defines a function to call when the effect creation is successful
  7999. * @param onError defines a function to call when the effect creation has failed
  8000. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  8001. * @returns the new Effect
  8002. */
  8003. 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;
  8004. /**
  8005. * Create an effect to use with particle systems
  8006. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  8007. * @param uniformsNames defines a list of attribute names
  8008. * @param samplers defines an array of string used to represent textures
  8009. * @param defines defines the string containing the defines to use to compile the shaders
  8010. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8011. * @param onCompiled defines a function to call when the effect creation is successful
  8012. * @param onError defines a function to call when the effect creation has failed
  8013. * @returns the new Effect
  8014. */
  8015. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  8016. /**
  8017. * Directly creates a webGL program
  8018. * @param vertexCode defines the vertex shader code to use
  8019. * @param fragmentCode defines the fragment shader code to use
  8020. * @param context defines the webGL context to use (if not set, the current one will be used)
  8021. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8022. * @returns the new webGL program
  8023. */
  8024. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8025. /**
  8026. * Creates a webGL program
  8027. * @param vertexCode defines the vertex shader code to use
  8028. * @param fragmentCode defines the fragment shader code to use
  8029. * @param defines defines the string containing the defines to use to compile the shaders
  8030. * @param context defines the webGL context to use (if not set, the current one will be used)
  8031. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8032. * @returns the new webGL program
  8033. */
  8034. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8035. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  8036. /**
  8037. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  8038. * @param shaderProgram defines the webGL program to use
  8039. * @param uniformsNames defines the list of uniform names
  8040. * @returns an array of webGL uniform locations
  8041. */
  8042. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  8043. /**
  8044. * Gets the lsit of active attributes for a given webGL program
  8045. * @param shaderProgram defines the webGL program to use
  8046. * @param attributesNames defines the list of attribute names to get
  8047. * @returns an array of indices indicating the offset of each attribute
  8048. */
  8049. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8050. /**
  8051. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  8052. * @param effect defines the effect to activate
  8053. */
  8054. enableEffect(effect: Nullable<Effect>): void;
  8055. /**
  8056. * Set the value of an uniform to an array of int32
  8057. * @param uniform defines the webGL uniform location where to store the value
  8058. * @param array defines the array of int32 to store
  8059. */
  8060. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8061. /**
  8062. * Set the value of an uniform to an array of int32 (stored as vec2)
  8063. * @param uniform defines the webGL uniform location where to store the value
  8064. * @param array defines the array of int32 to store
  8065. */
  8066. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8067. /**
  8068. * Set the value of an uniform to an array of int32 (stored as vec3)
  8069. * @param uniform defines the webGL uniform location where to store the value
  8070. * @param array defines the array of int32 to store
  8071. */
  8072. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8073. /**
  8074. * Set the value of an uniform to an array of int32 (stored as vec4)
  8075. * @param uniform defines the webGL uniform location where to store the value
  8076. * @param array defines the array of int32 to store
  8077. */
  8078. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8079. /**
  8080. * Set the value of an uniform to an array of float32
  8081. * @param uniform defines the webGL uniform location where to store the value
  8082. * @param array defines the array of float32 to store
  8083. */
  8084. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8085. /**
  8086. * Set the value of an uniform to an array of float32 (stored as vec2)
  8087. * @param uniform defines the webGL uniform location where to store the value
  8088. * @param array defines the array of float32 to store
  8089. */
  8090. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8091. /**
  8092. * Set the value of an uniform to an array of float32 (stored as vec3)
  8093. * @param uniform defines the webGL uniform location where to store the value
  8094. * @param array defines the array of float32 to store
  8095. */
  8096. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8097. /**
  8098. * Set the value of an uniform to an array of float32 (stored as vec4)
  8099. * @param uniform defines the webGL uniform location where to store the value
  8100. * @param array defines the array of float32 to store
  8101. */
  8102. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8103. /**
  8104. * Set the value of an uniform to an array of number
  8105. * @param uniform defines the webGL uniform location where to store the value
  8106. * @param array defines the array of number to store
  8107. */
  8108. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8109. /**
  8110. * Set the value of an uniform to an array of number (stored as vec2)
  8111. * @param uniform defines the webGL uniform location where to store the value
  8112. * @param array defines the array of number to store
  8113. */
  8114. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8115. /**
  8116. * Set the value of an uniform to an array of number (stored as vec3)
  8117. * @param uniform defines the webGL uniform location where to store the value
  8118. * @param array defines the array of number to store
  8119. */
  8120. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8121. /**
  8122. * Set the value of an uniform to an array of number (stored as vec4)
  8123. * @param uniform defines the webGL uniform location where to store the value
  8124. * @param array defines the array of number to store
  8125. */
  8126. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8127. /**
  8128. * Set the value of an uniform to an array of float32 (stored as matrices)
  8129. * @param uniform defines the webGL uniform location where to store the value
  8130. * @param matrices defines the array of float32 to store
  8131. */
  8132. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  8133. /**
  8134. * Set the value of an uniform to a matrix
  8135. * @param uniform defines the webGL uniform location where to store the value
  8136. * @param matrix defines the matrix to store
  8137. */
  8138. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  8139. /**
  8140. * Set the value of an uniform to a matrix (3x3)
  8141. * @param uniform defines the webGL uniform location where to store the value
  8142. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8143. */
  8144. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8145. /**
  8146. * Set the value of an uniform to a matrix (2x2)
  8147. * @param uniform defines the webGL uniform location where to store the value
  8148. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8149. */
  8150. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8151. /**
  8152. * Set the value of an uniform to a number (int)
  8153. * @param uniform defines the webGL uniform location where to store the value
  8154. * @param value defines the int number to store
  8155. */
  8156. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8157. /**
  8158. * Set the value of an uniform to a number (float)
  8159. * @param uniform defines the webGL uniform location where to store the value
  8160. * @param value defines the float number to store
  8161. */
  8162. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8163. /**
  8164. * Set the value of an uniform to a vec2
  8165. * @param uniform defines the webGL uniform location where to store the value
  8166. * @param x defines the 1st component of the value
  8167. * @param y defines the 2nd component of the value
  8168. */
  8169. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8170. /**
  8171. * Set the value of an uniform to a vec3
  8172. * @param uniform defines the webGL uniform location where to store the value
  8173. * @param x defines the 1st component of the value
  8174. * @param y defines the 2nd component of the value
  8175. * @param z defines the 3rd component of the value
  8176. */
  8177. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8178. /**
  8179. * Set the value of an uniform to a boolean
  8180. * @param uniform defines the webGL uniform location where to store the value
  8181. * @param bool defines the boolean to store
  8182. */
  8183. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8184. /**
  8185. * Set the value of an uniform to a vec4
  8186. * @param uniform defines the webGL uniform location where to store the value
  8187. * @param x defines the 1st component of the value
  8188. * @param y defines the 2nd component of the value
  8189. * @param z defines the 3rd component of the value
  8190. * @param w defines the 4th component of the value
  8191. */
  8192. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8193. /**
  8194. * Set the value of an uniform to a Color3
  8195. * @param uniform defines the webGL uniform location where to store the value
  8196. * @param color3 defines the color to store
  8197. */
  8198. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8199. /**
  8200. * Set the value of an uniform to a Color3 and an alpha value
  8201. * @param uniform defines the webGL uniform location where to store the value
  8202. * @param color3 defines the color to store
  8203. * @param alpha defines the alpha component to store
  8204. */
  8205. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8206. /**
  8207. * Sets a Color4 on a uniform variable
  8208. * @param uniform defines the uniform location
  8209. * @param color4 defines the value to be set
  8210. */
  8211. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8212. /**
  8213. * Set various states to the webGL context
  8214. * @param culling defines backface culling state
  8215. * @param zOffset defines the value to apply to zOffset (0 by default)
  8216. * @param force defines if states must be applied even if cache is up to date
  8217. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8218. */
  8219. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8220. /**
  8221. * Set the z offset to apply to current rendering
  8222. * @param value defines the offset to apply
  8223. */
  8224. setZOffset(value: number): void;
  8225. /**
  8226. * Gets the current value of the zOffset
  8227. * @returns the current zOffset state
  8228. */
  8229. getZOffset(): number;
  8230. /**
  8231. * Enable or disable depth buffering
  8232. * @param enable defines the state to set
  8233. */
  8234. setDepthBuffer(enable: boolean): void;
  8235. /**
  8236. * Gets a boolean indicating if depth writing is enabled
  8237. * @returns the current depth writing state
  8238. */
  8239. getDepthWrite(): boolean;
  8240. /**
  8241. * Enable or disable depth writing
  8242. * @param enable defines the state to set
  8243. */
  8244. setDepthWrite(enable: boolean): void;
  8245. /**
  8246. * Enable or disable color writing
  8247. * @param enable defines the state to set
  8248. */
  8249. setColorWrite(enable: boolean): void;
  8250. /**
  8251. * Gets a boolean indicating if color writing is enabled
  8252. * @returns the current color writing state
  8253. */
  8254. getColorWrite(): boolean;
  8255. /**
  8256. * Sets alpha constants used by some alpha blending modes
  8257. * @param r defines the red component
  8258. * @param g defines the green component
  8259. * @param b defines the blue component
  8260. * @param a defines the alpha component
  8261. */
  8262. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8263. /**
  8264. * Sets the current alpha mode
  8265. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8266. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8267. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8268. */
  8269. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8270. /**
  8271. * Gets the current alpha mode
  8272. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8273. * @returns the current alpha mode
  8274. */
  8275. getAlphaMode(): number;
  8276. /**
  8277. * Force the entire cache to be cleared
  8278. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8279. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8280. */
  8281. wipeCaches(bruteForce?: boolean): void;
  8282. /**
  8283. * Set the compressed texture format to use, based on the formats you have, and the formats
  8284. * supported by the hardware / browser.
  8285. *
  8286. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8287. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8288. * to API arguments needed to compressed textures. This puts the burden on the container
  8289. * generator to house the arcane code for determining these for current & future formats.
  8290. *
  8291. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8292. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8293. *
  8294. * Note: The result of this call is not taken into account when a texture is base64.
  8295. *
  8296. * @param formatsAvailable defines the list of those format families you have created
  8297. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8298. *
  8299. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8300. * @returns The extension selected.
  8301. */
  8302. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8303. /** @hidden */
  8304. _createTexture(): WebGLTexture;
  8305. /**
  8306. * Usually called from BABYLON.Texture.ts.
  8307. * Passed information to create a WebGLTexture
  8308. * @param urlArg defines a value which contains one of the following:
  8309. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8310. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8311. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8312. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8313. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8314. * @param scene needed for loading to the correct scene
  8315. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8316. * @param onLoad optional callback to be called upon successful completion
  8317. * @param onError optional callback to be called upon failure
  8318. * @param buffer a source of a file previously fetched as either an ArrayBuffer (compressed or image format) or HTMLImageElement (image format)
  8319. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8320. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8321. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8322. */
  8323. 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<ArrayBuffer | HTMLImageElement>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>): InternalTexture;
  8324. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  8325. /**
  8326. * Update a raw texture
  8327. * @param texture defines the texture to update
  8328. * @param data defines the data to store in the texture
  8329. * @param format defines the format of the data
  8330. * @param invertY defines if data must be stored with Y axis inverted
  8331. * @param compression defines the compression used (null by default)
  8332. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8333. */
  8334. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8335. /**
  8336. * Creates a raw texture
  8337. * @param data defines the data to store in the texture
  8338. * @param width defines the width of the texture
  8339. * @param height defines the height of the texture
  8340. * @param format defines the format of the data
  8341. * @param generateMipMaps defines if the engine should generate the mip levels
  8342. * @param invertY defines if data must be stored with Y axis inverted
  8343. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8344. * @param compression defines the compression used (null by default)
  8345. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8346. * @returns the raw texture inside an InternalTexture
  8347. */
  8348. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8349. /**
  8350. * Creates a dynamic texture
  8351. * @param width defines the width of the texture
  8352. * @param height defines the height of the texture
  8353. * @param generateMipMaps defines if the engine should generate the mip levels
  8354. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8355. * @returns the dynamic texture inside an InternalTexture
  8356. */
  8357. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8358. /**
  8359. * Update the sampling mode of a given texture
  8360. * @param samplingMode defines the required sampling mode
  8361. * @param texture defines the texture to update
  8362. */
  8363. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8364. /**
  8365. * Update the content of a dynamic texture
  8366. * @param texture defines the texture to update
  8367. * @param canvas defines the canvas containing the source
  8368. * @param invertY defines if data must be stored with Y axis inverted
  8369. * @param premulAlpha defines if alpha is stored as premultiplied
  8370. * @param format defines the format of the data
  8371. */
  8372. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8373. /**
  8374. * Update a video texture
  8375. * @param texture defines the texture to update
  8376. * @param video defines the video element to use
  8377. * @param invertY defines if data must be stored with Y axis inverted
  8378. */
  8379. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8380. /**
  8381. * Updates a depth texture Comparison Mode and Function.
  8382. * If the comparison Function is equal to 0, the mode will be set to none.
  8383. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8384. * @param texture The texture to set the comparison function for
  8385. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8386. */
  8387. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8388. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  8389. /**
  8390. * Creates a depth stencil texture.
  8391. * This is only available in WebGL 2 or with the depth texture extension available.
  8392. * @param size The size of face edge in the texture.
  8393. * @param options The options defining the texture.
  8394. * @returns The texture
  8395. */
  8396. createDepthStencilTexture(size: number | {
  8397. width: number;
  8398. height: number;
  8399. }, options: DepthTextureCreationOptions): InternalTexture;
  8400. /**
  8401. * Creates a depth stencil texture.
  8402. * This is only available in WebGL 2 or with the depth texture extension available.
  8403. * @param size The size of face edge in the texture.
  8404. * @param options The options defining the texture.
  8405. * @returns The texture
  8406. */
  8407. private _createDepthStencilTexture(size, options);
  8408. /**
  8409. * Creates a depth stencil cube texture.
  8410. * This is only available in WebGL 2.
  8411. * @param size The size of face edge in the cube texture.
  8412. * @param options The options defining the cube texture.
  8413. * @returns The cube texture
  8414. */
  8415. private _createDepthStencilCubeTexture(size, options);
  8416. /**
  8417. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8418. * @param renderTarget The render target to set the frame buffer for
  8419. */
  8420. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8421. /**
  8422. * Creates a new render target texture
  8423. * @param size defines the size of the texture
  8424. * @param options defines the options used to create the texture
  8425. * @returns a new render target texture stored in an InternalTexture
  8426. */
  8427. createRenderTargetTexture(size: number | {
  8428. width: number;
  8429. height: number;
  8430. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8431. /**
  8432. * Create a multi render target texture
  8433. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8434. * @param size defines the size of the texture
  8435. * @param options defines the creation options
  8436. * @returns the cube texture as an InternalTexture
  8437. */
  8438. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8439. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  8440. /**
  8441. * Updates the sample count of a render target texture
  8442. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8443. * @param texture defines the texture to update
  8444. * @param samples defines the sample count to set
  8445. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8446. */
  8447. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8448. /**
  8449. * Update the sample count for a given multiple render target texture
  8450. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8451. * @param textures defines the textures to update
  8452. * @param samples defines the sample count to set
  8453. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8454. */
  8455. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8456. /** @hidden */
  8457. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  8458. /** @hidden */
  8459. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  8460. /**
  8461. * Creates a new render target cube texture
  8462. * @param size defines the size of the texture
  8463. * @param options defines the options used to create the texture
  8464. * @returns a new render target cube texture stored in an InternalTexture
  8465. */
  8466. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8467. /**
  8468. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8469. * @param rootUrl defines the url where the file to load is located
  8470. * @param scene defines the current scene
  8471. * @param scale defines scale to apply to the mip map selection
  8472. * @param offset defines offset to apply to the mip map selection
  8473. * @param onLoad defines an optional callback raised when the texture is loaded
  8474. * @param onError defines an optional callback raised if there is an issue to load the texture
  8475. * @param format defines the format of the data
  8476. * @param forcedExtension defines the extension to use to pick the right loader
  8477. * @returns the cube texture as an InternalTexture
  8478. */
  8479. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, scale: number, offset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any): InternalTexture;
  8480. /**
  8481. * Creates a cube texture
  8482. * @param rootUrl defines the url where the files to load is located
  8483. * @param scene defines the current scene
  8484. * @param files defines the list of files to load (1 per face)
  8485. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8486. * @param onLoad defines an optional callback raised when the texture is loaded
  8487. * @param onError defines an optional callback raised if there is an issue to load the texture
  8488. * @param format defines the format of the data
  8489. * @param forcedExtension defines the extension to use to pick the right loader
  8490. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8491. * @returns the cube texture as an InternalTexture
  8492. */
  8493. 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;
  8494. private setCubeMapTextureParams(gl, loadMipmap);
  8495. /**
  8496. * Update a raw cube texture
  8497. * @param texture defines the texture to udpdate
  8498. * @param data defines the data to store
  8499. * @param format defines the data format
  8500. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8501. * @param invertY defines if data must be stored with Y axis inverted
  8502. * @param compression defines the compression used (null by default)
  8503. * @param level defines which level of the texture to update
  8504. */
  8505. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  8506. /**
  8507. * Creates a new raw cube texture
  8508. * @param data defines the array of data to use to create each face
  8509. * @param size defines the size of the textures
  8510. * @param format defines the format of the data
  8511. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8512. * @param generateMipMaps defines if the engine should generate the mip levels
  8513. * @param invertY defines if data must be stored with Y axis inverted
  8514. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8515. * @param compression defines the compression used (null by default)
  8516. * @returns the cube texture as an InternalTexture
  8517. */
  8518. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8519. /**
  8520. * Creates a new raw cube texture from a specified url
  8521. * @param url defines the url where the data is located
  8522. * @param scene defines the current scene
  8523. * @param size defines the size of the textures
  8524. * @param format defines the format of the data
  8525. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8526. * @param noMipmap defines if the engine should avoid generating the mip levels
  8527. * @param callback defines a callback used to extract texture data from loaded data
  8528. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  8529. * @param onLoad defines a callback called when texture is loaded
  8530. * @param onError defines a callback called if there is an error
  8531. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8532. * @param invertY defines if data must be stored with Y axis inverted
  8533. * @returns the cube texture as an InternalTexture
  8534. */
  8535. 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;
  8536. /**
  8537. * Update a raw 3D texture
  8538. * @param texture defines the texture to update
  8539. * @param data defines the data to store
  8540. * @param format defines the data format
  8541. * @param invertY defines if data must be stored with Y axis inverted
  8542. * @param compression defines the used compression (can be null)
  8543. */
  8544. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>): void;
  8545. /**
  8546. * Creates a new raw 3D texture
  8547. * @param data defines the data used to create the texture
  8548. * @param width defines the width of the texture
  8549. * @param height defines the height of the texture
  8550. * @param depth defines the depth of the texture
  8551. * @param format defines the format of the texture
  8552. * @param generateMipMaps defines if the engine must generate mip levels
  8553. * @param invertY defines if data must be stored with Y axis inverted
  8554. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8555. * @param compression defines the compressed used (can be null)
  8556. * @returns a new raw 3D texture (stored in an InternalTexture)
  8557. */
  8558. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8559. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  8560. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  8561. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  8562. /** @hidden */
  8563. _releaseFramebufferObjects(texture: InternalTexture): void;
  8564. /** @hidden */
  8565. _releaseTexture(texture: InternalTexture): void;
  8566. private setProgram(program);
  8567. private _boundUniforms;
  8568. /**
  8569. * Binds an effect to the webGL context
  8570. * @param effect defines the effect to bind
  8571. */
  8572. bindSamplers(effect: Effect): void;
  8573. private _moveBoundTextureOnTop(internalTexture);
  8574. private _getCorrectTextureChannel(channel, internalTexture);
  8575. private _linkTrackers(previous, next);
  8576. private _removeDesignatedSlot(internalTexture);
  8577. private _activateCurrentTexture();
  8578. /** @hidden */
  8579. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): void;
  8580. /** @hidden */
  8581. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  8582. /**
  8583. * Sets a texture to the webGL context from a postprocess
  8584. * @param channel defines the channel to use
  8585. * @param postProcess defines the source postprocess
  8586. */
  8587. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  8588. /**
  8589. * Binds the output of the passed in post process to the texture channel specified
  8590. * @param channel The channel the texture should be bound to
  8591. * @param postProcess The post process which's output should be bound
  8592. */
  8593. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  8594. /**
  8595. * Unbind all textures from the webGL context
  8596. */
  8597. unbindAllTextures(): void;
  8598. /**
  8599. * Sets a texture to the according uniform.
  8600. * @param channel The texture channel
  8601. * @param uniform The uniform to set
  8602. * @param texture The texture to apply
  8603. */
  8604. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  8605. /**
  8606. * Sets a depth stencil texture from a render target to the according uniform.
  8607. * @param channel The texture channel
  8608. * @param uniform The uniform to set
  8609. * @param texture The render target texture containing the depth stencil texture to apply
  8610. */
  8611. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  8612. private _bindSamplerUniformToChannel(sourceSlot, destination);
  8613. private _getTextureWrapMode(mode);
  8614. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  8615. /**
  8616. * Sets an array of texture to the webGL context
  8617. * @param channel defines the channel where the texture array must be set
  8618. * @param uniform defines the associated uniform location
  8619. * @param textures defines the array of textures to bind
  8620. */
  8621. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  8622. /** @hidden */
  8623. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  8624. private _setTextureParameterFloat(target, parameter, value, texture);
  8625. private _setTextureParameterInteger(target, parameter, value, texture?);
  8626. /**
  8627. * Reads pixels from the current frame buffer. Please note that this function can be slow
  8628. * @param x defines the x coordinate of the rectangle where pixels must be read
  8629. * @param y defines the y coordinate of the rectangle where pixels must be read
  8630. * @param width defines the width of the rectangle where pixels must be read
  8631. * @param height defines the height of the rectangle where pixels must be read
  8632. * @returns a Uint8Array containing RGBA colors
  8633. */
  8634. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  8635. /**
  8636. * Add an externaly attached data from its key.
  8637. * This method call will fail and return false, if such key already exists.
  8638. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  8639. * @param key the unique key that identifies the data
  8640. * @param data the data object to associate to the key for this Engine instance
  8641. * @return true if no such key were already present and the data was added successfully, false otherwise
  8642. */
  8643. addExternalData<T>(key: string, data: T): boolean;
  8644. /**
  8645. * Get an externaly attached data from its key
  8646. * @param key the unique key that identifies the data
  8647. * @return the associated data, if present (can be null), or undefined if not present
  8648. */
  8649. getExternalData<T>(key: string): T;
  8650. /**
  8651. * Get an externaly attached data from its key, create it using a factory if it's not already present
  8652. * @param key the unique key that identifies the data
  8653. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  8654. * @return the associated data, can be null if the factory returned null.
  8655. */
  8656. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  8657. /**
  8658. * Remove an externaly attached data from the Engine instance
  8659. * @param key the unique key that identifies the data
  8660. * @return true if the data was successfully removed, false if it doesn't exist
  8661. */
  8662. removeExternalData(key: string): boolean;
  8663. /**
  8664. * Unbind all vertex attributes from the webGL context
  8665. */
  8666. unbindAllAttributes(): void;
  8667. /**
  8668. * 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
  8669. */
  8670. releaseEffects(): void;
  8671. /**
  8672. * Dispose and release all associated resources
  8673. */
  8674. dispose(): void;
  8675. /**
  8676. * Display the loading screen
  8677. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8678. */
  8679. displayLoadingUI(): void;
  8680. /**
  8681. * Hide the loading screen
  8682. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8683. */
  8684. hideLoadingUI(): void;
  8685. /**
  8686. * Gets the current loading screen object
  8687. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8688. */
  8689. /**
  8690. * Sets the current loading screen object
  8691. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8692. */
  8693. loadingScreen: ILoadingScreen;
  8694. /**
  8695. * Sets the current loading screen text
  8696. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8697. */
  8698. loadingUIText: string;
  8699. /**
  8700. * Sets the current loading screen background color
  8701. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  8702. */
  8703. loadingUIBackgroundColor: string;
  8704. /**
  8705. * Attach a new callback raised when context lost event is fired
  8706. * @param callback defines the callback to call
  8707. */
  8708. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8709. /**
  8710. * Attach a new callback raised when context restored event is fired
  8711. * @param callback defines the callback to call
  8712. */
  8713. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  8714. /**
  8715. * Gets the source code of the vertex shader associated with a specific webGL program
  8716. * @param program defines the program to use
  8717. * @returns a string containing the source code of the vertex shader associated with the program
  8718. */
  8719. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  8720. /**
  8721. * Gets the source code of the fragment shader associated with a specific webGL program
  8722. * @param program defines the program to use
  8723. * @returns a string containing the source code of the fragment shader associated with the program
  8724. */
  8725. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  8726. /**
  8727. * Get the current error code of the webGL context
  8728. * @returns the error code
  8729. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  8730. */
  8731. getError(): number;
  8732. /**
  8733. * Gets the current framerate
  8734. * @returns a number representing the framerate
  8735. */
  8736. getFps(): number;
  8737. /**
  8738. * Gets the time spent between current and previous frame
  8739. * @returns a number representing the delta time in ms
  8740. */
  8741. getDeltaTime(): number;
  8742. private _measureFps();
  8743. /** @hidden */
  8744. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number): ArrayBufferView;
  8745. private _canRenderToFloatFramebuffer();
  8746. private _canRenderToHalfFloatFramebuffer();
  8747. private _canRenderToFramebuffer(type);
  8748. /** @hidden */
  8749. _getWebGLTextureType(type: number): number;
  8750. private _getInternalFormat(format);
  8751. /** @hidden */
  8752. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  8753. /** @hidden */
  8754. _getRGBAMultiSampleBufferFormat(type: number): number;
  8755. /**
  8756. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  8757. * @return the new query
  8758. */
  8759. createQuery(): WebGLQuery;
  8760. /**
  8761. * Delete and release a webGL query
  8762. * @param query defines the query to delete
  8763. * @return the current engine
  8764. */
  8765. deleteQuery(query: WebGLQuery): Engine;
  8766. /**
  8767. * Check if a given query has resolved and got its value
  8768. * @param query defines the query to check
  8769. * @returns true if the query got its value
  8770. */
  8771. isQueryResultAvailable(query: WebGLQuery): boolean;
  8772. /**
  8773. * Gets the value of a given query
  8774. * @param query defines the query to check
  8775. * @returns the value of the query
  8776. */
  8777. getQueryResult(query: WebGLQuery): number;
  8778. /**
  8779. * Initiates an occlusion query
  8780. * @param algorithmType defines the algorithm to use
  8781. * @param query defines the query to use
  8782. * @returns the current engine
  8783. * @see http://doc.babylonjs.com/features/occlusionquery
  8784. */
  8785. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  8786. /**
  8787. * Ends an occlusion query
  8788. * @see http://doc.babylonjs.com/features/occlusionquery
  8789. * @param algorithmType defines the algorithm to use
  8790. * @returns the current engine
  8791. */
  8792. endOcclusionQuery(algorithmType: number): Engine;
  8793. private _createTimeQuery();
  8794. private _deleteTimeQuery(query);
  8795. private _getTimeQueryResult(query);
  8796. private _getTimeQueryAvailability(query);
  8797. private _currentNonTimestampToken;
  8798. /**
  8799. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  8800. * Please note that only one query can be issued at a time
  8801. * @returns a time token used to track the time span
  8802. */
  8803. startTimeQuery(): Nullable<_TimeToken>;
  8804. /**
  8805. * Ends a time query
  8806. * @param token defines the token used to measure the time span
  8807. * @returns the time spent (in ns)
  8808. */
  8809. endTimeQuery(token: _TimeToken): int;
  8810. private getGlAlgorithmType(algorithmType);
  8811. /**
  8812. * Creates a webGL transform feedback object
  8813. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  8814. * @returns the webGL transform feedback object
  8815. */
  8816. createTransformFeedback(): WebGLTransformFeedback;
  8817. /**
  8818. * Delete a webGL transform feedback object
  8819. * @param value defines the webGL transform feedback object to delete
  8820. */
  8821. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  8822. /**
  8823. * Bind a webGL transform feedback object to the webgl context
  8824. * @param value defines the webGL transform feedback object to bind
  8825. */
  8826. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  8827. /**
  8828. * Begins a transform feedback operation
  8829. * @param usePoints defines if points or triangles must be used
  8830. */
  8831. beginTransformFeedback(usePoints?: boolean): void;
  8832. /**
  8833. * Ends a transform feedback operation
  8834. */
  8835. endTransformFeedback(): void;
  8836. /**
  8837. * Specify the varyings to use with transform feedback
  8838. * @param program defines the associated webGL program
  8839. * @param value defines the list of strings representing the varying names
  8840. */
  8841. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  8842. /**
  8843. * Bind a webGL buffer for a transform feedback operation
  8844. * @param value defines the webGL buffer to bind
  8845. */
  8846. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  8847. /** @hidden */
  8848. _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;
  8849. /** @hidden */
  8850. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  8851. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  8852. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  8853. /**
  8854. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  8855. * @returns true if the engine can be created
  8856. * @ignorenaming
  8857. */
  8858. static isSupported(): boolean;
  8859. }
  8860. }
  8861. declare module BABYLON {
  8862. class NullEngineOptions {
  8863. renderWidth: number;
  8864. renderHeight: number;
  8865. textureSize: number;
  8866. deterministicLockstep: boolean;
  8867. lockstepMaxSteps: number;
  8868. }
  8869. /**
  8870. * The null engine class provides support for headless version of babylon.js.
  8871. * This can be used in server side scenario or for testing purposes
  8872. */
  8873. class NullEngine extends Engine {
  8874. private _options;
  8875. isDeterministicLockStep(): boolean;
  8876. getLockstepMaxSteps(): number;
  8877. getHardwareScalingLevel(): number;
  8878. constructor(options?: NullEngineOptions);
  8879. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8880. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  8881. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8882. getRenderWidth(useScreen?: boolean): number;
  8883. getRenderHeight(useScreen?: boolean): number;
  8884. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8885. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  8886. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  8887. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8888. bindSamplers(effect: Effect): void;
  8889. enableEffect(effect: Effect): void;
  8890. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8891. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  8892. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  8893. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  8894. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  8895. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  8896. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  8897. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  8898. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  8899. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  8900. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  8901. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  8902. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  8903. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  8904. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  8905. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8906. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  8907. setFloat(uniform: WebGLUniformLocation, value: number): void;
  8908. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  8909. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  8910. setBool(uniform: WebGLUniformLocation, bool: number): void;
  8911. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  8912. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  8913. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  8914. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8915. bindBuffers(vertexBuffers: {
  8916. [key: string]: VertexBuffer;
  8917. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  8918. wipeCaches(bruteForce?: boolean): void;
  8919. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8920. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8921. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8922. _createTexture(): WebGLTexture;
  8923. _releaseTexture(texture: InternalTexture): void;
  8924. 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;
  8925. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8926. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8927. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  8928. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8929. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  8930. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8931. /**
  8932. * Updates a dynamic vertex buffer.
  8933. * @param vertexBuffer the vertex buffer to update
  8934. * @param data the data used to update the vertex buffer
  8935. * @param byteOffset the byte offset of the data (optional)
  8936. * @param byteLength the byte length of the data (optional)
  8937. */
  8938. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  8939. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  8940. _bindTexture(channel: number, texture: InternalTexture): void;
  8941. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8942. releaseEffects(): void;
  8943. }
  8944. }
  8945. interface WebGLRenderingContext {
  8946. readonly RASTERIZER_DISCARD: number;
  8947. readonly DEPTH_COMPONENT24: number;
  8948. readonly TEXTURE_3D: number;
  8949. readonly TEXTURE_2D_ARRAY: number;
  8950. readonly TEXTURE_COMPARE_FUNC: number;
  8951. readonly TEXTURE_COMPARE_MODE: number;
  8952. readonly COMPARE_REF_TO_TEXTURE: number;
  8953. readonly TEXTURE_WRAP_R: number;
  8954. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  8955. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  8956. 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;
  8957. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  8958. readonly TRANSFORM_FEEDBACK: number;
  8959. readonly INTERLEAVED_ATTRIBS: number;
  8960. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  8961. createTransformFeedback(): WebGLTransformFeedback;
  8962. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  8963. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  8964. beginTransformFeedback(primitiveMode: number): void;
  8965. endTransformFeedback(): void;
  8966. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  8967. }
  8968. interface ImageBitmap {
  8969. readonly width: number;
  8970. readonly height: number;
  8971. close(): void;
  8972. }
  8973. interface WebGLQuery extends WebGLObject {
  8974. }
  8975. declare var WebGLQuery: {
  8976. prototype: WebGLQuery;
  8977. new (): WebGLQuery;
  8978. };
  8979. interface WebGLSampler extends WebGLObject {
  8980. }
  8981. declare var WebGLSampler: {
  8982. prototype: WebGLSampler;
  8983. new (): WebGLSampler;
  8984. };
  8985. interface WebGLSync extends WebGLObject {
  8986. }
  8987. declare var WebGLSync: {
  8988. prototype: WebGLSync;
  8989. new (): WebGLSync;
  8990. };
  8991. interface WebGLTransformFeedback extends WebGLObject {
  8992. }
  8993. declare var WebGLTransformFeedback: {
  8994. prototype: WebGLTransformFeedback;
  8995. new (): WebGLTransformFeedback;
  8996. };
  8997. interface WebGLVertexArrayObject extends WebGLObject {
  8998. }
  8999. declare var WebGLVertexArrayObject: {
  9000. prototype: WebGLVertexArrayObject;
  9001. new (): WebGLVertexArrayObject;
  9002. };
  9003. declare module BABYLON {
  9004. class StickValues {
  9005. x: number;
  9006. y: number;
  9007. constructor(x: number, y: number);
  9008. }
  9009. interface GamepadButtonChanges {
  9010. changed: boolean;
  9011. pressChanged: boolean;
  9012. touchChanged: boolean;
  9013. valueChanged: boolean;
  9014. }
  9015. class Gamepad {
  9016. id: string;
  9017. index: number;
  9018. browserGamepad: any;
  9019. type: number;
  9020. private _leftStick;
  9021. private _rightStick;
  9022. _isConnected: boolean;
  9023. private _leftStickAxisX;
  9024. private _leftStickAxisY;
  9025. private _rightStickAxisX;
  9026. private _rightStickAxisY;
  9027. private _onleftstickchanged;
  9028. private _onrightstickchanged;
  9029. static GAMEPAD: number;
  9030. static GENERIC: number;
  9031. static XBOX: number;
  9032. static POSE_ENABLED: number;
  9033. protected _invertLeftStickY: boolean;
  9034. readonly isConnected: boolean;
  9035. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  9036. onleftstickchanged(callback: (values: StickValues) => void): void;
  9037. onrightstickchanged(callback: (values: StickValues) => void): void;
  9038. leftStick: StickValues;
  9039. rightStick: StickValues;
  9040. update(): void;
  9041. dispose(): void;
  9042. }
  9043. class GenericPad extends Gamepad {
  9044. private _buttons;
  9045. private _onbuttondown;
  9046. private _onbuttonup;
  9047. onButtonDownObservable: Observable<number>;
  9048. onButtonUpObservable: Observable<number>;
  9049. onbuttondown(callback: (buttonPressed: number) => void): void;
  9050. onbuttonup(callback: (buttonReleased: number) => void): void;
  9051. constructor(id: string, index: number, browserGamepad: any);
  9052. private _setButtonValue(newValue, currentValue, buttonIndex);
  9053. update(): void;
  9054. dispose(): void;
  9055. }
  9056. }
  9057. declare module BABYLON {
  9058. class GamepadManager {
  9059. private _scene;
  9060. private _babylonGamepads;
  9061. private _oneGamepadConnected;
  9062. _isMonitoring: boolean;
  9063. private _gamepadEventSupported;
  9064. private _gamepadSupport;
  9065. onGamepadConnectedObservable: Observable<Gamepad>;
  9066. onGamepadDisconnectedObservable: Observable<Gamepad>;
  9067. private _onGamepadConnectedEvent;
  9068. private _onGamepadDisconnectedEvent;
  9069. constructor(_scene?: Scene | undefined);
  9070. readonly gamepads: Gamepad[];
  9071. getGamepadByType(type?: number): Nullable<Gamepad>;
  9072. dispose(): void;
  9073. private _addNewGamepad(gamepad);
  9074. private _startMonitoringGamepads();
  9075. private _stopMonitoringGamepads();
  9076. _checkGamepadsStatus(): void;
  9077. private _updateGamepadObjects();
  9078. }
  9079. }
  9080. declare module BABYLON {
  9081. /**
  9082. * Defines supported buttons for XBox360 compatible gamepads
  9083. */
  9084. enum Xbox360Button {
  9085. /** A */
  9086. A = 0,
  9087. /** B */
  9088. B = 1,
  9089. /** X */
  9090. X = 2,
  9091. /** Y */
  9092. Y = 3,
  9093. /** Start */
  9094. Start = 4,
  9095. /** Back */
  9096. Back = 5,
  9097. /** Left button */
  9098. LB = 6,
  9099. /** Right button */
  9100. RB = 7,
  9101. /** Left stick */
  9102. LeftStick = 8,
  9103. /** Right stick */
  9104. RightStick = 9,
  9105. }
  9106. /** Defines values for XBox360 DPad */
  9107. enum Xbox360Dpad {
  9108. /** Up */
  9109. Up = 0,
  9110. /** Down */
  9111. Down = 1,
  9112. /** Left */
  9113. Left = 2,
  9114. /** Right */
  9115. Right = 3,
  9116. }
  9117. /**
  9118. * Defines a XBox360 gamepad
  9119. */
  9120. class Xbox360Pad extends Gamepad {
  9121. private _leftTrigger;
  9122. private _rightTrigger;
  9123. private _onlefttriggerchanged;
  9124. private _onrighttriggerchanged;
  9125. private _onbuttondown;
  9126. private _onbuttonup;
  9127. private _ondpaddown;
  9128. private _ondpadup;
  9129. /** Observable raised when a button is pressed */
  9130. onButtonDownObservable: Observable<Xbox360Button>;
  9131. /** Observable raised when a button is released */
  9132. onButtonUpObservable: Observable<Xbox360Button>;
  9133. /** Observable raised when a pad is pressed */
  9134. onPadDownObservable: Observable<Xbox360Dpad>;
  9135. /** Observable raised when a pad is released */
  9136. onPadUpObservable: Observable<Xbox360Dpad>;
  9137. private _buttonA;
  9138. private _buttonB;
  9139. private _buttonX;
  9140. private _buttonY;
  9141. private _buttonBack;
  9142. private _buttonStart;
  9143. private _buttonLB;
  9144. private _buttonRB;
  9145. private _buttonLeftStick;
  9146. private _buttonRightStick;
  9147. private _dPadUp;
  9148. private _dPadDown;
  9149. private _dPadLeft;
  9150. private _dPadRight;
  9151. private _isXboxOnePad;
  9152. /**
  9153. * Creates a new XBox360 gamepad object
  9154. * @param id defines the id of this gamepad
  9155. * @param index defines its index
  9156. * @param gamepad defines the internal HTML gamepad object
  9157. * @param xboxOne defines if it is a XBox One gamepad
  9158. */
  9159. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  9160. /**
  9161. * Defines the callback to call when left trigger is pressed
  9162. * @param callback defines the callback to use
  9163. */
  9164. onlefttriggerchanged(callback: (value: number) => void): void;
  9165. /**
  9166. * Defines the callback to call when right trigger is pressed
  9167. * @param callback defines the callback to use
  9168. */
  9169. onrighttriggerchanged(callback: (value: number) => void): void;
  9170. /**
  9171. * Gets or sets left trigger value
  9172. */
  9173. leftTrigger: number;
  9174. /**
  9175. * Gets or sets right trigger value
  9176. */
  9177. rightTrigger: number;
  9178. /**
  9179. * Defines the callback to call when a button is pressed
  9180. * @param callback defines the callback to use
  9181. */
  9182. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  9183. /**
  9184. * Defines the callback to call when a button is released
  9185. * @param callback defines the callback to use
  9186. */
  9187. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  9188. /**
  9189. * Defines the callback to call when a pad is pressed
  9190. * @param callback defines the callback to use
  9191. */
  9192. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  9193. /**
  9194. * Defines the callback to call when a pad is released
  9195. * @param callback defines the callback to use
  9196. */
  9197. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  9198. private _setButtonValue(newValue, currentValue, buttonType);
  9199. private _setDPadValue(newValue, currentValue, buttonType);
  9200. /** Gets or sets value of A button */
  9201. buttonA: number;
  9202. /** Gets or sets value of B button */
  9203. buttonB: number;
  9204. /** Gets or sets value of X button */
  9205. buttonX: number;
  9206. /** Gets or sets value of Y button */
  9207. buttonY: number;
  9208. /** Gets or sets value of Start button */
  9209. buttonStart: number;
  9210. /** Gets or sets value of Back button */
  9211. buttonBack: number;
  9212. /** Gets or sets value of Left button */
  9213. buttonLB: number;
  9214. /** Gets or sets value of Right button */
  9215. buttonRB: number;
  9216. /** Gets or sets value of left stick */
  9217. buttonLeftStick: number;
  9218. /** Gets or sets value of right stick */
  9219. buttonRightStick: number;
  9220. /** Gets or sets value of DPad up */
  9221. dPadUp: number;
  9222. /** Gets or sets value of DPad down */
  9223. dPadDown: number;
  9224. /** Gets or sets value of DPad left */
  9225. dPadLeft: number;
  9226. /** Gets or sets value of DPad right */
  9227. dPadRight: number;
  9228. /**
  9229. * Force the gamepad to synchronize with device values
  9230. */
  9231. update(): void;
  9232. dispose(): void;
  9233. }
  9234. }
  9235. declare module BABYLON {
  9236. class KeyboardEventTypes {
  9237. static _KEYDOWN: number;
  9238. static _KEYUP: number;
  9239. static readonly KEYDOWN: number;
  9240. static readonly KEYUP: number;
  9241. }
  9242. class KeyboardInfo {
  9243. type: number;
  9244. event: KeyboardEvent;
  9245. constructor(type: number, event: KeyboardEvent);
  9246. }
  9247. /**
  9248. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9249. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9250. */
  9251. class KeyboardInfoPre extends KeyboardInfo {
  9252. constructor(type: number, event: KeyboardEvent);
  9253. skipOnPointerObservable: boolean;
  9254. }
  9255. }
  9256. declare module BABYLON {
  9257. class PointerEventTypes {
  9258. static _POINTERDOWN: number;
  9259. static _POINTERUP: number;
  9260. static _POINTERMOVE: number;
  9261. static _POINTERWHEEL: number;
  9262. static _POINTERPICK: number;
  9263. static _POINTERTAP: number;
  9264. static _POINTERDOUBLETAP: number;
  9265. static readonly POINTERDOWN: number;
  9266. static readonly POINTERUP: number;
  9267. static readonly POINTERMOVE: number;
  9268. static readonly POINTERWHEEL: number;
  9269. static readonly POINTERPICK: number;
  9270. static readonly POINTERTAP: number;
  9271. static readonly POINTERDOUBLETAP: number;
  9272. }
  9273. class PointerInfoBase {
  9274. type: number;
  9275. event: PointerEvent | MouseWheelEvent;
  9276. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  9277. }
  9278. /**
  9279. * This class is used to store pointer related info for the onPrePointerObservable event.
  9280. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  9281. */
  9282. class PointerInfoPre extends PointerInfoBase {
  9283. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  9284. localPosition: Vector2;
  9285. skipOnPointerObservable: boolean;
  9286. }
  9287. /**
  9288. * This type contains all the data related to a pointer event in Babylon.js.
  9289. * 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.
  9290. */
  9291. class PointerInfo extends PointerInfoBase {
  9292. pickInfo: Nullable<PickingInfo>;
  9293. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  9294. }
  9295. }
  9296. declare module BABYLON {
  9297. /**
  9298. * Represents the different options available during the creation of
  9299. * a Environment helper.
  9300. *
  9301. * This can control the default ground, skybox and image processing setup of your scene.
  9302. */
  9303. interface IEnvironmentHelperOptions {
  9304. /**
  9305. * Specifies wether or not to create a ground.
  9306. * True by default.
  9307. */
  9308. createGround: boolean;
  9309. /**
  9310. * Specifies the ground size.
  9311. * 15 by default.
  9312. */
  9313. groundSize: number;
  9314. /**
  9315. * The texture used on the ground for the main color.
  9316. * Comes from the BabylonJS CDN by default.
  9317. *
  9318. * Remarks: Can be either a texture or a url.
  9319. */
  9320. groundTexture: string | BaseTexture;
  9321. /**
  9322. * The color mixed in the ground texture by default.
  9323. * BabylonJS clearColor by default.
  9324. */
  9325. groundColor: Color3;
  9326. /**
  9327. * Specifies the ground opacity.
  9328. * 1 by default.
  9329. */
  9330. groundOpacity: number;
  9331. /**
  9332. * Enables the ground to receive shadows.
  9333. * True by default.
  9334. */
  9335. enableGroundShadow: boolean;
  9336. /**
  9337. * Helps preventing the shadow to be fully black on the ground.
  9338. * 0.5 by default.
  9339. */
  9340. groundShadowLevel: number;
  9341. /**
  9342. * Creates a mirror texture attach to the ground.
  9343. * false by default.
  9344. */
  9345. enableGroundMirror: boolean;
  9346. /**
  9347. * Specifies the ground mirror size ratio.
  9348. * 0.3 by default as the default kernel is 64.
  9349. */
  9350. groundMirrorSizeRatio: number;
  9351. /**
  9352. * Specifies the ground mirror blur kernel size.
  9353. * 64 by default.
  9354. */
  9355. groundMirrorBlurKernel: number;
  9356. /**
  9357. * Specifies the ground mirror visibility amount.
  9358. * 1 by default
  9359. */
  9360. groundMirrorAmount: number;
  9361. /**
  9362. * Specifies the ground mirror reflectance weight.
  9363. * This uses the standard weight of the background material to setup the fresnel effect
  9364. * of the mirror.
  9365. * 1 by default.
  9366. */
  9367. groundMirrorFresnelWeight: number;
  9368. /**
  9369. * Specifies the ground mirror Falloff distance.
  9370. * This can helps reducing the size of the reflection.
  9371. * 0 by Default.
  9372. */
  9373. groundMirrorFallOffDistance: number;
  9374. /**
  9375. * Specifies the ground mirror texture type.
  9376. * Unsigned Int by Default.
  9377. */
  9378. groundMirrorTextureType: number;
  9379. /**
  9380. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  9381. * the shown objects.
  9382. */
  9383. groundYBias: number;
  9384. /**
  9385. * Specifies wether or not to create a skybox.
  9386. * True by default.
  9387. */
  9388. createSkybox: boolean;
  9389. /**
  9390. * Specifies the skybox size.
  9391. * 20 by default.
  9392. */
  9393. skyboxSize: number;
  9394. /**
  9395. * The texture used on the skybox for the main color.
  9396. * Comes from the BabylonJS CDN by default.
  9397. *
  9398. * Remarks: Can be either a texture or a url.
  9399. */
  9400. skyboxTexture: string | BaseTexture;
  9401. /**
  9402. * The color mixed in the skybox texture by default.
  9403. * BabylonJS clearColor by default.
  9404. */
  9405. skyboxColor: Color3;
  9406. /**
  9407. * The background rotation around the Y axis of the scene.
  9408. * This helps aligning the key lights of your scene with the background.
  9409. * 0 by default.
  9410. */
  9411. backgroundYRotation: number;
  9412. /**
  9413. * Compute automatically the size of the elements to best fit with the scene.
  9414. */
  9415. sizeAuto: boolean;
  9416. /**
  9417. * Default position of the rootMesh if autoSize is not true.
  9418. */
  9419. rootPosition: Vector3;
  9420. /**
  9421. * Sets up the image processing in the scene.
  9422. * true by default.
  9423. */
  9424. setupImageProcessing: boolean;
  9425. /**
  9426. * The texture used as your environment texture in the scene.
  9427. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  9428. *
  9429. * Remarks: Can be either a texture or a url.
  9430. */
  9431. environmentTexture: string | BaseTexture;
  9432. /**
  9433. * The value of the exposure to apply to the scene.
  9434. * 0.6 by default if setupImageProcessing is true.
  9435. */
  9436. cameraExposure: number;
  9437. /**
  9438. * The value of the contrast to apply to the scene.
  9439. * 1.6 by default if setupImageProcessing is true.
  9440. */
  9441. cameraContrast: number;
  9442. /**
  9443. * Specifies wether or not tonemapping should be enabled in the scene.
  9444. * true by default if setupImageProcessing is true.
  9445. */
  9446. toneMappingEnabled: boolean;
  9447. }
  9448. /**
  9449. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  9450. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  9451. * It also helps with the default setup of your imageProcessing configuration.
  9452. */
  9453. class EnvironmentHelper {
  9454. /**
  9455. * Default ground texture URL.
  9456. */
  9457. private static _groundTextureCDNUrl;
  9458. /**
  9459. * Default skybox texture URL.
  9460. */
  9461. private static _skyboxTextureCDNUrl;
  9462. /**
  9463. * Default environment texture URL.
  9464. */
  9465. private static _environmentTextureCDNUrl;
  9466. /**
  9467. * Creates the default options for the helper.
  9468. */
  9469. private static _getDefaultOptions();
  9470. private _rootMesh;
  9471. /**
  9472. * Gets the root mesh created by the helper.
  9473. */
  9474. readonly rootMesh: Mesh;
  9475. private _skybox;
  9476. /**
  9477. * Gets the skybox created by the helper.
  9478. */
  9479. readonly skybox: Nullable<Mesh>;
  9480. private _skyboxTexture;
  9481. /**
  9482. * Gets the skybox texture created by the helper.
  9483. */
  9484. readonly skyboxTexture: Nullable<BaseTexture>;
  9485. private _skyboxMaterial;
  9486. /**
  9487. * Gets the skybox material created by the helper.
  9488. */
  9489. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  9490. private _ground;
  9491. /**
  9492. * Gets the ground mesh created by the helper.
  9493. */
  9494. readonly ground: Nullable<Mesh>;
  9495. private _groundTexture;
  9496. /**
  9497. * Gets the ground texture created by the helper.
  9498. */
  9499. readonly groundTexture: Nullable<BaseTexture>;
  9500. private _groundMirror;
  9501. /**
  9502. * Gets the ground mirror created by the helper.
  9503. */
  9504. readonly groundMirror: Nullable<MirrorTexture>;
  9505. /**
  9506. * Gets the ground mirror render list to helps pushing the meshes
  9507. * you wish in the ground reflection.
  9508. */
  9509. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  9510. private _groundMaterial;
  9511. /**
  9512. * Gets the ground material created by the helper.
  9513. */
  9514. readonly groundMaterial: Nullable<BackgroundMaterial>;
  9515. /**
  9516. * Stores the creation options.
  9517. */
  9518. private readonly _scene;
  9519. private _options;
  9520. /**
  9521. * This observable will be notified with any error during the creation of the environment,
  9522. * mainly texture creation errors.
  9523. */
  9524. onErrorObservable: Observable<{
  9525. message?: string;
  9526. exception?: any;
  9527. }>;
  9528. /**
  9529. * constructor
  9530. * @param options
  9531. * @param scene The scene to add the material to
  9532. */
  9533. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  9534. /**
  9535. * Updates the background according to the new options
  9536. * @param options
  9537. */
  9538. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  9539. /**
  9540. * Sets the primary color of all the available elements.
  9541. * @param color the main color to affect to the ground and the background
  9542. */
  9543. setMainColor(color: Color3): void;
  9544. /**
  9545. * Setup the image processing according to the specified options.
  9546. */
  9547. private _setupImageProcessing();
  9548. /**
  9549. * Setup the environment texture according to the specified options.
  9550. */
  9551. private _setupEnvironmentTexture();
  9552. /**
  9553. * Setup the background according to the specified options.
  9554. */
  9555. private _setupBackground();
  9556. /**
  9557. * Get the scene sizes according to the setup.
  9558. */
  9559. private _getSceneSize();
  9560. /**
  9561. * Setup the ground according to the specified options.
  9562. */
  9563. private _setupGround(sceneSize);
  9564. /**
  9565. * Setup the ground material according to the specified options.
  9566. */
  9567. private _setupGroundMaterial();
  9568. /**
  9569. * Setup the ground diffuse texture according to the specified options.
  9570. */
  9571. private _setupGroundDiffuseTexture();
  9572. /**
  9573. * Setup the ground mirror texture according to the specified options.
  9574. */
  9575. private _setupGroundMirrorTexture(sceneSize);
  9576. /**
  9577. * Setup the ground to receive the mirror texture.
  9578. */
  9579. private _setupMirrorInGroundMaterial();
  9580. /**
  9581. * Setup the skybox according to the specified options.
  9582. */
  9583. private _setupSkybox(sceneSize);
  9584. /**
  9585. * Setup the skybox material according to the specified options.
  9586. */
  9587. private _setupSkyboxMaterial();
  9588. /**
  9589. * Setup the skybox reflection texture according to the specified options.
  9590. */
  9591. private _setupSkyboxReflectionTexture();
  9592. private _errorHandler;
  9593. /**
  9594. * Dispose all the elements created by the Helper.
  9595. */
  9596. dispose(): void;
  9597. }
  9598. }
  9599. declare module BABYLON {
  9600. /**
  9601. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  9602. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  9603. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  9604. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  9605. */
  9606. class VideoDome extends Node {
  9607. /**
  9608. * The video texture being displayed on the sphere
  9609. */
  9610. protected _videoTexture: VideoTexture;
  9611. /**
  9612. * The skybox material
  9613. */
  9614. protected _material: BackgroundMaterial;
  9615. /**
  9616. * The surface used for the skybox
  9617. */
  9618. protected _mesh: Mesh;
  9619. /**
  9620. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  9621. * Also see the options.resolution property.
  9622. */
  9623. fovMultiplier: number;
  9624. /**
  9625. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  9626. * @param name Element's name, child elements will append suffixes for their own names.
  9627. * @param urlsOrVideo
  9628. * @param options An object containing optional or exposed sub element properties:
  9629. * @param options **resolution=12** Integer, lower resolutions have more artifacts at extreme fovs
  9630. * @param options **clickToPlay=false** Add a click to play listener to the video, does not prevent autoplay.
  9631. * @param options **autoPlay=true** Automatically attempt to being playing the video.
  9632. * @param options **loop=true** Automatically loop video on end.
  9633. * @param options **size=1000** Physical radius to create the dome at, defaults to approximately half the far clip plane.
  9634. */
  9635. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  9636. resolution?: number;
  9637. clickToPlay?: boolean;
  9638. autoPlay?: boolean;
  9639. loop?: boolean;
  9640. size?: number;
  9641. }, scene: Scene);
  9642. /**
  9643. * Releases resources associated with this node.
  9644. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9645. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9646. */
  9647. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9648. }
  9649. }
  9650. declare module BABYLON {
  9651. /**
  9652. * This class can be used to get instrumentation data from a Babylon engine
  9653. */
  9654. class EngineInstrumentation implements IDisposable {
  9655. engine: Engine;
  9656. private _captureGPUFrameTime;
  9657. private _gpuFrameTimeToken;
  9658. private _gpuFrameTime;
  9659. private _captureShaderCompilationTime;
  9660. private _shaderCompilationTime;
  9661. private _onBeginFrameObserver;
  9662. private _onEndFrameObserver;
  9663. private _onBeforeShaderCompilationObserver;
  9664. private _onAfterShaderCompilationObserver;
  9665. /**
  9666. * Gets the perf counter used for GPU frame time
  9667. */
  9668. readonly gpuFrameTimeCounter: PerfCounter;
  9669. /**
  9670. * Gets the GPU frame time capture status
  9671. */
  9672. /**
  9673. * Enable or disable the GPU frame time capture
  9674. */
  9675. captureGPUFrameTime: boolean;
  9676. /**
  9677. * Gets the perf counter used for shader compilation time
  9678. */
  9679. readonly shaderCompilationTimeCounter: PerfCounter;
  9680. /**
  9681. * Gets the shader compilation time capture status
  9682. */
  9683. /**
  9684. * Enable or disable the shader compilation time capture
  9685. */
  9686. captureShaderCompilationTime: boolean;
  9687. constructor(engine: Engine);
  9688. dispose(): void;
  9689. }
  9690. }
  9691. declare module BABYLON {
  9692. /**
  9693. * This class can be used to get instrumentation data from a Babylon engine
  9694. */
  9695. class SceneInstrumentation implements IDisposable {
  9696. scene: Scene;
  9697. private _captureActiveMeshesEvaluationTime;
  9698. private _activeMeshesEvaluationTime;
  9699. private _captureRenderTargetsRenderTime;
  9700. private _renderTargetsRenderTime;
  9701. private _captureFrameTime;
  9702. private _frameTime;
  9703. private _captureRenderTime;
  9704. private _renderTime;
  9705. private _captureInterFrameTime;
  9706. private _interFrameTime;
  9707. private _captureParticlesRenderTime;
  9708. private _particlesRenderTime;
  9709. private _captureSpritesRenderTime;
  9710. private _spritesRenderTime;
  9711. private _capturePhysicsTime;
  9712. private _physicsTime;
  9713. private _captureAnimationsTime;
  9714. private _animationsTime;
  9715. private _onBeforeActiveMeshesEvaluationObserver;
  9716. private _onAfterActiveMeshesEvaluationObserver;
  9717. private _onBeforeRenderTargetsRenderObserver;
  9718. private _onAfterRenderTargetsRenderObserver;
  9719. private _onAfterRenderObserver;
  9720. private _onBeforeDrawPhaseObserver;
  9721. private _onAfterDrawPhaseObserver;
  9722. private _onBeforeAnimationsObserver;
  9723. private _onBeforeParticlesRenderingObserver;
  9724. private _onAfterParticlesRenderingObserver;
  9725. private _onBeforeSpritesRenderingObserver;
  9726. private _onAfterSpritesRenderingObserver;
  9727. private _onBeforePhysicsObserver;
  9728. private _onAfterPhysicsObserver;
  9729. private _onAfterAnimationsObserver;
  9730. /**
  9731. * Gets the perf counter used for active meshes evaluation time
  9732. */
  9733. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  9734. /**
  9735. * Gets the active meshes evaluation time capture status
  9736. */
  9737. /**
  9738. * Enable or disable the active meshes evaluation time capture
  9739. */
  9740. captureActiveMeshesEvaluationTime: boolean;
  9741. /**
  9742. * Gets the perf counter used for render targets render time
  9743. */
  9744. readonly renderTargetsRenderTimeCounter: PerfCounter;
  9745. /**
  9746. * Gets the render targets render time capture status
  9747. */
  9748. /**
  9749. * Enable or disable the render targets render time capture
  9750. */
  9751. captureRenderTargetsRenderTime: boolean;
  9752. /**
  9753. * Gets the perf counter used for particles render time
  9754. */
  9755. readonly particlesRenderTimeCounter: PerfCounter;
  9756. /**
  9757. * Gets the particles render time capture status
  9758. */
  9759. /**
  9760. * Enable or disable the particles render time capture
  9761. */
  9762. captureParticlesRenderTime: boolean;
  9763. /**
  9764. * Gets the perf counter used for sprites render time
  9765. */
  9766. readonly spritesRenderTimeCounter: PerfCounter;
  9767. /**
  9768. * Gets the sprites render time capture status
  9769. */
  9770. /**
  9771. * Enable or disable the sprites render time capture
  9772. */
  9773. captureSpritesRenderTime: boolean;
  9774. /**
  9775. * Gets the perf counter used for physics time
  9776. */
  9777. readonly physicsTimeCounter: PerfCounter;
  9778. /**
  9779. * Gets the physics time capture status
  9780. */
  9781. /**
  9782. * Enable or disable the physics time capture
  9783. */
  9784. capturePhysicsTime: boolean;
  9785. /**
  9786. * Gets the perf counter used for animations time
  9787. */
  9788. readonly animationsTimeCounter: PerfCounter;
  9789. /**
  9790. * Gets the animations time capture status
  9791. */
  9792. /**
  9793. * Enable or disable the animations time capture
  9794. */
  9795. captureAnimationsTime: boolean;
  9796. /**
  9797. * Gets the perf counter used for frame time capture
  9798. */
  9799. readonly frameTimeCounter: PerfCounter;
  9800. /**
  9801. * Gets the frame time capture status
  9802. */
  9803. /**
  9804. * Enable or disable the frame time capture
  9805. */
  9806. captureFrameTime: boolean;
  9807. /**
  9808. * Gets the perf counter used for inter-frames time capture
  9809. */
  9810. readonly interFrameTimeCounter: PerfCounter;
  9811. /**
  9812. * Gets the inter-frames time capture status
  9813. */
  9814. /**
  9815. * Enable or disable the inter-frames time capture
  9816. */
  9817. captureInterFrameTime: boolean;
  9818. /**
  9819. * Gets the perf counter used for render time capture
  9820. */
  9821. readonly renderTimeCounter: PerfCounter;
  9822. /**
  9823. * Gets the render time capture status
  9824. */
  9825. /**
  9826. * Enable or disable the render time capture
  9827. */
  9828. captureRenderTime: boolean;
  9829. /**
  9830. * Gets the perf counter used for draw calls
  9831. */
  9832. readonly drawCallsCounter: PerfCounter;
  9833. /**
  9834. * Gets the perf counter used for texture collisions
  9835. */
  9836. readonly textureCollisionsCounter: PerfCounter;
  9837. constructor(scene: Scene);
  9838. dispose(): void;
  9839. }
  9840. }
  9841. declare module BABYLON {
  9842. /**
  9843. * @hidden
  9844. **/
  9845. class _TimeToken {
  9846. _startTimeQuery: Nullable<WebGLQuery>;
  9847. _endTimeQuery: Nullable<WebGLQuery>;
  9848. _timeElapsedQuery: Nullable<WebGLQuery>;
  9849. _timeElapsedQueryEnded: boolean;
  9850. }
  9851. }
  9852. declare module BABYLON {
  9853. class LensFlare {
  9854. size: number;
  9855. position: number;
  9856. color: Color3;
  9857. texture: Nullable<Texture>;
  9858. alphaMode: number;
  9859. private _system;
  9860. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  9861. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  9862. dispose(): void;
  9863. }
  9864. }
  9865. declare module BABYLON {
  9866. class LensFlareSystem {
  9867. name: string;
  9868. lensFlares: LensFlare[];
  9869. borderLimit: number;
  9870. viewportBorder: number;
  9871. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  9872. layerMask: number;
  9873. id: string;
  9874. private _scene;
  9875. private _emitter;
  9876. private _vertexBuffers;
  9877. private _indexBuffer;
  9878. private _effect;
  9879. private _positionX;
  9880. private _positionY;
  9881. private _isEnabled;
  9882. constructor(name: string, emitter: any, scene: Scene);
  9883. isEnabled: boolean;
  9884. getScene(): Scene;
  9885. getEmitter(): any;
  9886. setEmitter(newEmitter: any): void;
  9887. getEmitterPosition(): Vector3;
  9888. computeEffectivePosition(globalViewport: Viewport): boolean;
  9889. _isVisible(): boolean;
  9890. render(): boolean;
  9891. dispose(): void;
  9892. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  9893. serialize(): any;
  9894. }
  9895. }
  9896. declare module BABYLON {
  9897. /**
  9898. * Effect layer options. This helps customizing the behaviour
  9899. * of the effect layer.
  9900. */
  9901. interface IEffectLayerOptions {
  9902. /**
  9903. * Multiplication factor apply to the canvas size to compute the render target size
  9904. * used to generated the objects (the smaller the faster).
  9905. */
  9906. mainTextureRatio: number;
  9907. /**
  9908. * Enforces a fixed size texture to ensure effect stability across devices.
  9909. */
  9910. mainTextureFixedSize?: number;
  9911. /**
  9912. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  9913. */
  9914. alphaBlendingMode: number;
  9915. /**
  9916. * The camera attached to the layer.
  9917. */
  9918. camera: Nullable<Camera>;
  9919. }
  9920. /**
  9921. * The effect layer Helps adding post process effect blended with the main pass.
  9922. *
  9923. * This can be for instance use to generate glow or higlight effects on the scene.
  9924. *
  9925. * The effect layer class can not be used directly and is intented to inherited from to be
  9926. * customized per effects.
  9927. */
  9928. abstract class EffectLayer {
  9929. private _vertexBuffers;
  9930. private _indexBuffer;
  9931. private _cachedDefines;
  9932. private _effectLayerMapGenerationEffect;
  9933. private _effectLayerOptions;
  9934. private _mergeEffect;
  9935. protected _scene: Scene;
  9936. protected _engine: Engine;
  9937. protected _maxSize: number;
  9938. protected _mainTextureDesiredSize: ISize;
  9939. protected _mainTexture: RenderTargetTexture;
  9940. protected _shouldRender: boolean;
  9941. protected _postProcesses: PostProcess[];
  9942. protected _textures: BaseTexture[];
  9943. protected _emissiveTextureAndColor: {
  9944. texture: Nullable<BaseTexture>;
  9945. color: Color4;
  9946. };
  9947. /**
  9948. * The name of the layer
  9949. */
  9950. name: string;
  9951. /**
  9952. * The clear color of the texture used to generate the glow map.
  9953. */
  9954. neutralColor: Color4;
  9955. /**
  9956. * Specifies wether the highlight layer is enabled or not.
  9957. */
  9958. isEnabled: boolean;
  9959. /**
  9960. * Gets the camera attached to the layer.
  9961. */
  9962. readonly camera: Nullable<Camera>;
  9963. /**
  9964. * An event triggered when the effect layer has been disposed.
  9965. */
  9966. onDisposeObservable: Observable<EffectLayer>;
  9967. /**
  9968. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  9969. */
  9970. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  9971. /**
  9972. * An event triggered when the generated texture is being merged in the scene.
  9973. */
  9974. onBeforeComposeObservable: Observable<EffectLayer>;
  9975. /**
  9976. * An event triggered when the generated texture has been merged in the scene.
  9977. */
  9978. onAfterComposeObservable: Observable<EffectLayer>;
  9979. /**
  9980. * An event triggered when the efffect layer changes its size.
  9981. */
  9982. onSizeChangedObservable: Observable<EffectLayer>;
  9983. /**
  9984. * Instantiates a new effect Layer and references it in the scene.
  9985. * @param name The name of the layer
  9986. * @param scene The scene to use the layer in
  9987. */
  9988. constructor(
  9989. /** The Friendly of the effect in the scene */
  9990. name: string, scene: Scene);
  9991. /**
  9992. * Get the effect name of the layer.
  9993. * @return The effect name
  9994. */
  9995. abstract getEffectName(): string;
  9996. /**
  9997. * Checks for the readiness of the element composing the layer.
  9998. * @param subMesh the mesh to check for
  9999. * @param useInstances specify wether or not to use instances to render the mesh
  10000. * @return true if ready otherwise, false
  10001. */
  10002. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10003. /**
  10004. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10005. * @returns true if the effect requires stencil during the main canvas render pass.
  10006. */
  10007. abstract needStencil(): boolean;
  10008. /**
  10009. * Create the merge effect. This is the shader use to blit the information back
  10010. * to the main canvas at the end of the scene rendering.
  10011. * @returns The effect containing the shader used to merge the effect on the main canvas
  10012. */
  10013. protected abstract _createMergeEffect(): Effect;
  10014. /**
  10015. * Creates the render target textures and post processes used in the effect layer.
  10016. */
  10017. protected abstract _createTextureAndPostProcesses(): void;
  10018. /**
  10019. * Implementation specific of rendering the generating effect on the main canvas.
  10020. * @param effect The effect used to render through
  10021. */
  10022. protected abstract _internalRender(effect: Effect): void;
  10023. /**
  10024. * Sets the required values for both the emissive texture and and the main color.
  10025. */
  10026. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10027. /**
  10028. * Free any resources and references associated to a mesh.
  10029. * Internal use
  10030. * @param mesh The mesh to free.
  10031. */
  10032. abstract _disposeMesh(mesh: Mesh): void;
  10033. /**
  10034. * Serializes this layer (Glow or Highlight for example)
  10035. * @returns a serialized layer object
  10036. */
  10037. abstract serialize?(): any;
  10038. /**
  10039. * Initializes the effect layer with the required options.
  10040. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  10041. */
  10042. protected _init(options: Partial<IEffectLayerOptions>): void;
  10043. /**
  10044. * Generates the index buffer of the full screen quad blending to the main canvas.
  10045. */
  10046. private _generateIndexBuffer();
  10047. /**
  10048. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  10049. */
  10050. private _genrateVertexBuffer();
  10051. /**
  10052. * Sets the main texture desired size which is the closest power of two
  10053. * of the engine canvas size.
  10054. */
  10055. private _setMainTextureSize();
  10056. /**
  10057. * Creates the main texture for the effect layer.
  10058. */
  10059. protected _createMainTexture(): void;
  10060. /**
  10061. * Checks for the readiness of the element composing the layer.
  10062. * @param subMesh the mesh to check for
  10063. * @param useInstances specify wether or not to use instances to render the mesh
  10064. * @param emissiveTexture the associated emissive texture used to generate the glow
  10065. * @return true if ready otherwise, false
  10066. */
  10067. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  10068. /**
  10069. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  10070. */
  10071. render(): void;
  10072. /**
  10073. * Determine if a given mesh will be used in the current effect.
  10074. * @param mesh mesh to test
  10075. * @returns true if the mesh will be used
  10076. */
  10077. hasMesh(mesh: AbstractMesh): boolean;
  10078. /**
  10079. * Returns true if the layer contains information to display, otherwise false.
  10080. * @returns true if the glow layer should be rendered
  10081. */
  10082. shouldRender(): boolean;
  10083. /**
  10084. * Returns true if the mesh should render, otherwise false.
  10085. * @param mesh The mesh to render
  10086. * @returns true if it should render otherwise false
  10087. */
  10088. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10089. /**
  10090. * Returns true if the mesh should render, otherwise false.
  10091. * @param mesh The mesh to render
  10092. * @returns true if it should render otherwise false
  10093. */
  10094. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  10095. /**
  10096. * Renders the submesh passed in parameter to the generation map.
  10097. */
  10098. protected _renderSubMesh(subMesh: SubMesh): void;
  10099. /**
  10100. * Rebuild the required buffers.
  10101. * @hidden Internal use only.
  10102. */
  10103. _rebuild(): void;
  10104. /**
  10105. * Dispose only the render target textures and post process.
  10106. */
  10107. private _disposeTextureAndPostProcesses();
  10108. /**
  10109. * Dispose the highlight layer and free resources.
  10110. */
  10111. dispose(): void;
  10112. /**
  10113. * Gets the class name of the effect layer
  10114. * @returns the string with the class name of the effect layer
  10115. */
  10116. getClassName(): string;
  10117. /**
  10118. * Creates an effect layer from parsed effect layer data
  10119. * @param parsedEffectLayer defines effect layer data
  10120. * @param scene defines the current scene
  10121. * @param rootUrl defines the root URL containing the effect layer information
  10122. * @returns a parsed effect Layer
  10123. */
  10124. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  10125. }
  10126. }
  10127. declare module BABYLON {
  10128. /**
  10129. * Glow layer options. This helps customizing the behaviour
  10130. * of the glow layer.
  10131. */
  10132. interface IGlowLayerOptions {
  10133. /**
  10134. * Multiplication factor apply to the canvas size to compute the render target size
  10135. * used to generated the glowing objects (the smaller the faster).
  10136. */
  10137. mainTextureRatio: number;
  10138. /**
  10139. * Enforces a fixed size texture to ensure resize independant blur.
  10140. */
  10141. mainTextureFixedSize?: number;
  10142. /**
  10143. * How big is the kernel of the blur texture.
  10144. */
  10145. blurKernelSize: number;
  10146. /**
  10147. * The camera attached to the layer.
  10148. */
  10149. camera: Nullable<Camera>;
  10150. /**
  10151. * Enable MSAA by chosing the number of samples.
  10152. */
  10153. mainTextureSamples?: number;
  10154. }
  10155. /**
  10156. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  10157. *
  10158. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10159. * glowy meshes to your scene.
  10160. *
  10161. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  10162. */
  10163. class GlowLayer extends EffectLayer {
  10164. /**
  10165. * Effect Name of the layer.
  10166. */
  10167. static readonly EffectName: string;
  10168. /**
  10169. * The default blur kernel size used for the glow.
  10170. */
  10171. static DefaultBlurKernelSize: number;
  10172. /**
  10173. * The default texture size ratio used for the glow.
  10174. */
  10175. static DefaultTextureRatio: number;
  10176. /**
  10177. * Gets the kernel size of the blur.
  10178. */
  10179. /**
  10180. * Sets the kernel size of the blur.
  10181. */
  10182. blurKernelSize: number;
  10183. /**
  10184. * Gets the glow intensity.
  10185. */
  10186. /**
  10187. * Sets the glow intensity.
  10188. */
  10189. intensity: number;
  10190. private _options;
  10191. private _intensity;
  10192. private _horizontalBlurPostprocess1;
  10193. private _verticalBlurPostprocess1;
  10194. private _horizontalBlurPostprocess2;
  10195. private _verticalBlurPostprocess2;
  10196. private _blurTexture1;
  10197. private _blurTexture2;
  10198. private _postProcesses1;
  10199. private _postProcesses2;
  10200. private _includedOnlyMeshes;
  10201. private _excludedMeshes;
  10202. /**
  10203. * Callback used to let the user override the color selection on a per mesh basis
  10204. */
  10205. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  10206. /**
  10207. * Callback used to let the user override the texture selection on a per mesh basis
  10208. */
  10209. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  10210. /**
  10211. * Instantiates a new glow Layer and references it to the scene.
  10212. * @param name The name of the layer
  10213. * @param scene The scene to use the layer in
  10214. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  10215. */
  10216. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  10217. /**
  10218. * Get the effect name of the layer.
  10219. * @return The effect name
  10220. */
  10221. getEffectName(): string;
  10222. /**
  10223. * Create the merge effect. This is the shader use to blit the information back
  10224. * to the main canvas at the end of the scene rendering.
  10225. */
  10226. protected _createMergeEffect(): Effect;
  10227. /**
  10228. * Creates the render target textures and post processes used in the glow layer.
  10229. */
  10230. protected _createTextureAndPostProcesses(): void;
  10231. /**
  10232. * Checks for the readiness of the element composing the layer.
  10233. * @param subMesh the mesh to check for
  10234. * @param useInstances specify wether or not to use instances to render the mesh
  10235. * @param emissiveTexture the associated emissive texture used to generate the glow
  10236. * @return true if ready otherwise, false
  10237. */
  10238. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10239. /**
  10240. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10241. */
  10242. needStencil(): boolean;
  10243. /**
  10244. * Implementation specific of rendering the generating effect on the main canvas.
  10245. * @param effect The effect used to render through
  10246. */
  10247. protected _internalRender(effect: Effect): void;
  10248. /**
  10249. * Sets the required values for both the emissive texture and and the main color.
  10250. */
  10251. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10252. /**
  10253. * Returns true if the mesh should render, otherwise false.
  10254. * @param mesh The mesh to render
  10255. * @returns true if it should render otherwise false
  10256. */
  10257. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10258. /**
  10259. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  10260. * @param mesh The mesh to exclude from the glow layer
  10261. */
  10262. addExcludedMesh(mesh: Mesh): void;
  10263. /**
  10264. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  10265. * @param mesh The mesh to remove
  10266. */
  10267. removeExcludedMesh(mesh: Mesh): void;
  10268. /**
  10269. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  10270. * @param mesh The mesh to include in the glow layer
  10271. */
  10272. addIncludedOnlyMesh(mesh: Mesh): void;
  10273. /**
  10274. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  10275. * @param mesh The mesh to remove
  10276. */
  10277. removeIncludedOnlyMesh(mesh: Mesh): void;
  10278. /**
  10279. * Determine if a given mesh will be used in the glow layer
  10280. * @param mesh The mesh to test
  10281. * @returns true if the mesh will be highlighted by the current glow layer
  10282. */
  10283. hasMesh(mesh: AbstractMesh): boolean;
  10284. /**
  10285. * Free any resources and references associated to a mesh.
  10286. * Internal use
  10287. * @param mesh The mesh to free.
  10288. */
  10289. _disposeMesh(mesh: Mesh): void;
  10290. /**
  10291. * Gets the class name of the effect layer
  10292. * @returns the string with the class name of the effect layer
  10293. */
  10294. getClassName(): string;
  10295. /**
  10296. * Serializes this glow layer
  10297. * @returns a serialized glow layer object
  10298. */
  10299. serialize(): any;
  10300. /**
  10301. * Creates a Glow Layer from parsed glow layer data
  10302. * @param parsedGlowLayer defines glow layer data
  10303. * @param scene defines the current scene
  10304. * @param rootUrl defines the root URL containing the glow layer information
  10305. * @returns a parsed Glow Layer
  10306. */
  10307. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  10308. }
  10309. }
  10310. declare module BABYLON {
  10311. /**
  10312. * Highlight layer options. This helps customizing the behaviour
  10313. * of the highlight layer.
  10314. */
  10315. interface IHighlightLayerOptions {
  10316. /**
  10317. * Multiplication factor apply to the canvas size to compute the render target size
  10318. * used to generated the glowing objects (the smaller the faster).
  10319. */
  10320. mainTextureRatio: number;
  10321. /**
  10322. * Enforces a fixed size texture to ensure resize independant blur.
  10323. */
  10324. mainTextureFixedSize?: number;
  10325. /**
  10326. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  10327. * of the picture to blur (the smaller the faster).
  10328. */
  10329. blurTextureSizeRatio: number;
  10330. /**
  10331. * How big in texel of the blur texture is the vertical blur.
  10332. */
  10333. blurVerticalSize: number;
  10334. /**
  10335. * How big in texel of the blur texture is the horizontal blur.
  10336. */
  10337. blurHorizontalSize: number;
  10338. /**
  10339. * Alpha blending mode used to apply the blur. Default is combine.
  10340. */
  10341. alphaBlendingMode: number;
  10342. /**
  10343. * The camera attached to the layer.
  10344. */
  10345. camera: Nullable<Camera>;
  10346. /**
  10347. * Should we display highlight as a solid stroke?
  10348. */
  10349. isStroke?: boolean;
  10350. }
  10351. /**
  10352. * The highlight layer Helps adding a glow effect around a mesh.
  10353. *
  10354. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10355. * glowy meshes to your scene.
  10356. *
  10357. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  10358. */
  10359. class HighlightLayer extends EffectLayer {
  10360. name: string;
  10361. /**
  10362. * Effect Name of the highlight layer.
  10363. */
  10364. static readonly EffectName: string;
  10365. /**
  10366. * The neutral color used during the preparation of the glow effect.
  10367. * This is black by default as the blend operation is a blend operation.
  10368. */
  10369. static NeutralColor: Color4;
  10370. /**
  10371. * Stencil value used for glowing meshes.
  10372. */
  10373. static GlowingMeshStencilReference: number;
  10374. /**
  10375. * Stencil value used for the other meshes in the scene.
  10376. */
  10377. static NormalMeshStencilReference: number;
  10378. /**
  10379. * Specifies whether or not the inner glow is ACTIVE in the layer.
  10380. */
  10381. innerGlow: boolean;
  10382. /**
  10383. * Specifies whether or not the outer glow is ACTIVE in the layer.
  10384. */
  10385. outerGlow: boolean;
  10386. /**
  10387. * Gets the horizontal size of the blur.
  10388. */
  10389. /**
  10390. * Specifies the horizontal size of the blur.
  10391. */
  10392. blurHorizontalSize: number;
  10393. /**
  10394. * Gets the vertical size of the blur.
  10395. */
  10396. /**
  10397. * Specifies the vertical size of the blur.
  10398. */
  10399. blurVerticalSize: number;
  10400. /**
  10401. * An event triggered when the highlight layer is being blurred.
  10402. */
  10403. onBeforeBlurObservable: Observable<HighlightLayer>;
  10404. /**
  10405. * An event triggered when the highlight layer has been blurred.
  10406. */
  10407. onAfterBlurObservable: Observable<HighlightLayer>;
  10408. private _instanceGlowingMeshStencilReference;
  10409. private _options;
  10410. private _downSamplePostprocess;
  10411. private _horizontalBlurPostprocess;
  10412. private _verticalBlurPostprocess;
  10413. private _blurTexture;
  10414. private _meshes;
  10415. private _excludedMeshes;
  10416. /**
  10417. * Instantiates a new highlight Layer and references it to the scene..
  10418. * @param name The name of the layer
  10419. * @param scene The scene to use the layer in
  10420. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  10421. */
  10422. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  10423. /**
  10424. * Get the effect name of the layer.
  10425. * @return The effect name
  10426. */
  10427. getEffectName(): string;
  10428. /**
  10429. * Create the merge effect. This is the shader use to blit the information back
  10430. * to the main canvas at the end of the scene rendering.
  10431. */
  10432. protected _createMergeEffect(): Effect;
  10433. /**
  10434. * Creates the render target textures and post processes used in the highlight layer.
  10435. */
  10436. protected _createTextureAndPostProcesses(): void;
  10437. /**
  10438. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10439. */
  10440. needStencil(): boolean;
  10441. /**
  10442. * Checks for the readiness of the element composing the layer.
  10443. * @param subMesh the mesh to check for
  10444. * @param useInstances specify wether or not to use instances to render the mesh
  10445. * @param emissiveTexture the associated emissive texture used to generate the glow
  10446. * @return true if ready otherwise, false
  10447. */
  10448. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10449. /**
  10450. * Implementation specific of rendering the generating effect on the main canvas.
  10451. * @param effect The effect used to render through
  10452. */
  10453. protected _internalRender(effect: Effect): void;
  10454. /**
  10455. * Returns true if the layer contains information to display, otherwise false.
  10456. */
  10457. shouldRender(): boolean;
  10458. /**
  10459. * Returns true if the mesh should render, otherwise false.
  10460. * @param mesh The mesh to render
  10461. * @returns true if it should render otherwise false
  10462. */
  10463. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10464. /**
  10465. * Sets the required values for both the emissive texture and and the main color.
  10466. */
  10467. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10468. /**
  10469. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  10470. * @param mesh The mesh to exclude from the highlight layer
  10471. */
  10472. addExcludedMesh(mesh: Mesh): void;
  10473. /**
  10474. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  10475. * @param mesh The mesh to highlight
  10476. */
  10477. removeExcludedMesh(mesh: Mesh): void;
  10478. /**
  10479. * Determine if a given mesh will be highlighted by the current HighlightLayer
  10480. * @param mesh mesh to test
  10481. * @returns true if the mesh will be highlighted by the current HighlightLayer
  10482. */
  10483. hasMesh(mesh: AbstractMesh): boolean;
  10484. /**
  10485. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  10486. * @param mesh The mesh to highlight
  10487. * @param color The color of the highlight
  10488. * @param glowEmissiveOnly Extract the glow from the emissive texture
  10489. */
  10490. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  10491. /**
  10492. * Remove a mesh from the highlight layer in order to make it stop glowing.
  10493. * @param mesh The mesh to highlight
  10494. */
  10495. removeMesh(mesh: Mesh): void;
  10496. /**
  10497. * Force the stencil to the normal expected value for none glowing parts
  10498. */
  10499. private _defaultStencilReference(mesh);
  10500. /**
  10501. * Free any resources and references associated to a mesh.
  10502. * Internal use
  10503. * @param mesh The mesh to free.
  10504. */
  10505. _disposeMesh(mesh: Mesh): void;
  10506. /**
  10507. * Dispose the highlight layer and free resources.
  10508. */
  10509. dispose(): void;
  10510. /**
  10511. * Gets the class name of the effect layer
  10512. * @returns the string with the class name of the effect layer
  10513. */
  10514. getClassName(): string;
  10515. /**
  10516. * Serializes this Highlight layer
  10517. * @returns a serialized Highlight layer object
  10518. */
  10519. serialize(): any;
  10520. /**
  10521. * Creates a Highlight layer from parsed Highlight layer data
  10522. * @param parsedHightlightLayer defines the Highlight layer data
  10523. * @param scene defines the current scene
  10524. * @param rootUrl defines the root URL containing the Highlight layer information
  10525. * @returns a parsed Highlight layer
  10526. */
  10527. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  10528. }
  10529. }
  10530. declare module BABYLON {
  10531. class Layer {
  10532. name: string;
  10533. texture: Nullable<Texture>;
  10534. isBackground: boolean;
  10535. color: Color4;
  10536. scale: Vector2;
  10537. offset: Vector2;
  10538. alphaBlendingMode: number;
  10539. alphaTest: boolean;
  10540. layerMask: number;
  10541. private _scene;
  10542. private _vertexBuffers;
  10543. private _indexBuffer;
  10544. private _effect;
  10545. private _alphaTestEffect;
  10546. /**
  10547. * An event triggered when the layer is disposed.
  10548. */
  10549. onDisposeObservable: Observable<Layer>;
  10550. private _onDisposeObserver;
  10551. onDispose: () => void;
  10552. /**
  10553. * An event triggered before rendering the scene
  10554. */
  10555. onBeforeRenderObservable: Observable<Layer>;
  10556. private _onBeforeRenderObserver;
  10557. onBeforeRender: () => void;
  10558. /**
  10559. * An event triggered after rendering the scene
  10560. */
  10561. onAfterRenderObservable: Observable<Layer>;
  10562. private _onAfterRenderObserver;
  10563. onAfterRender: () => void;
  10564. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  10565. private _createIndexBuffer();
  10566. _rebuild(): void;
  10567. render(): void;
  10568. dispose(): void;
  10569. }
  10570. }
  10571. declare module BABYLON {
  10572. interface ILoadingScreen {
  10573. displayLoadingUI: () => void;
  10574. hideLoadingUI: () => void;
  10575. loadingUIBackgroundColor: string;
  10576. loadingUIText: string;
  10577. }
  10578. class DefaultLoadingScreen implements ILoadingScreen {
  10579. private _renderingCanvas;
  10580. private _loadingText;
  10581. private _loadingDivBackgroundColor;
  10582. private _loadingDiv;
  10583. private _loadingTextDiv;
  10584. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  10585. displayLoadingUI(): void;
  10586. hideLoadingUI(): void;
  10587. loadingUIText: string;
  10588. loadingUIBackgroundColor: string;
  10589. private _resizeLoadingUI;
  10590. }
  10591. }
  10592. declare module BABYLON {
  10593. class SceneLoaderProgressEvent {
  10594. readonly lengthComputable: boolean;
  10595. readonly loaded: number;
  10596. readonly total: number;
  10597. constructor(lengthComputable: boolean, loaded: number, total: number);
  10598. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  10599. }
  10600. interface ISceneLoaderPluginExtensions {
  10601. [extension: string]: {
  10602. isBinary: boolean;
  10603. };
  10604. }
  10605. interface ISceneLoaderPluginFactory {
  10606. name: string;
  10607. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  10608. canDirectLoad?: (data: string) => boolean;
  10609. }
  10610. interface ISceneLoaderPlugin {
  10611. /**
  10612. * The friendly name of this plugin.
  10613. */
  10614. name: string;
  10615. /**
  10616. * The file extensions supported by this plugin.
  10617. */
  10618. extensions: string | ISceneLoaderPluginExtensions;
  10619. /**
  10620. * Import meshes into a scene.
  10621. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  10622. * @param scene The scene to import into
  10623. * @param data The data to import
  10624. * @param rootUrl The root url for scene and resources
  10625. * @param meshes The meshes array to import into
  10626. * @param particleSystems The particle systems array to import into
  10627. * @param skeletons The skeletons array to import into
  10628. * @param onError The callback when import fails
  10629. * @returns True if successful or false otherwise
  10630. */
  10631. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  10632. /**
  10633. * Load into a scene.
  10634. * @param scene The scene to load into
  10635. * @param data The data to import
  10636. * @param rootUrl The root url for scene and resources
  10637. * @param onError The callback when import fails
  10638. * @returns true if successful or false otherwise
  10639. */
  10640. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  10641. /**
  10642. * The callback that returns true if the data can be directly loaded.
  10643. */
  10644. canDirectLoad?: (data: string) => boolean;
  10645. /**
  10646. * The callback that allows custom handling of the root url based on the response url.
  10647. */
  10648. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  10649. /**
  10650. * Load into an asset container.
  10651. * @param scene The scene to load into
  10652. * @param data The data to import
  10653. * @param rootUrl The root url for scene and resources
  10654. * @param onError The callback when import fails
  10655. * @returns The loaded asset container
  10656. */
  10657. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  10658. }
  10659. interface ISceneLoaderPluginAsync {
  10660. /**
  10661. * The friendly name of this plugin.
  10662. */
  10663. name: string;
  10664. /**
  10665. * The file extensions supported by this plugin.
  10666. */
  10667. extensions: string | ISceneLoaderPluginExtensions;
  10668. /**
  10669. * Import meshes into a scene.
  10670. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  10671. * @param scene The scene to import into
  10672. * @param data The data to import
  10673. * @param rootUrl The root url for scene and resources
  10674. * @param onProgress The callback when the load progresses
  10675. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  10676. */
  10677. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  10678. meshes: AbstractMesh[];
  10679. particleSystems: ParticleSystem[];
  10680. skeletons: Skeleton[];
  10681. animationGroups: AnimationGroup[];
  10682. }>;
  10683. /**
  10684. * Load into a scene.
  10685. * @param scene The scene to load into
  10686. * @param data The data to import
  10687. * @param rootUrl The root url for scene and resources
  10688. * @param onProgress The callback when the load progresses
  10689. * @returns Nothing
  10690. */
  10691. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  10692. /**
  10693. * The callback that returns true if the data can be directly loaded.
  10694. */
  10695. canDirectLoad?: (data: string) => boolean;
  10696. /**
  10697. * The callback that allows custom handling of the root url based on the response url.
  10698. */
  10699. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  10700. /**
  10701. * Load into an asset container.
  10702. * @param scene The scene to load into
  10703. * @param data The data to import
  10704. * @param rootUrl The root url for scene and resources
  10705. * @param onProgress The callback when the load progresses
  10706. * @returns The loaded asset container
  10707. */
  10708. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  10709. }
  10710. class SceneLoader {
  10711. private static _ForceFullSceneLoadingForIncremental;
  10712. private static _ShowLoadingScreen;
  10713. private static _CleanBoneMatrixWeights;
  10714. static readonly NO_LOGGING: number;
  10715. static readonly MINIMAL_LOGGING: number;
  10716. static readonly SUMMARY_LOGGING: number;
  10717. static readonly DETAILED_LOGGING: number;
  10718. private static _loggingLevel;
  10719. static ForceFullSceneLoadingForIncremental: boolean;
  10720. static ShowLoadingScreen: boolean;
  10721. static loggingLevel: number;
  10722. static CleanBoneMatrixWeights: boolean;
  10723. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  10724. private static _registeredPlugins;
  10725. private static _getDefaultPlugin();
  10726. private static _getPluginForExtension(extension);
  10727. private static _getPluginForDirectLoad(data);
  10728. private static _getPluginForFilename(sceneFilename);
  10729. private static _getDirectLoad(sceneFilename);
  10730. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  10731. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  10732. static IsPluginForExtensionAvailable(extension: string): boolean;
  10733. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  10734. /**
  10735. * Import meshes into a scene
  10736. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  10737. * @param rootUrl a string that defines the root url for scene and resources
  10738. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  10739. * @param scene the instance of BABYLON.Scene to append to
  10740. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  10741. * @param onProgress a callback with a progress event for each file being loaded
  10742. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  10743. * @param pluginExtension the extension used to determine the plugin
  10744. * @returns The loaded plugin
  10745. */
  10746. 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>;
  10747. /**
  10748. * Import meshes into a scene
  10749. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  10750. * @param rootUrl a string that defines the root url for scene and resources
  10751. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  10752. * @param scene the instance of BABYLON.Scene to append to
  10753. * @param onProgress a callback with a progress event for each file being loaded
  10754. * @param pluginExtension the extension used to determine the plugin
  10755. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  10756. */
  10757. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  10758. meshes: AbstractMesh[];
  10759. particleSystems: ParticleSystem[];
  10760. skeletons: Skeleton[];
  10761. animationGroups: AnimationGroup[];
  10762. }>;
  10763. /**
  10764. * Load a scene
  10765. * @param rootUrl a string that defines the root url for scene and resources
  10766. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  10767. * @param engine is the instance of BABYLON.Engine to use to create the scene
  10768. * @param onSuccess a callback with the scene when import succeeds
  10769. * @param onProgress a callback with a progress event for each file being loaded
  10770. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  10771. * @param pluginExtension the extension used to determine the plugin
  10772. * @returns The loaded plugin
  10773. */
  10774. 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>;
  10775. /**
  10776. * Load a scene
  10777. * @param rootUrl a string that defines the root url for scene and resources
  10778. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  10779. * @param engine is the instance of BABYLON.Engine to use to create the scene
  10780. * @param onProgress a callback with a progress event for each file being loaded
  10781. * @param pluginExtension the extension used to determine the plugin
  10782. * @returns The loaded scene
  10783. */
  10784. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  10785. /**
  10786. * Append a scene
  10787. * @param rootUrl a string that defines the root url for scene and resources
  10788. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  10789. * @param scene is the instance of BABYLON.Scene to append to
  10790. * @param onSuccess a callback with the scene when import succeeds
  10791. * @param onProgress a callback with a progress event for each file being loaded
  10792. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  10793. * @param pluginExtension the extension used to determine the plugin
  10794. * @returns The loaded plugin
  10795. */
  10796. 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>;
  10797. /**
  10798. * Append a scene
  10799. * @param rootUrl a string that defines the root url for scene and resources
  10800. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  10801. * @param scene is the instance of BABYLON.Scene to append to
  10802. * @param onProgress a callback with a progress event for each file being loaded
  10803. * @param pluginExtension the extension used to determine the plugin
  10804. * @returns The given scene
  10805. */
  10806. static AppendAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  10807. /**
  10808. * Load a scene into an asset container
  10809. * @param rootUrl a string that defines the root url for scene and resources
  10810. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  10811. * @param scene is the instance of BABYLON.Scene to append to
  10812. * @param onSuccess a callback with the scene when import succeeds
  10813. * @param onProgress a callback with a progress event for each file being loaded
  10814. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  10815. * @param pluginExtension the extension used to determine the plugin
  10816. * @returns The loaded plugin
  10817. */
  10818. 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>;
  10819. /**
  10820. * Load a scene into an asset container
  10821. * @param rootUrl a string that defines the root url for scene and resources
  10822. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  10823. * @param scene is the instance of BABYLON.Scene to append to
  10824. * @param onProgress a callback with a progress event for each file being loaded
  10825. * @param pluginExtension the extension used to determine the plugin
  10826. * @returns The loaded asset container
  10827. */
  10828. static LoadAssetContainerAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  10829. }
  10830. }
  10831. declare module BABYLON {
  10832. /**
  10833. * A directional light is defined by a direction (what a surprise!).
  10834. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  10835. * 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.
  10836. * Documentation: https://doc.babylonjs.com/babylon101/lights
  10837. */
  10838. class DirectionalLight extends ShadowLight {
  10839. private _shadowFrustumSize;
  10840. /**
  10841. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  10842. */
  10843. /**
  10844. * Specifies a fix frustum size for the shadow generation.
  10845. */
  10846. shadowFrustumSize: number;
  10847. private _shadowOrthoScale;
  10848. /**
  10849. * Gets the shadow projection scale against the optimal computed one.
  10850. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  10851. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  10852. */
  10853. /**
  10854. * Sets the shadow projection scale against the optimal computed one.
  10855. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  10856. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  10857. */
  10858. shadowOrthoScale: number;
  10859. /**
  10860. * Automatically compute the projection matrix to best fit (including all the casters)
  10861. * on each frame.
  10862. */
  10863. autoUpdateExtends: boolean;
  10864. private _orthoLeft;
  10865. private _orthoRight;
  10866. private _orthoTop;
  10867. private _orthoBottom;
  10868. /**
  10869. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  10870. * The directional light is emitted from everywhere in the given direction.
  10871. * It can cast shawdows.
  10872. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10873. * @param name The friendly name of the light
  10874. * @param direction The direction of the light
  10875. * @param scene The scene the light belongs to
  10876. */
  10877. constructor(name: string, direction: Vector3, scene: Scene);
  10878. /**
  10879. * Returns the string "DirectionalLight".
  10880. * @return The class name
  10881. */
  10882. getClassName(): string;
  10883. /**
  10884. * Returns the integer 1.
  10885. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10886. */
  10887. getTypeID(): number;
  10888. /**
  10889. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  10890. * Returns the DirectionalLight Shadow projection matrix.
  10891. */
  10892. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10893. /**
  10894. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  10895. * Returns the DirectionalLight Shadow projection matrix.
  10896. */
  10897. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  10898. /**
  10899. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  10900. * Returns the DirectionalLight Shadow projection matrix.
  10901. */
  10902. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10903. protected _buildUniformLayout(): void;
  10904. /**
  10905. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  10906. * @param effect The effect to update
  10907. * @param lightIndex The index of the light in the effect to update
  10908. * @returns The directional light
  10909. */
  10910. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  10911. /**
  10912. * Gets the minZ used for shadow according to both the scene and the light.
  10913. *
  10914. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  10915. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  10916. * @param activeCamera The camera we are returning the min for
  10917. * @returns the depth min z
  10918. */
  10919. getDepthMinZ(activeCamera: Camera): number;
  10920. /**
  10921. * Gets the maxZ used for shadow according to both the scene and the light.
  10922. *
  10923. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  10924. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  10925. * @param activeCamera The camera we are returning the max for
  10926. * @returns the depth max z
  10927. */
  10928. getDepthMaxZ(activeCamera: Camera): number;
  10929. }
  10930. }
  10931. declare module BABYLON {
  10932. /**
  10933. * The HemisphericLight simulates the ambient environment light,
  10934. * so the passed direction is the light reflection direction, not the incoming direction.
  10935. */
  10936. class HemisphericLight extends Light {
  10937. /**
  10938. * The groundColor is the light in the opposite direction to the one specified during creation.
  10939. * 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.
  10940. */
  10941. groundColor: Color3;
  10942. /**
  10943. * The light reflection direction, not the incoming direction.
  10944. */
  10945. direction: Vector3;
  10946. private _worldMatrix;
  10947. /**
  10948. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  10949. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  10950. * The HemisphericLight can't cast shadows.
  10951. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10952. * @param name The friendly name of the light
  10953. * @param direction The direction of the light reflection
  10954. * @param scene The scene the light belongs to
  10955. */
  10956. constructor(name: string, direction: Vector3, scene: Scene);
  10957. protected _buildUniformLayout(): void;
  10958. /**
  10959. * Returns the string "HemisphericLight".
  10960. * @return The class name
  10961. */
  10962. getClassName(): string;
  10963. /**
  10964. * Sets the HemisphericLight direction towards the passed target (Vector3).
  10965. * Returns the updated direction.
  10966. * @param target The target the direction should point to
  10967. * @return The computed direction
  10968. */
  10969. setDirectionToTarget(target: Vector3): Vector3;
  10970. /**
  10971. * Returns the shadow generator associated to the light.
  10972. * @returns Always null for hemispheric lights because it does not support shadows.
  10973. */
  10974. getShadowGenerator(): Nullable<ShadowGenerator>;
  10975. /**
  10976. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  10977. * @param effect The effect to update
  10978. * @param lightIndex The index of the light in the effect to update
  10979. * @returns The hemispheric light
  10980. */
  10981. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  10982. /**
  10983. * @hidden internal use only.
  10984. */
  10985. _getWorldMatrix(): Matrix;
  10986. /**
  10987. * Returns the integer 3.
  10988. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10989. */
  10990. getTypeID(): number;
  10991. }
  10992. }
  10993. declare module BABYLON {
  10994. /**
  10995. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10996. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10997. * 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.
  10998. */
  10999. abstract class Light extends Node {
  11000. private static _LIGHTMAP_DEFAULT;
  11001. private static _LIGHTMAP_SPECULAR;
  11002. private static _LIGHTMAP_SHADOWSONLY;
  11003. /**
  11004. * If every light affecting the material is in this lightmapMode,
  11005. * material.lightmapTexture adds or multiplies
  11006. * (depends on material.useLightmapAsShadowmap)
  11007. * after every other light calculations.
  11008. */
  11009. static readonly LIGHTMAP_DEFAULT: number;
  11010. /**
  11011. * material.lightmapTexture as only diffuse lighting from this light
  11012. * adds only specular lighting from this light
  11013. * adds dynamic shadows
  11014. */
  11015. static readonly LIGHTMAP_SPECULAR: number;
  11016. /**
  11017. * material.lightmapTexture as only lighting
  11018. * no light calculation from this light
  11019. * only adds dynamic shadows from this light
  11020. */
  11021. static readonly LIGHTMAP_SHADOWSONLY: number;
  11022. private static _INTENSITYMODE_AUTOMATIC;
  11023. private static _INTENSITYMODE_LUMINOUSPOWER;
  11024. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  11025. private static _INTENSITYMODE_ILLUMINANCE;
  11026. private static _INTENSITYMODE_LUMINANCE;
  11027. /**
  11028. * Each light type uses the default quantity according to its type:
  11029. * point/spot lights use luminous intensity
  11030. * directional lights use illuminance
  11031. */
  11032. static readonly INTENSITYMODE_AUTOMATIC: number;
  11033. /**
  11034. * lumen (lm)
  11035. */
  11036. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11037. /**
  11038. * candela (lm/sr)
  11039. */
  11040. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11041. /**
  11042. * lux (lm/m^2)
  11043. */
  11044. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11045. /**
  11046. * nit (cd/m^2)
  11047. */
  11048. static readonly INTENSITYMODE_LUMINANCE: number;
  11049. private static _LIGHTTYPEID_POINTLIGHT;
  11050. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  11051. private static _LIGHTTYPEID_SPOTLIGHT;
  11052. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  11053. /**
  11054. * Light type const id of the point light.
  11055. */
  11056. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11057. /**
  11058. * Light type const id of the directional light.
  11059. */
  11060. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11061. /**
  11062. * Light type const id of the spot light.
  11063. */
  11064. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11065. /**
  11066. * Light type const id of the hemispheric light.
  11067. */
  11068. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11069. /**
  11070. * Diffuse gives the basic color to an object.
  11071. */
  11072. diffuse: Color3;
  11073. /**
  11074. * Specular produces a highlight color on an object.
  11075. * Note: This is note affecting PBR materials.
  11076. */
  11077. specular: Color3;
  11078. /**
  11079. * Strength of the light.
  11080. * Note: By default it is define in the framework own unit.
  11081. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11082. */
  11083. intensity: number;
  11084. /**
  11085. * Defines how far from the source the light is impacting in scene units.
  11086. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11087. */
  11088. range: number;
  11089. /**
  11090. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11091. * of light.
  11092. */
  11093. private _photometricScale;
  11094. private _intensityMode;
  11095. /**
  11096. * Gets the photometric scale used to interpret the intensity.
  11097. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11098. */
  11099. /**
  11100. * Sets the photometric scale used to interpret the intensity.
  11101. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11102. */
  11103. intensityMode: number;
  11104. private _radius;
  11105. /**
  11106. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11107. */
  11108. /**
  11109. * sets the light radius used by PBR Materials to simulate soft area lights.
  11110. */
  11111. radius: number;
  11112. private _renderPriority;
  11113. /**
  11114. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11115. * exceeding the number allowed of the materials.
  11116. */
  11117. renderPriority: number;
  11118. /**
  11119. * Defines wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11120. * the current shadow generator.
  11121. */
  11122. shadowEnabled: boolean;
  11123. private _includedOnlyMeshes;
  11124. /**
  11125. * Gets the only meshes impacted by this light.
  11126. */
  11127. /**
  11128. * Sets the only meshes impacted by this light.
  11129. */
  11130. includedOnlyMeshes: AbstractMesh[];
  11131. private _excludedMeshes;
  11132. /**
  11133. * Gets the meshes not impacted by this light.
  11134. */
  11135. /**
  11136. * Sets the meshes not impacted by this light.
  11137. */
  11138. excludedMeshes: AbstractMesh[];
  11139. private _excludeWithLayerMask;
  11140. /**
  11141. * Gets the layer id use to find what meshes are not impacted by the light.
  11142. * Inactive if 0
  11143. */
  11144. /**
  11145. * Sets the layer id use to find what meshes are not impacted by the light.
  11146. * Inactive if 0
  11147. */
  11148. excludeWithLayerMask: number;
  11149. private _includeOnlyWithLayerMask;
  11150. /**
  11151. * Gets the layer id use to find what meshes are impacted by the light.
  11152. * Inactive if 0
  11153. */
  11154. /**
  11155. * Sets the layer id use to find what meshes are impacted by the light.
  11156. * Inactive if 0
  11157. */
  11158. includeOnlyWithLayerMask: number;
  11159. private _lightmapMode;
  11160. /**
  11161. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11162. */
  11163. /**
  11164. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11165. */
  11166. lightmapMode: number;
  11167. private _parentedWorldMatrix;
  11168. /**
  11169. * Shadow generator associted to the light.
  11170. * Internal use only.
  11171. */
  11172. _shadowGenerator: Nullable<IShadowGenerator>;
  11173. /**
  11174. * @hidden Internal use only.
  11175. */
  11176. _excludedMeshesIds: string[];
  11177. /**
  11178. * @hidden Internal use only.
  11179. */
  11180. _includedOnlyMeshesIds: string[];
  11181. /**
  11182. * The current light unifom buffer.
  11183. * @hidden Internal use only.
  11184. */
  11185. _uniformBuffer: UniformBuffer;
  11186. /**
  11187. * Creates a Light object in the scene.
  11188. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11189. * @param name The firendly name of the light
  11190. * @param scene The scene the light belongs too
  11191. */
  11192. constructor(name: string, scene: Scene);
  11193. protected abstract _buildUniformLayout(): void;
  11194. /**
  11195. * Sets the passed Effect "effect" with the Light information.
  11196. * @param effect The effect to update
  11197. * @param lightIndex The index of the light in the effect to update
  11198. * @returns The light
  11199. */
  11200. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11201. /**
  11202. * @hidden internal use only.
  11203. */
  11204. abstract _getWorldMatrix(): Matrix;
  11205. /**
  11206. * Returns the string "Light".
  11207. * @returns the class name
  11208. */
  11209. getClassName(): string;
  11210. /**
  11211. * Converts the light information to a readable string for debug purpose.
  11212. * @param fullDetails Supports for multiple levels of logging within scene loading
  11213. * @returns the human readable light info
  11214. */
  11215. toString(fullDetails?: boolean): string;
  11216. /**
  11217. * Set the enabled state of this node.
  11218. * @param value - the new enabled state
  11219. */
  11220. setEnabled(value: boolean): void;
  11221. /**
  11222. * Returns the Light associated shadow generator if any.
  11223. * @return the associated shadow generator.
  11224. */
  11225. getShadowGenerator(): Nullable<IShadowGenerator>;
  11226. /**
  11227. * Returns a Vector3, the absolute light position in the World.
  11228. * @returns the world space position of the light
  11229. */
  11230. getAbsolutePosition(): Vector3;
  11231. /**
  11232. * Specifies if the light will affect the passed mesh.
  11233. * @param mesh The mesh to test against the light
  11234. * @return true the mesh is affected otherwise, false.
  11235. */
  11236. canAffectMesh(mesh: AbstractMesh): boolean;
  11237. /**
  11238. * Computes and Returns the light World matrix.
  11239. * @returns the world matrix
  11240. */
  11241. getWorldMatrix(): Matrix;
  11242. /**
  11243. * Sort function to order lights for rendering.
  11244. * @param a First Light object to compare to second.
  11245. * @param b Second Light object to compare first.
  11246. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11247. */
  11248. static CompareLightsPriority(a: Light, b: Light): number;
  11249. /**
  11250. * Releases resources associated with this node.
  11251. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11252. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11253. */
  11254. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11255. /**
  11256. * Returns the light type ID (integer).
  11257. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11258. */
  11259. getTypeID(): number;
  11260. /**
  11261. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11262. * @returns the scaled intensity in intensity mode unit
  11263. */
  11264. getScaledIntensity(): number;
  11265. /**
  11266. * Returns a new Light object, named "name", from the current one.
  11267. * @param name The name of the cloned light
  11268. * @returns the new created light
  11269. */
  11270. clone(name: string): Nullable<Light>;
  11271. /**
  11272. * Serializes the current light into a Serialization object.
  11273. * @returns the serialized object.
  11274. */
  11275. serialize(): any;
  11276. /**
  11277. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11278. * This new light is named "name" and added to the passed scene.
  11279. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11280. * @param name The friendly name of the light
  11281. * @param scene The scene the new light will belong to
  11282. * @returns the constructor function
  11283. */
  11284. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11285. /**
  11286. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11287. * @param parsedLight The JSON representation of the light
  11288. * @param scene The scene to create the parsed light in
  11289. * @returns the created light after parsing
  11290. */
  11291. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11292. private _hookArrayForExcluded(array);
  11293. private _hookArrayForIncludedOnly(array);
  11294. private _resyncMeshes();
  11295. /**
  11296. * Forces the meshes to update their light related information in their rendering used effects
  11297. * @hidden Internal Use Only
  11298. */
  11299. _markMeshesAsLightDirty(): void;
  11300. /**
  11301. * Recomputes the cached photometric scale if needed.
  11302. */
  11303. private _computePhotometricScale();
  11304. /**
  11305. * Returns the Photometric Scale according to the light type and intensity mode.
  11306. */
  11307. private _getPhotometricScale();
  11308. /**
  11309. * Reorder the light in the scene according to their defined priority.
  11310. * @hidden Internal Use Only
  11311. */
  11312. _reorderLightsInScene(): void;
  11313. }
  11314. }
  11315. declare module BABYLON {
  11316. /**
  11317. * A point light is a light defined by an unique point in world space.
  11318. * The light is emitted in every direction from this point.
  11319. * A good example of a point light is a standard light bulb.
  11320. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11321. */
  11322. class PointLight extends ShadowLight {
  11323. private _shadowAngle;
  11324. /**
  11325. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11326. * This specifies what angle the shadow will use to be created.
  11327. *
  11328. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11329. */
  11330. /**
  11331. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11332. * This specifies what angle the shadow will use to be created.
  11333. *
  11334. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11335. */
  11336. shadowAngle: number;
  11337. /**
  11338. * Gets the direction if it has been set.
  11339. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11340. */
  11341. /**
  11342. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11343. */
  11344. direction: Vector3;
  11345. /**
  11346. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  11347. * A PointLight emits the light in every direction.
  11348. * It can cast shadows.
  11349. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  11350. * ```javascript
  11351. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  11352. * ```
  11353. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11354. * @param name The light friendly name
  11355. * @param position The position of the point light in the scene
  11356. * @param scene The scene the lights belongs to
  11357. */
  11358. constructor(name: string, position: Vector3, scene: Scene);
  11359. /**
  11360. * Returns the string "PointLight"
  11361. * @returns the class name
  11362. */
  11363. getClassName(): string;
  11364. /**
  11365. * Returns the integer 0.
  11366. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11367. */
  11368. getTypeID(): number;
  11369. /**
  11370. * Specifies wether or not the shadowmap should be a cube texture.
  11371. * @returns true if the shadowmap needs to be a cube texture.
  11372. */
  11373. needCube(): boolean;
  11374. /**
  11375. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  11376. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11377. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11378. */
  11379. getShadowDirection(faceIndex?: number): Vector3;
  11380. /**
  11381. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  11382. * - fov = PI / 2
  11383. * - aspect ratio : 1.0
  11384. * - z-near and far equal to the active camera minZ and maxZ.
  11385. * Returns the PointLight.
  11386. */
  11387. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11388. protected _buildUniformLayout(): void;
  11389. /**
  11390. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  11391. * @param effect The effect to update
  11392. * @param lightIndex The index of the light in the effect to update
  11393. * @returns The point light
  11394. */
  11395. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  11396. }
  11397. }
  11398. declare module BABYLON {
  11399. /**
  11400. * Interface describing all the common properties and methods a shadow light needs to implement.
  11401. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  11402. * as well as binding the different shadow properties to the effects.
  11403. */
  11404. interface IShadowLight extends Light {
  11405. /**
  11406. * The light id in the scene (used in scene.findLighById for instance)
  11407. */
  11408. id: string;
  11409. /**
  11410. * The position the shdow will be casted from.
  11411. */
  11412. position: Vector3;
  11413. /**
  11414. * In 2d mode (needCube being false), the direction used to cast the shadow.
  11415. */
  11416. direction: Vector3;
  11417. /**
  11418. * The transformed position. Position of the light in world space taking parenting in account.
  11419. */
  11420. transformedPosition: Vector3;
  11421. /**
  11422. * The transformed direction. Direction of the light in world space taking parenting in account.
  11423. */
  11424. transformedDirection: Vector3;
  11425. /**
  11426. * The friendly name of the light in the scene.
  11427. */
  11428. name: string;
  11429. /**
  11430. * Defines the shadow projection clipping minimum z value.
  11431. */
  11432. shadowMinZ: number;
  11433. /**
  11434. * Defines the shadow projection clipping maximum z value.
  11435. */
  11436. shadowMaxZ: number;
  11437. /**
  11438. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11439. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11440. */
  11441. computeTransformedInformation(): boolean;
  11442. /**
  11443. * Gets the scene the light belongs to.
  11444. * @returns The scene
  11445. */
  11446. getScene(): Scene;
  11447. /**
  11448. * Callback defining a custom Projection Matrix Builder.
  11449. * This can be used to override the default projection matrix computation.
  11450. */
  11451. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11452. /**
  11453. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11454. * @param matrix The materix to updated with the projection information
  11455. * @param viewMatrix The transform matrix of the light
  11456. * @param renderList The list of mesh to render in the map
  11457. * @returns The current light
  11458. */
  11459. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11460. /**
  11461. * Gets the current depth scale used in ESM.
  11462. * @returns The scale
  11463. */
  11464. getDepthScale(): number;
  11465. /**
  11466. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11467. * @returns true if a cube texture needs to be use
  11468. */
  11469. needCube(): boolean;
  11470. /**
  11471. * Detects if the projection matrix requires to be recomputed this frame.
  11472. * @returns true if it requires to be recomputed otherwise, false.
  11473. */
  11474. needProjectionMatrixCompute(): boolean;
  11475. /**
  11476. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11477. */
  11478. forceProjectionMatrixCompute(): void;
  11479. /**
  11480. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11481. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11482. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11483. */
  11484. getShadowDirection(faceIndex?: number): Vector3;
  11485. /**
  11486. * Gets the minZ used for shadow according to both the scene and the light.
  11487. * @param activeCamera The camera we are returning the min for
  11488. * @returns the depth min z
  11489. */
  11490. getDepthMinZ(activeCamera: Camera): number;
  11491. /**
  11492. * Gets the maxZ used for shadow according to both the scene and the light.
  11493. * @param activeCamera The camera we are returning the max for
  11494. * @returns the depth max z
  11495. */
  11496. getDepthMaxZ(activeCamera: Camera): number;
  11497. }
  11498. /**
  11499. * Base implementation IShadowLight
  11500. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  11501. */
  11502. abstract class ShadowLight extends Light implements IShadowLight {
  11503. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11504. protected _position: Vector3;
  11505. protected _setPosition(value: Vector3): void;
  11506. /**
  11507. * Sets the position the shadow will be casted from. Also use as the light position for both
  11508. * point and spot lights.
  11509. */
  11510. /**
  11511. * Sets the position the shadow will be casted from. Also use as the light position for both
  11512. * point and spot lights.
  11513. */
  11514. position: Vector3;
  11515. protected _direction: Vector3;
  11516. protected _setDirection(value: Vector3): void;
  11517. /**
  11518. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  11519. * Also use as the light direction on spot and directional lights.
  11520. */
  11521. /**
  11522. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  11523. * Also use as the light direction on spot and directional lights.
  11524. */
  11525. direction: Vector3;
  11526. private _shadowMinZ;
  11527. /**
  11528. * Gets the shadow projection clipping minimum z value.
  11529. */
  11530. /**
  11531. * Sets the shadow projection clipping minimum z value.
  11532. */
  11533. shadowMinZ: number;
  11534. private _shadowMaxZ;
  11535. /**
  11536. * Sets the shadow projection clipping maximum z value.
  11537. */
  11538. /**
  11539. * Gets the shadow projection clipping maximum z value.
  11540. */
  11541. shadowMaxZ: number;
  11542. /**
  11543. * Callback defining a custom Projection Matrix Builder.
  11544. * This can be used to override the default projection matrix computation.
  11545. */
  11546. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11547. /**
  11548. * The transformed position. Position of the light in world space taking parenting in account.
  11549. */
  11550. transformedPosition: Vector3;
  11551. /**
  11552. * The transformed direction. Direction of the light in world space taking parenting in account.
  11553. */
  11554. transformedDirection: Vector3;
  11555. private _worldMatrix;
  11556. private _needProjectionMatrixCompute;
  11557. /**
  11558. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11559. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11560. */
  11561. computeTransformedInformation(): boolean;
  11562. /**
  11563. * Return the depth scale used for the shadow map.
  11564. * @returns the depth scale.
  11565. */
  11566. getDepthScale(): number;
  11567. /**
  11568. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11569. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11570. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11571. */
  11572. getShadowDirection(faceIndex?: number): Vector3;
  11573. /**
  11574. * Returns the ShadowLight absolute position in the World.
  11575. * @returns the position vector in world space
  11576. */
  11577. getAbsolutePosition(): Vector3;
  11578. /**
  11579. * Sets the ShadowLight direction toward the passed target.
  11580. * @param target The point tot target in local space
  11581. * @returns the updated ShadowLight direction
  11582. */
  11583. setDirectionToTarget(target: Vector3): Vector3;
  11584. /**
  11585. * Returns the light rotation in euler definition.
  11586. * @returns the x y z rotation in local space.
  11587. */
  11588. getRotation(): Vector3;
  11589. /**
  11590. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11591. * @returns true if a cube texture needs to be use
  11592. */
  11593. needCube(): boolean;
  11594. /**
  11595. * Detects if the projection matrix requires to be recomputed this frame.
  11596. * @returns true if it requires to be recomputed otherwise, false.
  11597. */
  11598. needProjectionMatrixCompute(): boolean;
  11599. /**
  11600. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11601. */
  11602. forceProjectionMatrixCompute(): void;
  11603. /**
  11604. * Get the world matrix of the sahdow lights.
  11605. * @hidden Internal Use Only
  11606. */
  11607. _getWorldMatrix(): Matrix;
  11608. /**
  11609. * Gets the minZ used for shadow according to both the scene and the light.
  11610. * @param activeCamera The camera we are returning the min for
  11611. * @returns the depth min z
  11612. */
  11613. getDepthMinZ(activeCamera: Camera): number;
  11614. /**
  11615. * Gets the maxZ used for shadow according to both the scene and the light.
  11616. * @param activeCamera The camera we are returning the max for
  11617. * @returns the depth max z
  11618. */
  11619. getDepthMaxZ(activeCamera: Camera): number;
  11620. /**
  11621. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11622. * @param matrix The materix to updated with the projection information
  11623. * @param viewMatrix The transform matrix of the light
  11624. * @param renderList The list of mesh to render in the map
  11625. * @returns The current light
  11626. */
  11627. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11628. }
  11629. }
  11630. declare module BABYLON {
  11631. /**
  11632. * A spot light is defined by a position, a direction, an angle, and an exponent.
  11633. * These values define a cone of light starting from the position, emitting toward the direction.
  11634. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  11635. * and the exponent defines the speed of the decay of the light with distance (reach).
  11636. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11637. */
  11638. class SpotLight extends ShadowLight {
  11639. private _angle;
  11640. /**
  11641. * Gets the cone angle of the spot light in Radians.
  11642. */
  11643. /**
  11644. * Sets the cone angle of the spot light in Radians.
  11645. */
  11646. angle: number;
  11647. private _shadowAngleScale;
  11648. /**
  11649. * Allows scaling the angle of the light for shadow generation only.
  11650. */
  11651. /**
  11652. * Allows scaling the angle of the light for shadow generation only.
  11653. */
  11654. shadowAngleScale: number;
  11655. /**
  11656. * The light decay speed with the distance from the emission spot.
  11657. */
  11658. exponent: number;
  11659. private _projectionTextureMatrix;
  11660. /**
  11661. * Allows reading the projecton texture
  11662. */
  11663. readonly projectionTextureMatrix: Matrix;
  11664. protected _projectionTextureLightNear: number;
  11665. /**
  11666. * Gets the near clip of the Spotlight for texture projection.
  11667. */
  11668. /**
  11669. * Sets the near clip of the Spotlight for texture projection.
  11670. */
  11671. projectionTextureLightNear: number;
  11672. protected _projectionTextureLightFar: number;
  11673. /**
  11674. * Gets the far clip of the Spotlight for texture projection.
  11675. */
  11676. /**
  11677. * Sets the far clip of the Spotlight for texture projection.
  11678. */
  11679. projectionTextureLightFar: number;
  11680. protected _projectionTextureUpDirection: Vector3;
  11681. /**
  11682. * Gets the Up vector of the Spotlight for texture projection.
  11683. */
  11684. /**
  11685. * Sets the Up vector of the Spotlight for texture projection.
  11686. */
  11687. projectionTextureUpDirection: Vector3;
  11688. private _projectionTexture;
  11689. /**
  11690. * Gets the projection texture of the light.
  11691. */
  11692. /**
  11693. * Sets the projection texture of the light.
  11694. */
  11695. projectionTexture: Nullable<BaseTexture>;
  11696. private _projectionTextureViewLightDirty;
  11697. private _projectionTextureProjectionLightDirty;
  11698. private _projectionTextureDirty;
  11699. private _projectionTextureViewTargetVector;
  11700. private _projectionTextureViewLightMatrix;
  11701. private _projectionTextureProjectionLightMatrix;
  11702. private _projectionTextureScalingMatrix;
  11703. /**
  11704. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  11705. * It can cast shadows.
  11706. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11707. * @param name The light friendly name
  11708. * @param position The position of the spot light in the scene
  11709. * @param direction The direction of the light in the scene
  11710. * @param angle The cone angle of the light in Radians
  11711. * @param exponent The light decay speed with the distance from the emission spot
  11712. * @param scene The scene the lights belongs to
  11713. */
  11714. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  11715. /**
  11716. * Returns the string "SpotLight".
  11717. * @returns the class name
  11718. */
  11719. getClassName(): string;
  11720. /**
  11721. * Returns the integer 2.
  11722. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11723. */
  11724. getTypeID(): number;
  11725. /**
  11726. * Overrides the direction setter to recompute the projection texture view light Matrix.
  11727. */
  11728. protected _setDirection(value: Vector3): void;
  11729. /**
  11730. * Overrides the position setter to recompute the projection texture view light Matrix.
  11731. */
  11732. protected _setPosition(value: Vector3): void;
  11733. /**
  11734. * 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.
  11735. * Returns the SpotLight.
  11736. */
  11737. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11738. protected _computeProjectionTextureViewLightMatrix(): void;
  11739. protected _computeProjectionTextureProjectionLightMatrix(): void;
  11740. /**
  11741. * Main function for light texture projection matrix computing.
  11742. */
  11743. protected _computeProjectionTextureMatrix(): void;
  11744. protected _buildUniformLayout(): void;
  11745. /**
  11746. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  11747. * @param effect The effect to update
  11748. * @param lightIndex The index of the light in the effect to update
  11749. * @returns The spot light
  11750. */
  11751. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  11752. /**
  11753. * Disposes the light and the associated resources.
  11754. */
  11755. dispose(): void;
  11756. }
  11757. }
  11758. declare module BABYLON {
  11759. class Scalar {
  11760. /**
  11761. * Two pi constants convenient for computation.
  11762. */
  11763. static TwoPi: number;
  11764. /**
  11765. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  11766. */
  11767. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  11768. /**
  11769. * Returns a string : the upper case translation of the number i to hexadecimal.
  11770. */
  11771. static ToHex(i: number): string;
  11772. /**
  11773. * Returns -1 if value is negative and +1 is value is positive.
  11774. * Returns the value itself if it's equal to zero.
  11775. */
  11776. static Sign(value: number): number;
  11777. /**
  11778. * Returns the value itself if it's between min and max.
  11779. * Returns min if the value is lower than min.
  11780. * Returns max if the value is greater than max.
  11781. */
  11782. static Clamp(value: number, min?: number, max?: number): number;
  11783. /**
  11784. * Returns the log2 of value.
  11785. */
  11786. static Log2(value: number): number;
  11787. /**
  11788. * Loops the value, so that it is never larger than length and never smaller than 0.
  11789. *
  11790. * This is similar to the modulo operator but it works with floating point numbers.
  11791. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  11792. * With t = 5 and length = 2.5, the result would be 0.0.
  11793. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  11794. */
  11795. static Repeat(value: number, length: number): number;
  11796. /**
  11797. * Normalize the value between 0.0 and 1.0 using min and max values
  11798. */
  11799. static Normalize(value: number, min: number, max: number): number;
  11800. /**
  11801. * Denormalize the value from 0.0 and 1.0 using min and max values
  11802. */
  11803. static Denormalize(normalized: number, min: number, max: number): number;
  11804. /**
  11805. * Calculates the shortest difference between two given angles given in degrees.
  11806. */
  11807. static DeltaAngle(current: number, target: number): number;
  11808. /**
  11809. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  11810. *
  11811. * The returned value will move back and forth between 0 and length
  11812. */
  11813. static PingPong(tx: number, length: number): number;
  11814. /**
  11815. * Interpolates between min and max with smoothing at the limits.
  11816. *
  11817. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  11818. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  11819. */
  11820. static SmoothStep(from: number, to: number, tx: number): number;
  11821. /**
  11822. * Moves a value current towards target.
  11823. *
  11824. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  11825. * Negative values of maxDelta pushes the value away from target.
  11826. */
  11827. static MoveTowards(current: number, target: number, maxDelta: number): number;
  11828. /**
  11829. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  11830. *
  11831. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  11832. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  11833. */
  11834. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  11835. /**
  11836. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  11837. */
  11838. static Lerp(start: number, end: number, amount: number): number;
  11839. /**
  11840. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  11841. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  11842. */
  11843. static LerpAngle(start: number, end: number, amount: number): number;
  11844. /**
  11845. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  11846. */
  11847. static InverseLerp(a: number, b: number, value: number): number;
  11848. /**
  11849. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  11850. */
  11851. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  11852. /**
  11853. * Returns a random float number between and min and max values
  11854. */
  11855. static RandomRange(min: number, max: number): number;
  11856. /**
  11857. * This function returns percentage of a number in a given range.
  11858. *
  11859. * RangeToPercent(40,20,60) will return 0.5 (50%)
  11860. * RangeToPercent(34,0,100) will return 0.34 (34%)
  11861. */
  11862. static RangeToPercent(number: number, min: number, max: number): number;
  11863. /**
  11864. * This function returns number that corresponds to the percentage in a given range.
  11865. *
  11866. * PercentToRange(0.34,0,100) will return 34.
  11867. */
  11868. static PercentToRange(percent: number, min: number, max: number): number;
  11869. /**
  11870. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  11871. * @param angle The angle to normalize in radian.
  11872. * @return The converted angle.
  11873. */
  11874. static NormalizeRadians(angle: number): number;
  11875. }
  11876. }
  11877. declare module BABYLON {
  11878. const ToGammaSpace: number;
  11879. const ToLinearSpace = 2.2;
  11880. const Epsilon = 0.001;
  11881. /**
  11882. * Class used to hold a RBG color
  11883. */
  11884. class Color3 {
  11885. /**
  11886. * Defines the red component (between 0 and 1, default is 0)
  11887. */
  11888. r: number;
  11889. /**
  11890. * Defines the green component (between 0 and 1, default is 0)
  11891. */
  11892. g: number;
  11893. /**
  11894. * Defines the blue component (between 0 and 1, default is 0)
  11895. */
  11896. b: number;
  11897. /**
  11898. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  11899. * @param r defines the red component (between 0 and 1, default is 0)
  11900. * @param g defines the green component (between 0 and 1, default is 0)
  11901. * @param b defines the blue component (between 0 and 1, default is 0)
  11902. */
  11903. constructor(
  11904. /**
  11905. * Defines the red component (between 0 and 1, default is 0)
  11906. */
  11907. r?: number,
  11908. /**
  11909. * Defines the green component (between 0 and 1, default is 0)
  11910. */
  11911. g?: number,
  11912. /**
  11913. * Defines the blue component (between 0 and 1, default is 0)
  11914. */
  11915. b?: number);
  11916. /**
  11917. * Creates a string with the Color3 current values
  11918. * @returns the string representation of the Color3 object
  11919. */
  11920. toString(): string;
  11921. /**
  11922. * Returns the string "Color3"
  11923. * @returns "Color3"
  11924. */
  11925. getClassName(): string;
  11926. /**
  11927. * Compute the Color3 hash code
  11928. * @returns an unique number that can be used to hash Color3 objects
  11929. */
  11930. getHashCode(): number;
  11931. /**
  11932. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  11933. * @param array defines the array where to store the r,g,b components
  11934. * @param index defines an optional index in the target array to define where to start storing values
  11935. * @returns the current Color3 object
  11936. */
  11937. toArray(array: FloatArray, index?: number): Color3;
  11938. /**
  11939. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  11940. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  11941. * @returns a new {BABYLON.Color4} object
  11942. */
  11943. toColor4(alpha?: number): Color4;
  11944. /**
  11945. * Returns a new array populated with 3 numeric elements : red, green and blue values
  11946. * @returns the new array
  11947. */
  11948. asArray(): number[];
  11949. /**
  11950. * Returns the luminance value
  11951. * @returns a float value
  11952. */
  11953. toLuminance(): number;
  11954. /**
  11955. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  11956. * @param otherColor defines the second operand
  11957. * @returns the new Color3 object
  11958. */
  11959. multiply(otherColor: Color3): Color3;
  11960. /**
  11961. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  11962. * @param otherColor defines the second operand
  11963. * @param result defines the Color3 object where to store the result
  11964. * @returns the current Color3
  11965. */
  11966. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  11967. /**
  11968. * Determines equality between Color3 objects
  11969. * @param otherColor defines the second operand
  11970. * @returns true if the rgb values are equal to the given ones
  11971. */
  11972. equals(otherColor: Color3): boolean;
  11973. /**
  11974. * Determines equality between the current Color3 object and a set of r,b,g values
  11975. * @param r defines the red component to check
  11976. * @param g defines the green component to check
  11977. * @param b defines the blue component to check
  11978. * @returns true if the rgb values are equal to the given ones
  11979. */
  11980. equalsFloats(r: number, g: number, b: number): boolean;
  11981. /**
  11982. * Multiplies in place each rgb value by scale
  11983. * @param scale defines the scaling factor
  11984. * @returns the updated Color3
  11985. */
  11986. scale(scale: number): Color3;
  11987. /**
  11988. * Multiplies the rgb values by scale and stores the result into "result"
  11989. * @param scale defines the scaling factor
  11990. * @param result defines the Color3 object where to store the result
  11991. * @returns the unmodified current Color3
  11992. */
  11993. scaleToRef(scale: number, result: Color3): Color3;
  11994. /**
  11995. * Scale the current Color3 values by a factor and add the result to a given Color3
  11996. * @param scale defines the scale factor
  11997. * @param result defines color to store the result into
  11998. * @returns the unmodified current Color3
  11999. */
  12000. scaleAndAddToRef(scale: number, result: Color3): Color3;
  12001. /**
  12002. * Clamps the rgb values by the min and max values and stores the result into "result"
  12003. * @param min defines minimum clamping value (default is 0)
  12004. * @param max defines maximum clamping value (default is 1)
  12005. * @param result defines color to store the result into
  12006. * @returns the original Color3
  12007. */
  12008. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  12009. /**
  12010. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  12011. * @param otherColor defines the second operand
  12012. * @returns the new Color3
  12013. */
  12014. add(otherColor: Color3): Color3;
  12015. /**
  12016. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  12017. * @param otherColor defines the second operand
  12018. * @param result defines Color3 object to store the result into
  12019. * @returns the unmodified current Color3
  12020. */
  12021. addToRef(otherColor: Color3, result: Color3): Color3;
  12022. /**
  12023. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  12024. * @param otherColor defines the second operand
  12025. * @returns the new Color3
  12026. */
  12027. subtract(otherColor: Color3): Color3;
  12028. /**
  12029. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  12030. * @param otherColor defines the second operand
  12031. * @param result defines Color3 object to store the result into
  12032. * @returns the unmodified current Color3
  12033. */
  12034. subtractToRef(otherColor: Color3, result: Color3): Color3;
  12035. /**
  12036. * Copy the current object
  12037. * @returns a new Color3 copied the current one
  12038. */
  12039. clone(): Color3;
  12040. /**
  12041. * Copies the rgb values from the source in the current Color3
  12042. * @param source defines the source Color3 object
  12043. * @returns the updated Color3 object
  12044. */
  12045. copyFrom(source: Color3): Color3;
  12046. /**
  12047. * Updates the Color3 rgb values from the given floats
  12048. * @param r defines the red component to read from
  12049. * @param g defines the green component to read from
  12050. * @param b defines the blue component to read from
  12051. * @returns the current Color3 object
  12052. */
  12053. copyFromFloats(r: number, g: number, b: number): Color3;
  12054. /**
  12055. * Updates the Color3 rgb values from the given floats
  12056. * @param r defines the red component to read from
  12057. * @param g defines the green component to read from
  12058. * @param b defines the blue component to read from
  12059. * @returns the current Color3 object
  12060. */
  12061. set(r: number, g: number, b: number): Color3;
  12062. /**
  12063. * Compute the Color3 hexadecimal code as a string
  12064. * @returns a string containing the hexadecimal representation of the Color3 object
  12065. */
  12066. toHexString(): string;
  12067. /**
  12068. * Computes a new Color3 converted from the current one to linear space
  12069. * @returns a new Color3 object
  12070. */
  12071. toLinearSpace(): Color3;
  12072. /**
  12073. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  12074. * @param convertedColor defines the Color3 object where to store the linear space version
  12075. * @returns the unmodified Color3
  12076. */
  12077. toLinearSpaceToRef(convertedColor: Color3): Color3;
  12078. /**
  12079. * Computes a new Color3 converted from the current one to gamma space
  12080. * @returns a new Color3 object
  12081. */
  12082. toGammaSpace(): Color3;
  12083. /**
  12084. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  12085. * @param convertedColor defines the Color3 object where to store the gamma space version
  12086. * @returns the unmodified Color3
  12087. */
  12088. toGammaSpaceToRef(convertedColor: Color3): Color3;
  12089. /**
  12090. * Creates a new Color3 from the string containing valid hexadecimal values
  12091. * @param hex defines a string containing valid hexadecimal values
  12092. * @returns a new Color3 object
  12093. */
  12094. static FromHexString(hex: string): Color3;
  12095. /**
  12096. * Creates a new Vector3 from the starting index of the given array
  12097. * @param array defines the source array
  12098. * @param offset defines an offset in the source array
  12099. * @returns a new Color3 object
  12100. */
  12101. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  12102. /**
  12103. * Creates a new Color3 from integer values (< 256)
  12104. * @param r defines the red component to read from (value between 0 and 255)
  12105. * @param g defines the green component to read from (value between 0 and 255)
  12106. * @param b defines the blue component to read from (value between 0 and 255)
  12107. * @returns a new Color3 object
  12108. */
  12109. static FromInts(r: number, g: number, b: number): Color3;
  12110. /**
  12111. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  12112. * @param start defines the start Color3 value
  12113. * @param end defines the end Color3 value
  12114. * @param amount defines the gradient value between start and end
  12115. * @returns a new Color3 object
  12116. */
  12117. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  12118. /**
  12119. * Returns a Color3 value containing a red color
  12120. * @returns a new Color3 object
  12121. */
  12122. static Red(): Color3;
  12123. /**
  12124. * Returns a Color3 value containing a green color
  12125. * @returns a new Color3 object
  12126. */
  12127. static Green(): Color3;
  12128. /**
  12129. * Returns a Color3 value containing a blue color
  12130. * @returns a new Color3 object
  12131. */
  12132. static Blue(): Color3;
  12133. /**
  12134. * Returns a Color3 value containing a black color
  12135. * @returns a new Color3 object
  12136. */
  12137. static Black(): Color3;
  12138. /**
  12139. * Returns a Color3 value containing a white color
  12140. * @returns a new Color3 object
  12141. */
  12142. static White(): Color3;
  12143. /**
  12144. * Returns a Color3 value containing a purple color
  12145. * @returns a new Color3 object
  12146. */
  12147. static Purple(): Color3;
  12148. /**
  12149. * Returns a Color3 value containing a magenta color
  12150. * @returns a new Color3 object
  12151. */
  12152. static Magenta(): Color3;
  12153. /**
  12154. * Returns a Color3 value containing a yellow color
  12155. * @returns a new Color3 object
  12156. */
  12157. static Yellow(): Color3;
  12158. /**
  12159. * Returns a Color3 value containing a gray color
  12160. * @returns a new Color3 object
  12161. */
  12162. static Gray(): Color3;
  12163. /**
  12164. * Returns a Color3 value containing a teal color
  12165. * @returns a new Color3 object
  12166. */
  12167. static Teal(): Color3;
  12168. /**
  12169. * Returns a Color3 value containing a random color
  12170. * @returns a new Color3 object
  12171. */
  12172. static Random(): Color3;
  12173. }
  12174. /**
  12175. * Class used to hold a RBGA color
  12176. */
  12177. class Color4 {
  12178. /**
  12179. * Defines the red component (between 0 and 1, default is 0)
  12180. */
  12181. r: number;
  12182. /**
  12183. * Defines the green component (between 0 and 1, default is 0)
  12184. */
  12185. g: number;
  12186. /**
  12187. * Defines the blue component (between 0 and 1, default is 0)
  12188. */
  12189. b: number;
  12190. /**
  12191. * Defines the alpha component (between 0 and 1, default is 1)
  12192. */
  12193. a: number;
  12194. /**
  12195. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  12196. * @param r defines the red component (between 0 and 1, default is 0)
  12197. * @param g defines the green component (between 0 and 1, default is 0)
  12198. * @param b defines the blue component (between 0 and 1, default is 0)
  12199. * @param a defines the alpha component (between 0 and 1, default is 1)
  12200. */
  12201. constructor(
  12202. /**
  12203. * Defines the red component (between 0 and 1, default is 0)
  12204. */
  12205. r?: number,
  12206. /**
  12207. * Defines the green component (between 0 and 1, default is 0)
  12208. */
  12209. g?: number,
  12210. /**
  12211. * Defines the blue component (between 0 and 1, default is 0)
  12212. */
  12213. b?: number,
  12214. /**
  12215. * Defines the alpha component (between 0 and 1, default is 1)
  12216. */
  12217. a?: number);
  12218. /**
  12219. * Adds in place the given Color4 values to the current Color4 object
  12220. * @param right defines the second operand
  12221. * @returns the current updated Color4 object
  12222. */
  12223. addInPlace(right: Color4): Color4;
  12224. /**
  12225. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  12226. * @returns the new array
  12227. */
  12228. asArray(): number[];
  12229. /**
  12230. * Stores from the starting index in the given array the Color4 successive values
  12231. * @param array defines the array where to store the r,g,b components
  12232. * @param index defines an optional index in the target array to define where to start storing values
  12233. * @returns the current Color4 object
  12234. */
  12235. toArray(array: number[], index?: number): Color4;
  12236. /**
  12237. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  12238. * @param right defines the second operand
  12239. * @returns a new Color4 object
  12240. */
  12241. add(right: Color4): Color4;
  12242. /**
  12243. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  12244. * @param right defines the second operand
  12245. * @returns a new Color4 object
  12246. */
  12247. subtract(right: Color4): Color4;
  12248. /**
  12249. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  12250. * @param right defines the second operand
  12251. * @param result defines the Color4 object where to store the result
  12252. * @returns the current Color4 object
  12253. */
  12254. subtractToRef(right: Color4, result: Color4): Color4;
  12255. /**
  12256. * Creates a new Color4 with the current Color4 values multiplied by scale
  12257. * @param scale defines the scaling factor to apply
  12258. * @returns a new Color4 object
  12259. */
  12260. scale(scale: number): Color4;
  12261. /**
  12262. * Multiplies the current Color4 values by scale and stores the result in "result"
  12263. * @param scale defines the scaling factor to apply
  12264. * @param result defines the Color4 object where to store the result
  12265. * @returns the current unmodified Color4
  12266. */
  12267. scaleToRef(scale: number, result: Color4): Color4;
  12268. /**
  12269. * Scale the current Color4 values by a factor and add the result to a given Color4
  12270. * @param scale defines the scale factor
  12271. * @param result defines the Color4 object where to store the result
  12272. * @returns the unmodified current Color4
  12273. */
  12274. scaleAndAddToRef(scale: number, result: Color4): Color4;
  12275. /**
  12276. * Clamps the rgb values by the min and max values and stores the result into "result"
  12277. * @param min defines minimum clamping value (default is 0)
  12278. * @param max defines maximum clamping value (default is 1)
  12279. * @param result defines color to store the result into.
  12280. * @returns the cuurent Color4
  12281. */
  12282. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  12283. /**
  12284. * Multipy an Color4 value by another and return a new Color4 object
  12285. * @param color defines the Color4 value to multiply by
  12286. * @returns a new Color4 object
  12287. */
  12288. multiply(color: Color4): Color4;
  12289. /**
  12290. * Multipy a Color4 value by another and push the result in a reference value
  12291. * @param color defines the Color4 value to multiply by
  12292. * @param result defines the Color4 to fill the result in
  12293. * @returns the result Color4
  12294. */
  12295. multiplyToRef(color: Color4, result: Color4): Color4;
  12296. /**
  12297. * Creates a string with the Color4 current values
  12298. * @returns the string representation of the Color4 object
  12299. */
  12300. toString(): string;
  12301. /**
  12302. * Returns the string "Color4"
  12303. * @returns "Color4"
  12304. */
  12305. getClassName(): string;
  12306. /**
  12307. * Compute the Color4 hash code
  12308. * @returns an unique number that can be used to hash Color4 objects
  12309. */
  12310. getHashCode(): number;
  12311. /**
  12312. * Creates a new Color4 copied from the current one
  12313. * @returns a new Color4 object
  12314. */
  12315. clone(): Color4;
  12316. /**
  12317. * Copies the given Color4 values into the current one
  12318. * @param source defines the source Color4 object
  12319. * @returns the current updated Color4 object
  12320. */
  12321. copyFrom(source: Color4): Color4;
  12322. /**
  12323. * Copies the given float values into the current one
  12324. * @param r defines the red component to read from
  12325. * @param g defines the green component to read from
  12326. * @param b defines the blue component to read from
  12327. * @param a defines the alpha component to read from
  12328. * @returns the current updated Color4 object
  12329. */
  12330. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  12331. /**
  12332. * Copies the given float values into the current one
  12333. * @param r defines the red component to read from
  12334. * @param g defines the green component to read from
  12335. * @param b defines the blue component to read from
  12336. * @param a defines the alpha component to read from
  12337. * @returns the current updated Color4 object
  12338. */
  12339. set(r: number, g: number, b: number, a: number): Color4;
  12340. /**
  12341. * Compute the Color4 hexadecimal code as a string
  12342. * @returns a string containing the hexadecimal representation of the Color4 object
  12343. */
  12344. toHexString(): string;
  12345. /**
  12346. * Computes a new Color4 converted from the current one to linear space
  12347. * @returns a new Color4 object
  12348. */
  12349. toLinearSpace(): Color4;
  12350. /**
  12351. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  12352. * @param convertedColor defines the Color4 object where to store the linear space version
  12353. * @returns the unmodified Color4
  12354. */
  12355. toLinearSpaceToRef(convertedColor: Color4): Color4;
  12356. /**
  12357. * Computes a new Color4 converted from the current one to gamma space
  12358. * @returns a new Color4 object
  12359. */
  12360. toGammaSpace(): Color4;
  12361. /**
  12362. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  12363. * @param convertedColor defines the Color4 object where to store the gamma space version
  12364. * @returns the unmodified Color4
  12365. */
  12366. toGammaSpaceToRef(convertedColor: Color4): Color4;
  12367. /**
  12368. * Creates a new Color4 from the string containing valid hexadecimal values
  12369. * @param hex defines a string containing valid hexadecimal values
  12370. * @returns a new Color4 object
  12371. */
  12372. static FromHexString(hex: string): Color4;
  12373. /**
  12374. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  12375. * @param left defines the start value
  12376. * @param right defines the end value
  12377. * @param amount defines the gradient factor
  12378. * @returns a new Color4 object
  12379. */
  12380. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  12381. /**
  12382. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  12383. * @param left defines the start value
  12384. * @param right defines the end value
  12385. * @param amount defines the gradient factor
  12386. * @param result defines the Color4 object where to store data
  12387. */
  12388. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  12389. /**
  12390. * Creates a new Color4 from the starting index element of the given array
  12391. * @param array defines the source array to read from
  12392. * @param offset defines the offset in the source array
  12393. * @returns a new Color4 object
  12394. */
  12395. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  12396. /**
  12397. * Creates a new Color3 from integer values (< 256)
  12398. * @param r defines the red component to read from (value between 0 and 255)
  12399. * @param g defines the green component to read from (value between 0 and 255)
  12400. * @param b defines the blue component to read from (value between 0 and 255)
  12401. * @param a defines the alpha component to read from (value between 0 and 255)
  12402. * @returns a new Color3 object
  12403. */
  12404. static FromInts(r: number, g: number, b: number, a: number): Color4;
  12405. /**
  12406. * Check the content of a given array and convert it to an array containing RGBA data
  12407. * If the original array was already containing count * 4 values then it is returned directly
  12408. * @param colors defines the array to check
  12409. * @param count defines the number of RGBA data to expect
  12410. * @returns an array containing count * 4 values (RGBA)
  12411. */
  12412. static CheckColors4(colors: number[], count: number): number[];
  12413. }
  12414. /**
  12415. * Class representing a vector containing 2 coordinates
  12416. */
  12417. class Vector2 {
  12418. /** defines the first coordinate */
  12419. x: number;
  12420. /** defines the second coordinate */
  12421. y: number;
  12422. /**
  12423. * Creates a new Vector2 from the given x and y coordinates
  12424. * @param x defines the first coordinate
  12425. * @param y defines the second coordinate
  12426. */
  12427. constructor(
  12428. /** defines the first coordinate */
  12429. x: number,
  12430. /** defines the second coordinate */
  12431. y: number);
  12432. /**
  12433. * Gets a string with the Vector2 coordinates
  12434. * @returns a string with the Vector2 coordinates
  12435. */
  12436. toString(): string;
  12437. /**
  12438. * Gets class name
  12439. * @returns the string "Vector2"
  12440. */
  12441. getClassName(): string;
  12442. /**
  12443. * Gets current vector hash code
  12444. * @returns the Vector2 hash code as a number
  12445. */
  12446. getHashCode(): number;
  12447. /**
  12448. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  12449. * @param array defines the source array
  12450. * @param index defines the offset in source array
  12451. * @returns the current Vector2
  12452. */
  12453. toArray(array: FloatArray, index?: number): Vector2;
  12454. /**
  12455. * Copy the current vector to an array
  12456. * @returns a new array with 2 elements: the Vector2 coordinates.
  12457. */
  12458. asArray(): number[];
  12459. /**
  12460. * Sets the Vector2 coordinates with the given Vector2 coordinates
  12461. * @param source defines the source Vector2
  12462. * @returns the current updated Vector2
  12463. */
  12464. copyFrom(source: Vector2): Vector2;
  12465. /**
  12466. * Sets the Vector2 coordinates with the given floats
  12467. * @param x defines the first coordinate
  12468. * @param y defines the second coordinate
  12469. * @returns the current updated Vector2
  12470. */
  12471. copyFromFloats(x: number, y: number): Vector2;
  12472. /**
  12473. * Sets the Vector2 coordinates with the given floats
  12474. * @param x defines the first coordinate
  12475. * @param y defines the second coordinate
  12476. * @returns the current updated Vector2
  12477. */
  12478. set(x: number, y: number): Vector2;
  12479. /**
  12480. * Add another vector with the current one
  12481. * @param otherVector defines the other vector
  12482. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  12483. */
  12484. add(otherVector: Vector2): Vector2;
  12485. /**
  12486. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  12487. * @param otherVector defines the other vector
  12488. * @param result defines the target vector
  12489. * @returns the unmodified current Vector2
  12490. */
  12491. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  12492. /**
  12493. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  12494. * @param otherVector defines the other vector
  12495. * @returns the current updated Vector2
  12496. */
  12497. addInPlace(otherVector: Vector2): Vector2;
  12498. /**
  12499. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  12500. * @param otherVector defines the other vector
  12501. * @returns a new Vector2
  12502. */
  12503. addVector3(otherVector: Vector3): Vector2;
  12504. /**
  12505. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  12506. * @param otherVector defines the other vector
  12507. * @returns a new Vector2
  12508. */
  12509. subtract(otherVector: Vector2): Vector2;
  12510. /**
  12511. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  12512. * @param otherVector defines the other vector
  12513. * @param result defines the target vector
  12514. * @returns the unmodified current Vector2
  12515. */
  12516. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  12517. /**
  12518. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  12519. * @param otherVector defines the other vector
  12520. * @returns the current updated Vector2
  12521. */
  12522. subtractInPlace(otherVector: Vector2): Vector2;
  12523. /**
  12524. * Multiplies in place the current Vector2 coordinates by the given ones
  12525. * @param otherVector defines the other vector
  12526. * @returns the current updated Vector2
  12527. */
  12528. multiplyInPlace(otherVector: Vector2): Vector2;
  12529. /**
  12530. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  12531. * @param otherVector defines the other vector
  12532. * @returns a new Vector2
  12533. */
  12534. multiply(otherVector: Vector2): Vector2;
  12535. /**
  12536. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  12537. * @param otherVector defines the other vector
  12538. * @param result defines the target vector
  12539. * @returns the unmodified current Vector2
  12540. */
  12541. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  12542. /**
  12543. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  12544. * @param x defines the first coordinate
  12545. * @param y defines the second coordinate
  12546. * @returns a new Vector2
  12547. */
  12548. multiplyByFloats(x: number, y: number): Vector2;
  12549. /**
  12550. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  12551. * @param otherVector defines the other vector
  12552. * @returns a new Vector2
  12553. */
  12554. divide(otherVector: Vector2): Vector2;
  12555. /**
  12556. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  12557. * @param otherVector defines the other vector
  12558. * @param result defines the target vector
  12559. * @returns the unmodified current Vector2
  12560. */
  12561. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  12562. /**
  12563. * Divides the current Vector3 coordinates by the given ones
  12564. * @param otherVector defines the other vector
  12565. * @returns the current updated Vector2
  12566. */
  12567. divideInPlace(otherVector: Vector2): Vector2;
  12568. /**
  12569. * Gets a new Vector2 with current Vector2 negated coordinates
  12570. * @returns a new Vector2
  12571. */
  12572. negate(): Vector2;
  12573. /**
  12574. * Multiply the Vector2 coordinates by scale
  12575. * @param scale defines the scaling factor
  12576. * @returns the current updated Vector2
  12577. */
  12578. scaleInPlace(scale: number): Vector2;
  12579. /**
  12580. * Returns a new Vector2 scaled by "scale" from the current Vector2
  12581. * @param scale defines the scaling factor
  12582. * @returns a new Vector2
  12583. */
  12584. scale(scale: number): Vector2;
  12585. /**
  12586. * Scale the current Vector2 values by a factor to a given Vector2
  12587. * @param scale defines the scale factor
  12588. * @param result defines the Vector2 object where to store the result
  12589. * @returns the unmodified current Vector2
  12590. */
  12591. scaleToRef(scale: number, result: Vector2): Vector2;
  12592. /**
  12593. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  12594. * @param scale defines the scale factor
  12595. * @param result defines the Vector2 object where to store the result
  12596. * @returns the unmodified current Vector2
  12597. */
  12598. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  12599. /**
  12600. * Gets a boolean if two vectors are equals
  12601. * @param otherVector defines the other vector
  12602. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  12603. */
  12604. equals(otherVector: Vector2): boolean;
  12605. /**
  12606. * Gets a boolean if two vectors are equals (using an epsilon value)
  12607. * @param otherVector defines the other vector
  12608. * @param epsilon defines the minimal distance to consider equality
  12609. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  12610. */
  12611. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  12612. /**
  12613. * Gets the length of the vector
  12614. * @returns the vector length (float)
  12615. */
  12616. length(): number;
  12617. /**
  12618. * Gets the vector squared length
  12619. * @returns the vector squared length (float)
  12620. */
  12621. lengthSquared(): number;
  12622. /**
  12623. * Normalize the vector
  12624. * @returns the current updated Vector2
  12625. */
  12626. normalize(): Vector2;
  12627. /**
  12628. * Gets a new Vector2 copied from the Vector2
  12629. * @returns a new Vector2
  12630. */
  12631. clone(): Vector2;
  12632. /**
  12633. * Gets a new Vector2(0, 0)
  12634. * @returns a new Vector2
  12635. */
  12636. static Zero(): Vector2;
  12637. /**
  12638. * Gets a new Vector2(1, 1)
  12639. * @returns a new Vector2
  12640. */
  12641. static One(): Vector2;
  12642. /**
  12643. * Gets a new Vector2 set from the given index element of the given array
  12644. * @param array defines the data source
  12645. * @param offset defines the offset in the data source
  12646. * @returns a new Vector2
  12647. */
  12648. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  12649. /**
  12650. * Sets "result" from the given index element of the given array
  12651. * @param array defines the data source
  12652. * @param offset defines the offset in the data source
  12653. * @param result defines the target vector
  12654. */
  12655. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  12656. /**
  12657. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  12658. * @param value1 defines 1st point of control
  12659. * @param value2 defines 2nd point of control
  12660. * @param value3 defines 3rd point of control
  12661. * @param value4 defines 4th point of control
  12662. * @param amount defines the interpolation factor
  12663. * @returns a new Vector2
  12664. */
  12665. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  12666. /**
  12667. * 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".
  12668. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  12669. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  12670. * @param value defines the value to clamp
  12671. * @param min defines the lower limit
  12672. * @param max defines the upper limit
  12673. * @returns a new Vector2
  12674. */
  12675. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  12676. /**
  12677. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  12678. * @param value1 defines the 1st control point
  12679. * @param tangent1 defines the outgoing tangent
  12680. * @param value2 defines the 2nd control point
  12681. * @param tangent2 defines the incoming tangent
  12682. * @param amount defines the interpolation factor
  12683. * @returns a new Vector2
  12684. */
  12685. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  12686. /**
  12687. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  12688. * @param start defines the start vector
  12689. * @param end defines the end vector
  12690. * @param amount defines the interpolation factor
  12691. * @returns a new Vector2
  12692. */
  12693. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  12694. /**
  12695. * Gets the dot product of the vector "left" and the vector "right"
  12696. * @param left defines first vector
  12697. * @param right defines second vector
  12698. * @returns the dot product (float)
  12699. */
  12700. static Dot(left: Vector2, right: Vector2): number;
  12701. /**
  12702. * Returns a new Vector2 equal to the normalized given vector
  12703. * @param vector defines the vector to normalize
  12704. * @returns a new Vector2
  12705. */
  12706. static Normalize(vector: Vector2): Vector2;
  12707. /**
  12708. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  12709. * @param left defines 1st vector
  12710. * @param right defines 2nd vector
  12711. * @returns a new Vector2
  12712. */
  12713. static Minimize(left: Vector2, right: Vector2): Vector2;
  12714. /**
  12715. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  12716. * @param left defines 1st vector
  12717. * @param right defines 2nd vector
  12718. * @returns a new Vector2
  12719. */
  12720. static Maximize(left: Vector2, right: Vector2): Vector2;
  12721. /**
  12722. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  12723. * @param vector defines the vector to transform
  12724. * @param transformation defines the matrix to apply
  12725. * @returns a new Vector2
  12726. */
  12727. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  12728. /**
  12729. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  12730. * @param vector defines the vector to transform
  12731. * @param transformation defines the matrix to apply
  12732. * @param result defines the target vector
  12733. */
  12734. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  12735. /**
  12736. * Determines if a given vector is included in a triangle
  12737. * @param p defines the vector to test
  12738. * @param p0 defines 1st triangle point
  12739. * @param p1 defines 2nd triangle point
  12740. * @param p2 defines 3rd triangle point
  12741. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  12742. */
  12743. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  12744. /**
  12745. * Gets the distance between the vectors "value1" and "value2"
  12746. * @param value1 defines first vector
  12747. * @param value2 defines second vector
  12748. * @returns the distance between vectors
  12749. */
  12750. static Distance(value1: Vector2, value2: Vector2): number;
  12751. /**
  12752. * Returns the squared distance between the vectors "value1" and "value2"
  12753. * @param value1 defines first vector
  12754. * @param value2 defines second vector
  12755. * @returns the squared distance between vectors
  12756. */
  12757. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  12758. /**
  12759. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  12760. * @param value1 defines first vector
  12761. * @param value2 defines second vector
  12762. * @returns a new Vector2
  12763. */
  12764. static Center(value1: Vector2, value2: Vector2): Vector2;
  12765. /**
  12766. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  12767. * @param p defines the middle point
  12768. * @param segA defines one point of the segment
  12769. * @param segB defines the other point of the segment
  12770. * @returns the shortest distance
  12771. */
  12772. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  12773. }
  12774. /**
  12775. * Classed used to store (x,y,z) vector representation
  12776. * A Vector3 is the main object used in 3D geometry
  12777. * It can represent etiher the coordinates of a point the space, either a direction
  12778. * Reminder: Babylon.js uses a left handed forward facing system
  12779. */
  12780. class Vector3 {
  12781. /**
  12782. * Defines the first coordinates (on X axis)
  12783. */
  12784. x: number;
  12785. /**
  12786. * Defines the second coordinates (on Y axis)
  12787. */
  12788. y: number;
  12789. /**
  12790. * Defines the third coordinates (on Z axis)
  12791. */
  12792. z: number;
  12793. /**
  12794. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  12795. * @param x defines the first coordinates (on X axis)
  12796. * @param y defines the second coordinates (on Y axis)
  12797. * @param z defines the third coordinates (on Z axis)
  12798. */
  12799. constructor(
  12800. /**
  12801. * Defines the first coordinates (on X axis)
  12802. */
  12803. x: number,
  12804. /**
  12805. * Defines the second coordinates (on Y axis)
  12806. */
  12807. y: number,
  12808. /**
  12809. * Defines the third coordinates (on Z axis)
  12810. */
  12811. z: number);
  12812. /**
  12813. * Creates a string representation of the Vector3
  12814. * @returns a string with the Vector3 coordinates.
  12815. */
  12816. toString(): string;
  12817. /**
  12818. * Gets the class name
  12819. * @returns the string "Vector3"
  12820. */
  12821. getClassName(): string;
  12822. /**
  12823. * Creates the Vector3 hash code
  12824. * @returns a number which tends to be unique between Vector3 instances
  12825. */
  12826. getHashCode(): number;
  12827. /**
  12828. * Creates an array containing three elements : the coordinates of the Vector3
  12829. * @returns a new array of numbers
  12830. */
  12831. asArray(): number[];
  12832. /**
  12833. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  12834. * @param array defines the destination array
  12835. * @param index defines the offset in the destination array
  12836. * @returns the current Vector3
  12837. */
  12838. toArray(array: FloatArray, index?: number): Vector3;
  12839. /**
  12840. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  12841. * @returns a new Quaternion object, computed from the Vector3 coordinates
  12842. */
  12843. toQuaternion(): Quaternion;
  12844. /**
  12845. * Adds the given vector to the current Vector3
  12846. * @param otherVector defines the second operand
  12847. * @returns the current updated Vector3
  12848. */
  12849. addInPlace(otherVector: Vector3): Vector3;
  12850. /**
  12851. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  12852. * @param otherVector defines the second operand
  12853. * @returns the resulting Vector3
  12854. */
  12855. add(otherVector: Vector3): Vector3;
  12856. /**
  12857. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  12858. * @param otherVector defines the second operand
  12859. * @param result defines the Vector3 object where to store the result
  12860. * @returns the current Vector3
  12861. */
  12862. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  12863. /**
  12864. * Subtract the given vector from the current Vector3
  12865. * @param otherVector defines the second operand
  12866. * @returns the current updated Vector3
  12867. */
  12868. subtractInPlace(otherVector: Vector3): Vector3;
  12869. /**
  12870. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  12871. * @param otherVector defines the second operand
  12872. * @returns the resulting Vector3
  12873. */
  12874. subtract(otherVector: Vector3): Vector3;
  12875. /**
  12876. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  12877. * @param otherVector defines the second operand
  12878. * @param result defines the Vector3 object where to store the result
  12879. * @returns the current Vector3
  12880. */
  12881. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  12882. /**
  12883. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  12884. * @param x defines the x coordinate of the operand
  12885. * @param y defines the y coordinate of the operand
  12886. * @param z defines the z coordinate of the operand
  12887. * @returns the resulting Vector3
  12888. */
  12889. subtractFromFloats(x: number, y: number, z: number): Vector3;
  12890. /**
  12891. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  12892. * @param x defines the x coordinate of the operand
  12893. * @param y defines the y coordinate of the operand
  12894. * @param z defines the z coordinate of the operand
  12895. * @param result defines the Vector3 object where to store the result
  12896. * @returns the current Vector3
  12897. */
  12898. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  12899. /**
  12900. * Gets a new Vector3 set with the current Vector3 negated coordinates
  12901. * @returns a new Vector3
  12902. */
  12903. negate(): Vector3;
  12904. /**
  12905. * Multiplies the Vector3 coordinates by the float "scale"
  12906. * @param scale defines the multiplier factor
  12907. * @returns the current updated Vector3
  12908. */
  12909. scaleInPlace(scale: number): Vector3;
  12910. /**
  12911. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  12912. * @param scale defines the multiplier factor
  12913. * @returns a new Vector3
  12914. */
  12915. scale(scale: number): Vector3;
  12916. /**
  12917. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  12918. * @param scale defines the multiplier factor
  12919. * @param result defines the Vector3 object where to store the result
  12920. * @returns the current Vector3
  12921. */
  12922. scaleToRef(scale: number, result: Vector3): Vector3;
  12923. /**
  12924. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  12925. * @param scale defines the scale factor
  12926. * @param result defines the Vector3 object where to store the result
  12927. * @returns the unmodified current Vector3
  12928. */
  12929. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  12930. /**
  12931. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  12932. * @param otherVector defines the second operand
  12933. * @returns true if both vectors are equals
  12934. */
  12935. equals(otherVector: Vector3): boolean;
  12936. /**
  12937. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  12938. * @param otherVector defines the second operand
  12939. * @param epsilon defines the minimal distance to define values as equals
  12940. * @returns true if both vectors are distant less than epsilon
  12941. */
  12942. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  12943. /**
  12944. * Returns true if the current Vector3 coordinates equals the given floats
  12945. * @param x defines the x coordinate of the operand
  12946. * @param y defines the y coordinate of the operand
  12947. * @param z defines the z coordinate of the operand
  12948. * @returns true if both vectors are equals
  12949. */
  12950. equalsToFloats(x: number, y: number, z: number): boolean;
  12951. /**
  12952. * Multiplies the current Vector3 coordinates by the given ones
  12953. * @param otherVector defines the second operand
  12954. * @returns the current updated Vector3
  12955. */
  12956. multiplyInPlace(otherVector: Vector3): Vector3;
  12957. /**
  12958. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  12959. * @param otherVector defines the second operand
  12960. * @returns the new Vector3
  12961. */
  12962. multiply(otherVector: Vector3): Vector3;
  12963. /**
  12964. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  12965. * @param otherVector defines the second operand
  12966. * @param result defines the Vector3 object where to store the result
  12967. * @returns the current Vector3
  12968. */
  12969. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  12970. /**
  12971. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  12972. * @param x defines the x coordinate of the operand
  12973. * @param y defines the y coordinate of the operand
  12974. * @param z defines the z coordinate of the operand
  12975. * @returns the new Vector3
  12976. */
  12977. multiplyByFloats(x: number, y: number, z: number): Vector3;
  12978. /**
  12979. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  12980. * @param otherVector defines the second operand
  12981. * @returns the new Vector3
  12982. */
  12983. divide(otherVector: Vector3): Vector3;
  12984. /**
  12985. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  12986. * @param otherVector defines the second operand
  12987. * @param result defines the Vector3 object where to store the result
  12988. * @returns the current Vector3
  12989. */
  12990. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  12991. /**
  12992. * Divides the current Vector3 coordinates by the given ones.
  12993. * @param otherVector defines the second operand
  12994. * @returns the current updated Vector3
  12995. */
  12996. divideInPlace(otherVector: Vector3): Vector3;
  12997. /**
  12998. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  12999. * @param other defines the second operand
  13000. * @returns the current updated Vector3
  13001. */
  13002. minimizeInPlace(other: Vector3): Vector3;
  13003. /**
  13004. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  13005. * @param other defines the second operand
  13006. * @returns the current updated Vector3
  13007. */
  13008. maximizeInPlace(other: Vector3): Vector3;
  13009. /**
  13010. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  13011. */
  13012. readonly isNonUniform: boolean;
  13013. /**
  13014. * Gets the length of the Vector3
  13015. * @returns the length of the Vecto3
  13016. */
  13017. length(): number;
  13018. /**
  13019. * Gets the squared length of the Vector3
  13020. * @returns squared length of the Vector3
  13021. */
  13022. lengthSquared(): number;
  13023. /**
  13024. * Normalize the current Vector3.
  13025. * Please note that this is an in place operation.
  13026. * @returns the current updated Vector3
  13027. */
  13028. normalize(): Vector3;
  13029. /**
  13030. * Normalize the current Vector3 to a new vector
  13031. * @returns the new Vector3
  13032. */
  13033. normalizeToNew(): Vector3;
  13034. /**
  13035. * Normalize the current Vector3 to the reference
  13036. * @param reference define the Vector3 to update
  13037. * @returns the updated Vector3
  13038. */
  13039. normalizeToRef(reference: Vector3): Vector3;
  13040. /**
  13041. * Creates a new Vector3 copied from the current Vector3
  13042. * @returns the new Vector3
  13043. */
  13044. clone(): Vector3;
  13045. /**
  13046. * Copies the given vector coordinates to the current Vector3 ones
  13047. * @param source defines the source Vector3
  13048. * @returns the current updated Vector3
  13049. */
  13050. copyFrom(source: Vector3): Vector3;
  13051. /**
  13052. * Copies the given floats to the current Vector3 coordinates
  13053. * @param x defines the x coordinate of the operand
  13054. * @param y defines the y coordinate of the operand
  13055. * @param z defines the z coordinate of the operand
  13056. * @returns the current updated Vector3
  13057. */
  13058. copyFromFloats(x: number, y: number, z: number): Vector3;
  13059. /**
  13060. * Copies the given floats to the current Vector3 coordinates
  13061. * @param x defines the x coordinate of the operand
  13062. * @param y defines the y coordinate of the operand
  13063. * @param z defines the z coordinate of the operand
  13064. * @returns the current updated Vector3
  13065. */
  13066. set(x: number, y: number, z: number): Vector3;
  13067. /**
  13068. * Get the clip factor between two vectors
  13069. * @param vector0 defines the first operand
  13070. * @param vector1 defines the second operand
  13071. * @param axis defines the axis to use
  13072. * @param size defines the size along the axis
  13073. * @returns the clip factor
  13074. */
  13075. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  13076. /**
  13077. * Get angle between two vectors
  13078. * @param vector0 angle between vector0 and vector1
  13079. * @param vector1 angle between vector0 and vector1
  13080. * @param normal direction of the normal
  13081. * @return the angle between vector0 and vector1
  13082. */
  13083. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  13084. /**
  13085. * Returns a new Vector3 set from the index "offset" of the given array
  13086. * @param array defines the source array
  13087. * @param offset defines the offset in the source array
  13088. * @returns the new Vector3
  13089. */
  13090. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  13091. /**
  13092. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  13093. * This function is deprecated. Use FromArray instead
  13094. * @param array defines the source array
  13095. * @param offset defines the offset in the source array
  13096. * @returns the new Vector3
  13097. */
  13098. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  13099. /**
  13100. * Sets the given vector "result" with the element values from the index "offset" of the given array
  13101. * @param array defines the source array
  13102. * @param offset defines the offset in the source array
  13103. * @param result defines the Vector3 where to store the result
  13104. */
  13105. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  13106. /**
  13107. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  13108. * This function is deprecated. Use FromArrayToRef instead.
  13109. * @param array defines the source array
  13110. * @param offset defines the offset in the source array
  13111. * @param result defines the Vector3 where to store the result
  13112. */
  13113. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  13114. /**
  13115. * Sets the given vector "result" with the given floats.
  13116. * @param x defines the x coordinate of the source
  13117. * @param y defines the y coordinate of the source
  13118. * @param z defines the z coordinate of the source
  13119. * @param result defines the Vector3 where to store the result
  13120. */
  13121. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  13122. /**
  13123. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  13124. * @returns a new empty Vector3
  13125. */
  13126. static Zero(): Vector3;
  13127. /**
  13128. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  13129. * @returns a new unit Vector3
  13130. */
  13131. static One(): Vector3;
  13132. /**
  13133. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  13134. * @returns a new up Vector3
  13135. */
  13136. static Up(): Vector3;
  13137. /**
  13138. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  13139. * @returns a new forward Vector3
  13140. */
  13141. static Forward(): Vector3;
  13142. /**
  13143. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  13144. * @returns a new right Vector3
  13145. */
  13146. static Right(): Vector3;
  13147. /**
  13148. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  13149. * @returns a new left Vector3
  13150. */
  13151. static Left(): Vector3;
  13152. /**
  13153. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  13154. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  13155. * @param vector defines the Vector3 to transform
  13156. * @param transformation defines the transformation matrix
  13157. * @returns the transformed Vector3
  13158. */
  13159. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  13160. /**
  13161. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  13162. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  13163. * @param vector defines the Vector3 to transform
  13164. * @param transformation defines the transformation matrix
  13165. * @param result defines the Vector3 where to store the result
  13166. */
  13167. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  13168. /**
  13169. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  13170. * This method computes tranformed coordinates only, not transformed direction vectors
  13171. * @param x define the x coordinate of the source vector
  13172. * @param y define the y coordinate of the source vector
  13173. * @param z define the z coordinate of the source vector
  13174. * @param transformation defines the transformation matrix
  13175. * @param result defines the Vector3 where to store the result
  13176. */
  13177. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  13178. /**
  13179. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  13180. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  13181. * @param vector defines the Vector3 to transform
  13182. * @param transformation defines the transformation matrix
  13183. * @returns the new Vector3
  13184. */
  13185. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  13186. /**
  13187. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  13188. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  13189. * @param vector defines the Vector3 to transform
  13190. * @param transformation defines the transformation matrix
  13191. * @param result defines the Vector3 where to store the result
  13192. */
  13193. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  13194. /**
  13195. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  13196. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  13197. * @param x define the x coordinate of the source vector
  13198. * @param y define the y coordinate of the source vector
  13199. * @param z define the z coordinate of the source vector
  13200. * @param transformation defines the transformation matrix
  13201. * @param result defines the Vector3 where to store the result
  13202. */
  13203. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  13204. /**
  13205. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  13206. * @param value1 defines the first control point
  13207. * @param value2 defines the second control point
  13208. * @param value3 defines the third control point
  13209. * @param value4 defines the fourth control point
  13210. * @param amount defines the amount on the spline to use
  13211. * @returns the new Vector3
  13212. */
  13213. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  13214. /**
  13215. * 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"
  13216. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  13217. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  13218. * @param value defines the current value
  13219. * @param min defines the lower range value
  13220. * @param max defines the upper range value
  13221. * @returns the new Vector3
  13222. */
  13223. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  13224. /**
  13225. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  13226. * @param value1 defines the first control point
  13227. * @param tangent1 defines the first tangent vector
  13228. * @param value2 defines the second control point
  13229. * @param tangent2 defines the second tangent vector
  13230. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  13231. * @returns the new Vector3
  13232. */
  13233. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  13234. /**
  13235. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  13236. * @param start defines the start value
  13237. * @param end defines the end value
  13238. * @param amount max defines amount between both (between 0 and 1)
  13239. * @returns the new Vector3
  13240. */
  13241. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  13242. /**
  13243. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  13244. * @param start defines the start value
  13245. * @param end defines the end value
  13246. * @param amount max defines amount between both (between 0 and 1)
  13247. * @param result defines the Vector3 where to store the result
  13248. */
  13249. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  13250. /**
  13251. * Returns the dot product (float) between the vectors "left" and "right"
  13252. * @param left defines the left operand
  13253. * @param right defines the right operand
  13254. * @returns the dot product
  13255. */
  13256. static Dot(left: Vector3, right: Vector3): number;
  13257. /**
  13258. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  13259. * The cross product is then orthogonal to both "left" and "right"
  13260. * @param left defines the left operand
  13261. * @param right defines the right operand
  13262. * @returns the cross product
  13263. */
  13264. static Cross(left: Vector3, right: Vector3): Vector3;
  13265. /**
  13266. * Sets the given vector "result" with the cross product of "left" and "right"
  13267. * The cross product is then orthogonal to both "left" and "right"
  13268. * @param left defines the left operand
  13269. * @param right defines the right operand
  13270. * @param result defines the Vector3 where to store the result
  13271. */
  13272. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  13273. /**
  13274. * Returns a new Vector3 as the normalization of the given vector
  13275. * @param vector defines the Vector3 to normalize
  13276. * @returns the new Vector3
  13277. */
  13278. static Normalize(vector: Vector3): Vector3;
  13279. /**
  13280. * Sets the given vector "result" with the normalization of the given first vector
  13281. * @param vector defines the Vector3 to normalize
  13282. * @param result defines the Vector3 where to store the result
  13283. */
  13284. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  13285. private static _viewportMatrixCache;
  13286. /**
  13287. * Project a Vector3 onto screen space
  13288. * @param vector defines the Vector3 to project
  13289. * @param world defines the world matrix to use
  13290. * @param transform defines the transform (view x projection) matrix to use
  13291. * @param viewport defines the screen viewport to use
  13292. * @returns the new Vector3
  13293. */
  13294. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  13295. /**
  13296. * Unproject from screen space to object space
  13297. * @param source defines the screen space Vector3 to use
  13298. * @param viewportWidth defines the current width of the viewport
  13299. * @param viewportHeight defines the current height of the viewport
  13300. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13301. * @param transform defines the transform (view x projection) matrix to use
  13302. * @returns the new Vector3
  13303. */
  13304. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  13305. /**
  13306. * Unproject from screen space to object space
  13307. * @param source defines the screen space Vector3 to use
  13308. * @param viewportWidth defines the current width of the viewport
  13309. * @param viewportHeight defines the current height of the viewport
  13310. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13311. * @param view defines the view matrix to use
  13312. * @param projection defines the projection matrix to use
  13313. * @returns the new Vector3
  13314. */
  13315. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  13316. /**
  13317. * Unproject from screen space to object space
  13318. * @param source defines the screen space Vector3 to use
  13319. * @param viewportWidth defines the current width of the viewport
  13320. * @param viewportHeight defines the current height of the viewport
  13321. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13322. * @param view defines the view matrix to use
  13323. * @param projection defines the projection matrix to use
  13324. * @param result defines the Vector3 where to store the result
  13325. */
  13326. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  13327. /**
  13328. * Unproject from screen space to object space
  13329. * @param sourceX defines the screen space x coordinate to use
  13330. * @param sourceY defines the screen space y coordinate to use
  13331. * @param sourceZ defines the screen space z coordinate to use
  13332. * @param viewportWidth defines the current width of the viewport
  13333. * @param viewportHeight defines the current height of the viewport
  13334. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  13335. * @param view defines the view matrix to use
  13336. * @param projection defines the projection matrix to use
  13337. * @param result defines the Vector3 where to store the result
  13338. */
  13339. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  13340. /**
  13341. * Gets the minimal coordinate values between two Vector3
  13342. * @param left defines the first operand
  13343. * @param right defines the second operand
  13344. * @returns the new Vector3
  13345. */
  13346. static Minimize(left: Vector3, right: Vector3): Vector3;
  13347. /**
  13348. * Gets the maximal coordinate values between two Vector3
  13349. * @param left defines the first operand
  13350. * @param right defines the second operand
  13351. * @returns the new Vector3
  13352. */
  13353. static Maximize(left: Vector3, right: Vector3): Vector3;
  13354. /**
  13355. * Returns the distance between the vectors "value1" and "value2"
  13356. * @param value1 defines the first operand
  13357. * @param value2 defines the second operand
  13358. * @returns the distance
  13359. */
  13360. static Distance(value1: Vector3, value2: Vector3): number;
  13361. /**
  13362. * Returns the squared distance between the vectors "value1" and "value2"
  13363. * @param value1 defines the first operand
  13364. * @param value2 defines the second operand
  13365. * @returns the squared distance
  13366. */
  13367. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  13368. /**
  13369. * Returns a new Vector3 located at the center between "value1" and "value2"
  13370. * @param value1 defines the first operand
  13371. * @param value2 defines the second operand
  13372. * @returns the new Vector3
  13373. */
  13374. static Center(value1: Vector3, value2: Vector3): Vector3;
  13375. /**
  13376. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  13377. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  13378. * to something in order to rotate it from its local system to the given target system
  13379. * Note: axis1, axis2 and axis3 are normalized during this operation
  13380. * @param axis1 defines the first axis
  13381. * @param axis2 defines the second axis
  13382. * @param axis3 defines the third axis
  13383. * @returns a new Vector3
  13384. */
  13385. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  13386. /**
  13387. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  13388. * @param axis1 defines the first axis
  13389. * @param axis2 defines the second axis
  13390. * @param axis3 defines the third axis
  13391. * @param ref defines the Vector3 where to store the result
  13392. */
  13393. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  13394. }
  13395. class Vector4 {
  13396. x: number;
  13397. y: number;
  13398. z: number;
  13399. w: number;
  13400. /**
  13401. * Creates a Vector4 object from the given floats.
  13402. */
  13403. constructor(x: number, y: number, z: number, w: number);
  13404. /**
  13405. * Returns the string with the Vector4 coordinates.
  13406. */
  13407. toString(): string;
  13408. /**
  13409. * Returns the string "Vector4".
  13410. */
  13411. getClassName(): string;
  13412. /**
  13413. * Returns the Vector4 hash code.
  13414. */
  13415. getHashCode(): number;
  13416. /**
  13417. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  13418. */
  13419. asArray(): number[];
  13420. /**
  13421. * Populates the given array from the given index with the Vector4 coordinates.
  13422. * Returns the Vector4.
  13423. */
  13424. toArray(array: FloatArray, index?: number): Vector4;
  13425. /**
  13426. * Adds the given vector to the current Vector4.
  13427. * Returns the updated Vector4.
  13428. */
  13429. addInPlace(otherVector: Vector4): Vector4;
  13430. /**
  13431. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  13432. */
  13433. add(otherVector: Vector4): Vector4;
  13434. /**
  13435. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  13436. * Returns the current Vector4.
  13437. */
  13438. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  13439. /**
  13440. * Subtract in place the given vector from the current Vector4.
  13441. * Returns the updated Vector4.
  13442. */
  13443. subtractInPlace(otherVector: Vector4): Vector4;
  13444. /**
  13445. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  13446. */
  13447. subtract(otherVector: Vector4): Vector4;
  13448. /**
  13449. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  13450. * Returns the current Vector4.
  13451. */
  13452. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  13453. /**
  13454. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  13455. */
  13456. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  13457. /**
  13458. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  13459. * Returns the current Vector4.
  13460. */
  13461. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  13462. /**
  13463. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  13464. */
  13465. negate(): Vector4;
  13466. /**
  13467. * Multiplies the current Vector4 coordinates by scale (float).
  13468. * Returns the updated Vector4.
  13469. */
  13470. scaleInPlace(scale: number): Vector4;
  13471. /**
  13472. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  13473. */
  13474. scale(scale: number): Vector4;
  13475. /**
  13476. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  13477. * Returns the current Vector4.
  13478. */
  13479. scaleToRef(scale: number, result: Vector4): Vector4;
  13480. /**
  13481. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  13482. * @param scale defines the scale factor
  13483. * @param result defines the Vector4 object where to store the result
  13484. * @returns the unmodified current Vector4
  13485. */
  13486. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  13487. /**
  13488. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  13489. */
  13490. equals(otherVector: Vector4): boolean;
  13491. /**
  13492. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  13493. */
  13494. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  13495. /**
  13496. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  13497. */
  13498. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  13499. /**
  13500. * Multiplies in place the current Vector4 by the given one.
  13501. * Returns the updated Vector4.
  13502. */
  13503. multiplyInPlace(otherVector: Vector4): Vector4;
  13504. /**
  13505. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  13506. */
  13507. multiply(otherVector: Vector4): Vector4;
  13508. /**
  13509. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  13510. * Returns the current Vector4.
  13511. */
  13512. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  13513. /**
  13514. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  13515. */
  13516. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  13517. /**
  13518. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  13519. */
  13520. divide(otherVector: Vector4): Vector4;
  13521. /**
  13522. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  13523. * Returns the current Vector4.
  13524. */
  13525. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  13526. /**
  13527. * Divides the current Vector3 coordinates by the given ones.
  13528. * @returns the updated Vector3.
  13529. */
  13530. divideInPlace(otherVector: Vector4): Vector4;
  13531. /**
  13532. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  13533. * @param other defines the second operand
  13534. * @returns the current updated Vector4
  13535. */
  13536. minimizeInPlace(other: Vector4): Vector4;
  13537. /**
  13538. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  13539. * @param other defines the second operand
  13540. * @returns the current updated Vector4
  13541. */
  13542. maximizeInPlace(other: Vector4): Vector4;
  13543. /**
  13544. * Returns the Vector4 length (float).
  13545. */
  13546. length(): number;
  13547. /**
  13548. * Returns the Vector4 squared length (float).
  13549. */
  13550. lengthSquared(): number;
  13551. /**
  13552. * Normalizes in place the Vector4.
  13553. * Returns the updated Vector4.
  13554. */
  13555. normalize(): Vector4;
  13556. /**
  13557. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  13558. */
  13559. toVector3(): Vector3;
  13560. /**
  13561. * Returns a new Vector4 copied from the current one.
  13562. */
  13563. clone(): Vector4;
  13564. /**
  13565. * Updates the current Vector4 with the given one coordinates.
  13566. * Returns the updated Vector4.
  13567. */
  13568. copyFrom(source: Vector4): Vector4;
  13569. /**
  13570. * Updates the current Vector4 coordinates with the given floats.
  13571. * Returns the updated Vector4.
  13572. */
  13573. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  13574. /**
  13575. * Updates the current Vector4 coordinates with the given floats.
  13576. * Returns the updated Vector4.
  13577. */
  13578. set(x: number, y: number, z: number, w: number): Vector4;
  13579. /**
  13580. * Returns a new Vector4 set from the starting index of the given array.
  13581. */
  13582. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  13583. /**
  13584. * Updates the given vector "result" from the starting index of the given array.
  13585. */
  13586. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  13587. /**
  13588. * Updates the given vector "result" from the starting index of the given Float32Array.
  13589. */
  13590. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  13591. /**
  13592. * Updates the given vector "result" coordinates from the given floats.
  13593. */
  13594. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  13595. /**
  13596. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  13597. */
  13598. static Zero(): Vector4;
  13599. /**
  13600. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  13601. */
  13602. static One(): Vector4;
  13603. /**
  13604. * Returns a new normalized Vector4 from the given one.
  13605. */
  13606. static Normalize(vector: Vector4): Vector4;
  13607. /**
  13608. * Updates the given vector "result" from the normalization of the given one.
  13609. */
  13610. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  13611. static Minimize(left: Vector4, right: Vector4): Vector4;
  13612. static Maximize(left: Vector4, right: Vector4): Vector4;
  13613. /**
  13614. * Returns the distance (float) between the vectors "value1" and "value2".
  13615. */
  13616. static Distance(value1: Vector4, value2: Vector4): number;
  13617. /**
  13618. * Returns the squared distance (float) between the vectors "value1" and "value2".
  13619. */
  13620. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  13621. /**
  13622. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  13623. */
  13624. static Center(value1: Vector4, value2: Vector4): Vector4;
  13625. /**
  13626. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  13627. * This methods computes transformed normalized direction vectors only.
  13628. */
  13629. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  13630. /**
  13631. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  13632. * This methods computes transformed normalized direction vectors only.
  13633. */
  13634. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  13635. /**
  13636. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  13637. * This methods computes transformed normalized direction vectors only.
  13638. */
  13639. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  13640. }
  13641. interface ISize {
  13642. width: number;
  13643. height: number;
  13644. }
  13645. class Size implements ISize {
  13646. width: number;
  13647. height: number;
  13648. /**
  13649. * Creates a Size object from the given width and height (floats).
  13650. */
  13651. constructor(width: number, height: number);
  13652. toString(): string;
  13653. /**
  13654. * Returns the string "Size"
  13655. */
  13656. getClassName(): string;
  13657. /**
  13658. * Returns the Size hash code.
  13659. */
  13660. getHashCode(): number;
  13661. /**
  13662. * Updates the current size from the given one.
  13663. * Returns the updated Size.
  13664. */
  13665. copyFrom(src: Size): void;
  13666. /**
  13667. * Updates in place the current Size from the given floats.
  13668. * Returns the updated Size.
  13669. */
  13670. copyFromFloats(width: number, height: number): Size;
  13671. /**
  13672. * Updates in place the current Size from the given floats.
  13673. * Returns the updated Size.
  13674. */
  13675. set(width: number, height: number): Size;
  13676. /**
  13677. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  13678. */
  13679. multiplyByFloats(w: number, h: number): Size;
  13680. /**
  13681. * Returns a new Size copied from the given one.
  13682. */
  13683. clone(): Size;
  13684. /**
  13685. * Boolean : True if the current Size and the given one width and height are strictly equal.
  13686. */
  13687. equals(other: Size): boolean;
  13688. /**
  13689. * Returns the surface of the Size : width * height (float).
  13690. */
  13691. readonly surface: number;
  13692. /**
  13693. * Returns a new Size set to (0.0, 0.0)
  13694. */
  13695. static Zero(): Size;
  13696. /**
  13697. * Returns a new Size set as the addition result of the current Size and the given one.
  13698. */
  13699. add(otherSize: Size): Size;
  13700. /**
  13701. * Returns a new Size set as the subtraction result of the given one from the current Size.
  13702. */
  13703. subtract(otherSize: Size): Size;
  13704. /**
  13705. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  13706. */
  13707. static Lerp(start: Size, end: Size, amount: number): Size;
  13708. }
  13709. /**
  13710. * Class used to store quaternion data
  13711. * @see https://en.wikipedia.org/wiki/Quaternion
  13712. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  13713. */
  13714. class Quaternion {
  13715. /** defines the first component (0 by default) */
  13716. x: number;
  13717. /** defines the second component (0 by default) */
  13718. y: number;
  13719. /** defines the third component (0 by default) */
  13720. z: number;
  13721. /** defines the fourth component (1.0 by default) */
  13722. w: number;
  13723. /**
  13724. * Creates a new Quaternion from the given floats
  13725. * @param x defines the first component (0 by default)
  13726. * @param y defines the second component (0 by default)
  13727. * @param z defines the third component (0 by default)
  13728. * @param w defines the fourth component (1.0 by default)
  13729. */
  13730. constructor(
  13731. /** defines the first component (0 by default) */
  13732. x?: number,
  13733. /** defines the second component (0 by default) */
  13734. y?: number,
  13735. /** defines the third component (0 by default) */
  13736. z?: number,
  13737. /** defines the fourth component (1.0 by default) */
  13738. w?: number);
  13739. /**
  13740. * Gets a string representation for the current quaternion
  13741. * @returns a string with the Quaternion coordinates
  13742. */
  13743. toString(): string;
  13744. /**
  13745. * Gets the class name of the quaternion
  13746. * @returns the string "Quaternion"
  13747. */
  13748. getClassName(): string;
  13749. /**
  13750. * Gets a hash code for this quaternion
  13751. * @returns the quaternion hash code
  13752. */
  13753. getHashCode(): number;
  13754. /**
  13755. * Copy the quaternion to an array
  13756. * @returns a new array populated with 4 elements from the quaternion coordinates
  13757. */
  13758. asArray(): number[];
  13759. /**
  13760. * Check if two quaternions are equals
  13761. * @param otherQuaternion defines the second operand
  13762. * @return true if the current quaternion and the given one coordinates are strictly equals
  13763. */
  13764. equals(otherQuaternion: Quaternion): boolean;
  13765. /**
  13766. * Clone the current quaternion
  13767. * @returns a new quaternion copied from the current one
  13768. */
  13769. clone(): Quaternion;
  13770. /**
  13771. * Copy a quaternion to the current one
  13772. * @param other defines the other quaternion
  13773. * @returns the updated current quaternion
  13774. */
  13775. copyFrom(other: Quaternion): Quaternion;
  13776. /**
  13777. * Updates the current quaternion with the given float coordinates
  13778. * @param x defines the x coordinate
  13779. * @param y defines the y coordinate
  13780. * @param z defines the z coordinate
  13781. * @param w defines the w coordinate
  13782. * @returns the updated current quaternion
  13783. */
  13784. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  13785. /**
  13786. * Updates the current quaternion from the given float coordinates
  13787. * @param x defines the x coordinate
  13788. * @param y defines the y coordinate
  13789. * @param z defines the z coordinate
  13790. * @param w defines the w coordinate
  13791. * @returns the updated current quaternion
  13792. */
  13793. set(x: number, y: number, z: number, w: number): Quaternion;
  13794. /**
  13795. * Adds two quaternions
  13796. * @param other defines the second operand
  13797. * @returns a new quaternion as the addition result of the given one and the current quaternion
  13798. */
  13799. add(other: Quaternion): Quaternion;
  13800. /**
  13801. * Add a quaternion to the current one
  13802. * @param other defines the quaternion to add
  13803. * @returns the current quaternion
  13804. */
  13805. addInPlace(other: Quaternion): Quaternion;
  13806. /**
  13807. * Subtract two quaternions
  13808. * @param other defines the second operand
  13809. * @returns a new quaternion as the subtraction result of the given one from the current one
  13810. */
  13811. subtract(other: Quaternion): Quaternion;
  13812. /**
  13813. * Multiplies the current quaternion by a scale factor
  13814. * @param value defines the scale factor
  13815. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  13816. */
  13817. scale(value: number): Quaternion;
  13818. /**
  13819. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  13820. * @param scale defines the scale factor
  13821. * @param result defines the Quaternion object where to store the result
  13822. * @returns the unmodified current quaternion
  13823. */
  13824. scaleToRef(scale: number, result: Quaternion): Quaternion;
  13825. /**
  13826. * Multiplies in place the current quaternion by a scale factor
  13827. * @param value defines the scale factor
  13828. * @returns the current modified quaternion
  13829. */
  13830. scaleInPlace(value: number): Quaternion;
  13831. /**
  13832. * Scale the current quaternion values by a factor and add the result to a given quaternion
  13833. * @param scale defines the scale factor
  13834. * @param result defines the Quaternion object where to store the result
  13835. * @returns the unmodified current quaternion
  13836. */
  13837. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  13838. /**
  13839. * Multiplies two quaternions
  13840. * @param q1 defines the second operand
  13841. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  13842. */
  13843. multiply(q1: Quaternion): Quaternion;
  13844. /**
  13845. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  13846. * @param q1 defines the second operand
  13847. * @param result defines the target quaternion
  13848. * @returns the current quaternion
  13849. */
  13850. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  13851. /**
  13852. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  13853. * @param q1 defines the second operand
  13854. * @returns the currentupdated quaternion
  13855. */
  13856. multiplyInPlace(q1: Quaternion): Quaternion;
  13857. /**
  13858. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  13859. * @param ref defines the target quaternion
  13860. * @returns the current quaternion
  13861. */
  13862. conjugateToRef(ref: Quaternion): Quaternion;
  13863. /**
  13864. * Conjugates in place (1-q) the current quaternion
  13865. * @returns the current updated quaternion
  13866. */
  13867. conjugateInPlace(): Quaternion;
  13868. /**
  13869. * Conjugates in place (1-q) the current quaternion
  13870. * @returns a new quaternion
  13871. */
  13872. conjugate(): Quaternion;
  13873. /**
  13874. * Gets length of current quaternion
  13875. * @returns the quaternion length (float)
  13876. */
  13877. length(): number;
  13878. /**
  13879. * Normalize in place the current quaternion
  13880. * @returns the current updated quaternion
  13881. */
  13882. normalize(): Quaternion;
  13883. /**
  13884. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  13885. * @param order is a reserved parameter and is ignore for now
  13886. * @returns a new Vector3 containing the Euler angles
  13887. */
  13888. toEulerAngles(order?: string): Vector3;
  13889. /**
  13890. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  13891. * @param result defines the vector which will be filled with the Euler angles
  13892. * @param order is a reserved parameter and is ignore for now
  13893. * @returns the current unchanged quaternion
  13894. */
  13895. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  13896. /**
  13897. * Updates the given rotation matrix with the current quaternion values
  13898. * @param result defines the target matrix
  13899. * @returns the current unchanged quaternion
  13900. */
  13901. toRotationMatrix(result: Matrix): Quaternion;
  13902. /**
  13903. * Updates the current quaternion from the given rotation matrix values
  13904. * @param matrix defines the source matrix
  13905. * @returns the current updated quaternion
  13906. */
  13907. fromRotationMatrix(matrix: Matrix): Quaternion;
  13908. /**
  13909. * Creates a new quaternion from a rotation matrix
  13910. * @param matrix defines the source matrix
  13911. * @returns a new quaternion created from the given rotation matrix values
  13912. */
  13913. static FromRotationMatrix(matrix: Matrix): Quaternion;
  13914. /**
  13915. * Updates the given quaternion with the given rotation matrix values
  13916. * @param matrix defines the source matrix
  13917. * @param result defines the target quaternion
  13918. */
  13919. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  13920. /**
  13921. * Creates an empty quaternion
  13922. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  13923. */
  13924. static Zero(): Quaternion;
  13925. /**
  13926. * Inverse a given quaternion
  13927. * @param q defines the source quaternion
  13928. * @returns a new quaternion as the inverted current quaternion
  13929. */
  13930. static Inverse(q: Quaternion): Quaternion;
  13931. /**
  13932. * Creates an identity quaternion
  13933. * @returns the identity quaternion
  13934. */
  13935. static Identity(): Quaternion;
  13936. /**
  13937. * Gets a boolean indicating if the given quaternion is identity
  13938. * @param quaternion defines the quaternion to check
  13939. * @returns true if the quaternion is identity
  13940. */
  13941. static IsIdentity(quaternion: Quaternion): boolean;
  13942. /**
  13943. * Creates a quaternion from a rotation around an axis
  13944. * @param axis defines the axis to use
  13945. * @param angle defines the angle to use
  13946. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  13947. */
  13948. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  13949. /**
  13950. * Creates a rotation around an axis and stores it into the given quaternion
  13951. * @param axis defines the axis to use
  13952. * @param angle defines the angle to use
  13953. * @param result defines the target quaternion
  13954. * @returns the target quaternion
  13955. */
  13956. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  13957. /**
  13958. * Creates a new quaternion from data stored into an array
  13959. * @param array defines the data source
  13960. * @param offset defines the offset in the source array where the data starts
  13961. * @returns a new quaternion
  13962. */
  13963. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  13964. /**
  13965. * Creates a new quaternion from the given Euler float angles (y, x, z)
  13966. * @param yaw defines the rotation around Y axis
  13967. * @param pitch defines the rotation around X axis
  13968. * @param roll defines the rotation around Z axis
  13969. * @returns the new quaternion
  13970. */
  13971. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  13972. /**
  13973. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  13974. * @param yaw defines the rotation around Y axis
  13975. * @param pitch defines the rotation around X axis
  13976. * @param roll defines the rotation around Z axis
  13977. * @param result defines the target quaternion
  13978. */
  13979. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  13980. /**
  13981. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  13982. * @param alpha defines the rotation around first axis
  13983. * @param beta defines the rotation around second axis
  13984. * @param gamma defines the rotation around third axis
  13985. * @returns the new quaternion
  13986. */
  13987. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  13988. /**
  13989. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  13990. * @param alpha defines the rotation around first axis
  13991. * @param beta defines the rotation around second axis
  13992. * @param gamma defines the rotation around third axis
  13993. * @param result defines the target quaternion
  13994. */
  13995. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  13996. /**
  13997. * 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)
  13998. * @param axis1 defines the first axis
  13999. * @param axis2 defines the second axis
  14000. * @param axis3 defines the third axis
  14001. * @returns the new quaternion
  14002. */
  14003. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  14004. /**
  14005. * 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
  14006. * @param axis1 defines the first axis
  14007. * @param axis2 defines the second axis
  14008. * @param axis3 defines the third axis
  14009. * @param ref defines the target quaternion
  14010. */
  14011. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  14012. /**
  14013. * Interpolates between two quaternions
  14014. * @param left defines first quaternion
  14015. * @param right defines second quaternion
  14016. * @param amount defines the gradient to use
  14017. * @returns the new interpolated quaternion
  14018. */
  14019. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  14020. /**
  14021. * Interpolates between two quaternions and stores it into a target quaternion
  14022. * @param left defines first quaternion
  14023. * @param right defines second quaternion
  14024. * @param amount defines the gradient to use
  14025. * @param result defines the target quaternion
  14026. */
  14027. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  14028. /**
  14029. * Interpolate between two quaternions using Hermite interpolation
  14030. * @param value1 defines first quaternion
  14031. * @param tangent1 defines the incoming tangent
  14032. * @param value2 defines second quaternion
  14033. * @param tangent2 defines the outgoing tangent
  14034. * @param amount defines the target quaternion
  14035. * @returns the new interpolated quaternion
  14036. */
  14037. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  14038. }
  14039. /**
  14040. * Class used to store matrix data (4x4)
  14041. */
  14042. class Matrix {
  14043. private static _tempQuaternion;
  14044. private static _xAxis;
  14045. private static _yAxis;
  14046. private static _zAxis;
  14047. private static _updateFlagSeed;
  14048. private static _identityReadOnly;
  14049. private _isIdentity;
  14050. private _isIdentityDirty;
  14051. /**
  14052. * Gets the update flag of the matrix which is an unique number for the matrix.
  14053. * It will be incremented every time the matrix data change.
  14054. * You can use it to speed the comparison between two versions of the same matrix.
  14055. */
  14056. updateFlag: number;
  14057. /**
  14058. * Gets or sets the internal data of the matrix
  14059. */
  14060. m: Float32Array;
  14061. /** @hidden */
  14062. _markAsUpdated(): void;
  14063. /**
  14064. * Creates an empty matrix (filled with zeros)
  14065. */
  14066. constructor();
  14067. /**
  14068. * Check if the current matrix is indentity
  14069. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  14070. * @returns true is the matrix is the identity matrix
  14071. */
  14072. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  14073. /**
  14074. * Gets the determinant of the matrix
  14075. * @returns the matrix determinant
  14076. */
  14077. determinant(): number;
  14078. /**
  14079. * Returns the matrix as a Float32Array
  14080. * @returns the matrix underlying array
  14081. */
  14082. toArray(): Float32Array;
  14083. /**
  14084. * Returns the matrix as a Float32Array
  14085. * @returns the matrix underlying array.
  14086. */
  14087. asArray(): Float32Array;
  14088. /**
  14089. * Inverts the current matrix in place
  14090. * @returns the current inverted matrix
  14091. */
  14092. invert(): Matrix;
  14093. /**
  14094. * Sets all the matrix elements to zero
  14095. * @returns the current matrix
  14096. */
  14097. reset(): Matrix;
  14098. /**
  14099. * Adds the current matrix with a second one
  14100. * @param other defines the matrix to add
  14101. * @returns a new matrix as the addition of the current matrix and the given one
  14102. */
  14103. add(other: Matrix): Matrix;
  14104. /**
  14105. * Sets the given matrix "result" to the addition of the current matrix and the given one
  14106. * @param other defines the matrix to add
  14107. * @param result defines the target matrix
  14108. * @returns the current matrix
  14109. */
  14110. addToRef(other: Matrix, result: Matrix): Matrix;
  14111. /**
  14112. * Adds in place the given matrix to the current matrix
  14113. * @param other defines the second operand
  14114. * @returns the current updated matrix
  14115. */
  14116. addToSelf(other: Matrix): Matrix;
  14117. /**
  14118. * Sets the given matrix to the current inverted Matrix
  14119. * @param other defines the target matrix
  14120. * @returns the unmodified current matrix
  14121. */
  14122. invertToRef(other: Matrix): Matrix;
  14123. /**
  14124. * Inserts the translation vector (using 3 floats) in the current matrix
  14125. * @param x defines the 1st component of the translation
  14126. * @param y defines the 2nd component of the translation
  14127. * @param z defines the 3rd component of the translation
  14128. * @returns the current updated matrix
  14129. */
  14130. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  14131. /**
  14132. * Inserts the translation vector in the current matrix
  14133. * @param vector3 defines the translation to insert
  14134. * @returns the current updated matrix
  14135. */
  14136. setTranslation(vector3: Vector3): Matrix;
  14137. /**
  14138. * Gets the translation value of the current matrix
  14139. * @returns a new Vector3 as the extracted translation from the matrix
  14140. */
  14141. getTranslation(): Vector3;
  14142. /**
  14143. * Fill a Vector3 with the extracted translation from the matrix
  14144. * @param result defines the Vector3 where to store the translation
  14145. * @returns the current matrix
  14146. */
  14147. getTranslationToRef(result: Vector3): Matrix;
  14148. /**
  14149. * Remove rotation and scaling part from the matrix
  14150. * @returns the updated matrix
  14151. */
  14152. removeRotationAndScaling(): Matrix;
  14153. /**
  14154. * Multiply two matrices
  14155. * @param other defines the second operand
  14156. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  14157. */
  14158. multiply(other: Matrix): Matrix;
  14159. /**
  14160. * Copy the current matrix from the given one
  14161. * @param other defines the source matrix
  14162. * @returns the current updated matrix
  14163. */
  14164. copyFrom(other: Matrix): Matrix;
  14165. /**
  14166. * Populates the given array from the starting index with the current matrix values
  14167. * @param array defines the target array
  14168. * @param offset defines the offset in the target array where to start storing values
  14169. * @returns the current matrix
  14170. */
  14171. copyToArray(array: Float32Array, offset?: number): Matrix;
  14172. /**
  14173. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  14174. * @param other defines the second operand
  14175. * @param result defines the matrix where to store the multiplication
  14176. * @returns the current matrix
  14177. */
  14178. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  14179. /**
  14180. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  14181. * @param other defines the second operand
  14182. * @param result defines the array where to store the multiplication
  14183. * @param offset defines the offset in the target array where to start storing values
  14184. * @returns the current matrix
  14185. */
  14186. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  14187. /**
  14188. * Check equality between this matrix and a second one
  14189. * @param value defines the second matrix to compare
  14190. * @returns true is the current matrix and the given one values are strictly equal
  14191. */
  14192. equals(value: Matrix): boolean;
  14193. /**
  14194. * Clone the current matrix
  14195. * @returns a new matrix from the current matrix
  14196. */
  14197. clone(): Matrix;
  14198. /**
  14199. * Returns the name of the current matrix class
  14200. * @returns the string "Matrix"
  14201. */
  14202. getClassName(): string;
  14203. /**
  14204. * Gets the hash code of the current matrix
  14205. * @returns the hash code
  14206. */
  14207. getHashCode(): number;
  14208. /**
  14209. * Decomposes the current Matrix into a translation, rotation and scaling components
  14210. * @param scale defines the scale vector3 given as a reference to update
  14211. * @param rotation defines the rotation quaternion given as a reference to update
  14212. * @param translation defines the translation vector3 given as a reference to update
  14213. * @returns true if operation was successful
  14214. */
  14215. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  14216. /**
  14217. * Gets specific row of the matrix
  14218. * @param index defines the number of the row to get
  14219. * @returns the index-th row of the current matrix as a new Vector4
  14220. */
  14221. getRow(index: number): Nullable<Vector4>;
  14222. /**
  14223. * Sets the index-th row of the current matrix to the vector4 values
  14224. * @param index defines the number of the row to set
  14225. * @param row defines the target vector4
  14226. * @returns the updated current matrix
  14227. */
  14228. setRow(index: number, row: Vector4): Matrix;
  14229. /**
  14230. * Compute the transpose of the matrix
  14231. * @returns the new transposed matrix
  14232. */
  14233. transpose(): Matrix;
  14234. /**
  14235. * Compute the transpose of the matrix and store it in a given matrix
  14236. * @param result defines the target matrix
  14237. * @returns the current matrix
  14238. */
  14239. transposeToRef(result: Matrix): Matrix;
  14240. /**
  14241. * Sets the index-th row of the current matrix with the given 4 x float values
  14242. * @param index defines the row index
  14243. * @param x defines the x component to set
  14244. * @param y defines the y component to set
  14245. * @param z defines the z component to set
  14246. * @param w defines the w component to set
  14247. * @returns the updated current matrix
  14248. */
  14249. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  14250. /**
  14251. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  14252. * @param scale defines the scale factor
  14253. * @returns a new matrix
  14254. */
  14255. scale(scale: number): Matrix;
  14256. /**
  14257. * Scale the current matrix values by a factor to a given result matrix
  14258. * @param scale defines the scale factor
  14259. * @param result defines the matrix to store the result
  14260. * @returns the current matrix
  14261. */
  14262. scaleToRef(scale: number, result: Matrix): Matrix;
  14263. /**
  14264. * Scale the current matrix values by a factor and add the result to a given matrix
  14265. * @param scale defines the scale factor
  14266. * @param result defines the Matrix to store the result
  14267. * @returns the current matrix
  14268. */
  14269. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  14270. /**
  14271. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  14272. * @param ref matrix to store the result
  14273. */
  14274. toNormalMatrix(ref: Matrix): void;
  14275. /**
  14276. * Gets only rotation part of the current matrix
  14277. * @returns a new matrix sets to the extracted rotation matrix from the current one
  14278. */
  14279. getRotationMatrix(): Matrix;
  14280. /**
  14281. * Extracts the rotation matrix from the current one and sets it as the given "result"
  14282. * @param result defines the target matrix to store data to
  14283. * @returns the current matrix
  14284. */
  14285. getRotationMatrixToRef(result: Matrix): Matrix;
  14286. /**
  14287. * Creates a matrix from an array
  14288. * @param array defines the source array
  14289. * @param offset defines an offset in the source array
  14290. * @returns a new Matrix set from the starting index of the given array
  14291. */
  14292. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  14293. /**
  14294. * Copy the content of an array into a given matrix
  14295. * @param array defines the source array
  14296. * @param offset defines an offset in the source array
  14297. * @param result defines the target matrix
  14298. */
  14299. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  14300. /**
  14301. * Stores an array into a matrix after having multiplied each component by a given factor
  14302. * @param array defines the source array
  14303. * @param offset defines the offset in the source array
  14304. * @param scale defines the scaling factor
  14305. * @param result defines the target matrix
  14306. */
  14307. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  14308. /**
  14309. * Stores a list of values (16) inside a given matrix
  14310. * @param initialM11 defines 1st value of 1st row
  14311. * @param initialM12 defines 2nd value of 1st row
  14312. * @param initialM13 defines 3rd value of 1st row
  14313. * @param initialM14 defines 4th value of 1st row
  14314. * @param initialM21 defines 1st value of 2nd row
  14315. * @param initialM22 defines 2nd value of 2nd row
  14316. * @param initialM23 defines 3rd value of 2nd row
  14317. * @param initialM24 defines 4th value of 2nd row
  14318. * @param initialM31 defines 1st value of 3rd row
  14319. * @param initialM32 defines 2nd value of 3rd row
  14320. * @param initialM33 defines 3rd value of 3rd row
  14321. * @param initialM34 defines 4th value of 3rd row
  14322. * @param initialM41 defines 1st value of 4th row
  14323. * @param initialM42 defines 2nd value of 4th row
  14324. * @param initialM43 defines 3rd value of 4th row
  14325. * @param initialM44 defines 4th value of 4th row
  14326. * @param result defines the target matrix
  14327. */
  14328. 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;
  14329. /**
  14330. * Gets an identity matrix that must not be updated
  14331. */
  14332. static readonly IdentityReadOnly: Matrix;
  14333. /**
  14334. * Creates new matrix from a list of values (16)
  14335. * @param initialM11 defines 1st value of 1st row
  14336. * @param initialM12 defines 2nd value of 1st row
  14337. * @param initialM13 defines 3rd value of 1st row
  14338. * @param initialM14 defines 4th value of 1st row
  14339. * @param initialM21 defines 1st value of 2nd row
  14340. * @param initialM22 defines 2nd value of 2nd row
  14341. * @param initialM23 defines 3rd value of 2nd row
  14342. * @param initialM24 defines 4th value of 2nd row
  14343. * @param initialM31 defines 1st value of 3rd row
  14344. * @param initialM32 defines 2nd value of 3rd row
  14345. * @param initialM33 defines 3rd value of 3rd row
  14346. * @param initialM34 defines 4th value of 3rd row
  14347. * @param initialM41 defines 1st value of 4th row
  14348. * @param initialM42 defines 2nd value of 4th row
  14349. * @param initialM43 defines 3rd value of 4th row
  14350. * @param initialM44 defines 4th value of 4th row
  14351. * @returns the new matrix
  14352. */
  14353. 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;
  14354. /**
  14355. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  14356. * @param scale defines the scale vector3
  14357. * @param rotation defines the rotation quaternion
  14358. * @param translation defines the translation vector3
  14359. * @returns a new matrix
  14360. */
  14361. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  14362. /**
  14363. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  14364. * @param scale defines the scale vector3
  14365. * @param rotation defines the rotation quaternion
  14366. * @param translation defines the translation vector3
  14367. * @param result defines the target matrix
  14368. */
  14369. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  14370. /**
  14371. * Creates a new identity matrix
  14372. * @returns a new identity matrix
  14373. */
  14374. static Identity(): Matrix;
  14375. /**
  14376. * Creates a new identity matrix and stores the result in a given matrix
  14377. * @param result defines the target matrix
  14378. */
  14379. static IdentityToRef(result: Matrix): void;
  14380. /**
  14381. * Creates a new zero matrix
  14382. * @returns a new zero matrix
  14383. */
  14384. static Zero(): Matrix;
  14385. /**
  14386. * Creates a new rotation matrix for "angle" radians around the X axis
  14387. * @param angle defines the angle (in radians) to use
  14388. * @return the new matrix
  14389. */
  14390. static RotationX(angle: number): Matrix;
  14391. /**
  14392. * Creates a new matrix as the invert of a given matrix
  14393. * @param source defines the source matrix
  14394. * @returns the new matrix
  14395. */
  14396. static Invert(source: Matrix): Matrix;
  14397. /**
  14398. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  14399. * @param angle defines the angle (in radians) to use
  14400. * @param result defines the target matrix
  14401. */
  14402. static RotationXToRef(angle: number, result: Matrix): void;
  14403. /**
  14404. * Creates a new rotation matrix for "angle" radians around the Y axis
  14405. * @param angle defines the angle (in radians) to use
  14406. * @return the new matrix
  14407. */
  14408. static RotationY(angle: number): Matrix;
  14409. /**
  14410. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  14411. * @param angle defines the angle (in radians) to use
  14412. * @param result defines the target matrix
  14413. */
  14414. static RotationYToRef(angle: number, result: Matrix): void;
  14415. /**
  14416. * Creates a new rotation matrix for "angle" radians around the Z axis
  14417. * @param angle defines the angle (in radians) to use
  14418. * @return the new matrix
  14419. */
  14420. static RotationZ(angle: number): Matrix;
  14421. /**
  14422. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  14423. * @param angle defines the angle (in radians) to use
  14424. * @param result defines the target matrix
  14425. */
  14426. static RotationZToRef(angle: number, result: Matrix): void;
  14427. /**
  14428. * Creates a new rotation matrix for "angle" radians around the given axis
  14429. * @param axis defines the axis to use
  14430. * @param angle defines the angle (in radians) to use
  14431. * @return the new matrix
  14432. */
  14433. static RotationAxis(axis: Vector3, angle: number): Matrix;
  14434. /**
  14435. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  14436. * @param axis defines the axis to use
  14437. * @param angle defines the angle (in radians) to use
  14438. * @param result defines the target matrix
  14439. */
  14440. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  14441. /**
  14442. * Creates a rotation matrix
  14443. * @param yaw defines the yaw angle in radians (Y axis)
  14444. * @param pitch defines the pitch angle in radians (X axis)
  14445. * @param roll defines the roll angle in radians (X axis)
  14446. * @returns the new rotation matrix
  14447. */
  14448. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  14449. /**
  14450. * Creates a rotation matrix and stores it in a given matrix
  14451. * @param yaw defines the yaw angle in radians (Y axis)
  14452. * @param pitch defines the pitch angle in radians (X axis)
  14453. * @param roll defines the roll angle in radians (X axis)
  14454. * @param result defines the target matrix
  14455. */
  14456. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  14457. /**
  14458. * Creates a scaling matrix
  14459. * @param x defines the scale factor on X axis
  14460. * @param y defines the scale factor on Y axis
  14461. * @param z defines the scale factor on Z axis
  14462. * @returns the new matrix
  14463. */
  14464. static Scaling(x: number, y: number, z: number): Matrix;
  14465. /**
  14466. * Creates a scaling matrix and stores it in a given matrix
  14467. * @param x defines the scale factor on X axis
  14468. * @param y defines the scale factor on Y axis
  14469. * @param z defines the scale factor on Z axis
  14470. * @param result defines the target matrix
  14471. */
  14472. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  14473. /**
  14474. * Creates a translation matrix
  14475. * @param x defines the translation on X axis
  14476. * @param y defines the translation on Y axis
  14477. * @param z defines the translationon Z axis
  14478. * @returns the new matrix
  14479. */
  14480. static Translation(x: number, y: number, z: number): Matrix;
  14481. /**
  14482. * Creates a translation matrix and stores it in a given matrix
  14483. * @param x defines the translation on X axis
  14484. * @param y defines the translation on Y axis
  14485. * @param z defines the translationon Z axis
  14486. * @param result defines the target matrix
  14487. */
  14488. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  14489. /**
  14490. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  14491. * @param startValue defines the start value
  14492. * @param endValue defines the end value
  14493. * @param gradient defines the gradient factor
  14494. * @returns the new matrix
  14495. */
  14496. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  14497. /**
  14498. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  14499. * @param startValue defines the start value
  14500. * @param endValue defines the end value
  14501. * @param gradient defines the gradient factor
  14502. * @param result defines the Matrix object where to store data
  14503. */
  14504. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  14505. /**
  14506. * Builds a new matrix whose values are computed by:
  14507. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  14508. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  14509. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  14510. * @param startValue defines the first matrix
  14511. * @param endValue defines the second matrix
  14512. * @param gradient defines the gradient between the two matrices
  14513. * @returns the new matrix
  14514. */
  14515. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  14516. /**
  14517. * Update a matrix to values which are computed by:
  14518. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  14519. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  14520. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  14521. * @param startValue defines the first matrix
  14522. * @param endValue defines the second matrix
  14523. * @param gradient defines the gradient between the two matrices
  14524. * @param result defines the target matrix
  14525. */
  14526. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  14527. /**
  14528. * 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"
  14529. * This function works in left handed mode
  14530. * @param eye defines the final position of the entity
  14531. * @param target defines where the entity should look at
  14532. * @param up defines the up vector for the entity
  14533. * @returns the new matrix
  14534. */
  14535. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  14536. /**
  14537. * 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".
  14538. * This function works in left handed mode
  14539. * @param eye defines the final position of the entity
  14540. * @param target defines where the entity should look at
  14541. * @param up defines the up vector for the entity
  14542. * @param result defines the target matrix
  14543. */
  14544. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  14545. /**
  14546. * 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"
  14547. * This function works in right handed mode
  14548. * @param eye defines the final position of the entity
  14549. * @param target defines where the entity should look at
  14550. * @param up defines the up vector for the entity
  14551. * @returns the new matrix
  14552. */
  14553. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  14554. /**
  14555. * 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".
  14556. * This function works in right handed mode
  14557. * @param eye defines the final position of the entity
  14558. * @param target defines where the entity should look at
  14559. * @param up defines the up vector for the entity
  14560. * @param result defines the target matrix
  14561. */
  14562. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  14563. /**
  14564. * Create a left-handed orthographic projection matrix
  14565. * @param width defines the viewport width
  14566. * @param height defines the viewport height
  14567. * @param znear defines the near clip plane
  14568. * @param zfar defines the far clip plane
  14569. * @returns a new matrix as a left-handed orthographic projection matrix
  14570. */
  14571. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  14572. /**
  14573. * Store a left-handed orthographic projection to a given matrix
  14574. * @param width defines the viewport width
  14575. * @param height defines the viewport height
  14576. * @param znear defines the near clip plane
  14577. * @param zfar defines the far clip plane
  14578. * @param result defines the target matrix
  14579. */
  14580. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  14581. /**
  14582. * Create a left-handed orthographic projection matrix
  14583. * @param left defines the viewport left coordinate
  14584. * @param right defines the viewport right coordinate
  14585. * @param bottom defines the viewport bottom coordinate
  14586. * @param top defines the viewport top coordinate
  14587. * @param znear defines the near clip plane
  14588. * @param zfar defines the far clip plane
  14589. * @returns a new matrix as a left-handed orthographic projection matrix
  14590. */
  14591. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  14592. /**
  14593. * Stores a left-handed orthographic projection into a given matrix
  14594. * @param left defines the viewport left coordinate
  14595. * @param right defines the viewport right coordinate
  14596. * @param bottom defines the viewport bottom coordinate
  14597. * @param top defines the viewport top coordinate
  14598. * @param znear defines the near clip plane
  14599. * @param zfar defines the far clip plane
  14600. * @param result defines the target matrix
  14601. */
  14602. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  14603. /**
  14604. * Creates a right-handed orthographic projection matrix
  14605. * @param left defines the viewport left coordinate
  14606. * @param right defines the viewport right coordinate
  14607. * @param bottom defines the viewport bottom coordinate
  14608. * @param top defines the viewport top coordinate
  14609. * @param znear defines the near clip plane
  14610. * @param zfar defines the far clip plane
  14611. * @returns a new matrix as a right-handed orthographic projection matrix
  14612. */
  14613. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  14614. /**
  14615. * Stores a right-handed orthographic projection into a given matrix
  14616. * @param left defines the viewport left coordinate
  14617. * @param right defines the viewport right coordinate
  14618. * @param bottom defines the viewport bottom coordinate
  14619. * @param top defines the viewport top coordinate
  14620. * @param znear defines the near clip plane
  14621. * @param zfar defines the far clip plane
  14622. * @param result defines the target matrix
  14623. */
  14624. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  14625. /**
  14626. * Creates a left-handed perspective projection matrix
  14627. * @param width defines the viewport width
  14628. * @param height defines the viewport height
  14629. * @param znear defines the near clip plane
  14630. * @param zfar defines the far clip plane
  14631. * @returns a new matrix as a left-handed perspective projection matrix
  14632. */
  14633. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  14634. /**
  14635. * Creates a left-handed perspective projection matrix
  14636. * @param fov defines the horizontal field of view
  14637. * @param aspect defines the aspect ratio
  14638. * @param znear defines the near clip plane
  14639. * @param zfar defines the far clip plane
  14640. * @returns a new matrix as a left-handed perspective projection matrix
  14641. */
  14642. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  14643. /**
  14644. * Stores a left-handed perspective projection into a given matrix
  14645. * @param fov defines the horizontal field of view
  14646. * @param aspect defines the aspect ratio
  14647. * @param znear defines the near clip plane
  14648. * @param zfar defines the far clip plane
  14649. * @param result defines the target matrix
  14650. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  14651. */
  14652. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  14653. /**
  14654. * Creates a right-handed perspective projection matrix
  14655. * @param fov defines the horizontal field of view
  14656. * @param aspect defines the aspect ratio
  14657. * @param znear defines the near clip plane
  14658. * @param zfar defines the far clip plane
  14659. * @returns a new matrix as a right-handed perspective projection matrix
  14660. */
  14661. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  14662. /**
  14663. * Stores a right-handed perspective projection into a given matrix
  14664. * @param fov defines the horizontal field of view
  14665. * @param aspect defines the aspect ratio
  14666. * @param znear defines the near clip plane
  14667. * @param zfar defines the far clip plane
  14668. * @param result defines the target matrix
  14669. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  14670. */
  14671. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  14672. /**
  14673. * Stores a perspective projection for WebVR info a given matrix
  14674. * @param fov defines the field of view
  14675. * @param znear defines the near clip plane
  14676. * @param zfar defines the far clip plane
  14677. * @param result defines the target matrix
  14678. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  14679. */
  14680. static PerspectiveFovWebVRToRef(fov: {
  14681. upDegrees: number;
  14682. downDegrees: number;
  14683. leftDegrees: number;
  14684. rightDegrees: number;
  14685. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  14686. /**
  14687. * Computes a complete transformation matrix
  14688. * @param viewport defines the viewport to use
  14689. * @param world defines the world matrix
  14690. * @param view defines the view matrix
  14691. * @param projection defines the projection matrix
  14692. * @param zmin defines the near clip plane
  14693. * @param zmax defines the far clip plane
  14694. * @returns the transformation matrix
  14695. */
  14696. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  14697. /**
  14698. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  14699. * @param matrix defines the matrix to use
  14700. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  14701. */
  14702. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  14703. /**
  14704. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  14705. * @param matrix defines the matrix to use
  14706. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  14707. */
  14708. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  14709. /**
  14710. * Compute the transpose of a given matrix
  14711. * @param matrix defines the matrix to transpose
  14712. * @returns the new matrix
  14713. */
  14714. static Transpose(matrix: Matrix): Matrix;
  14715. /**
  14716. * Compute the transpose of a matrix and store it in a target matrix
  14717. * @param matrix defines the matrix to transpose
  14718. * @param result defines the target matrix
  14719. */
  14720. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  14721. /**
  14722. * Computes a reflection matrix from a plane
  14723. * @param plane defines the reflection plane
  14724. * @returns a new matrix
  14725. */
  14726. static Reflection(plane: Plane): Matrix;
  14727. /**
  14728. * Computes a reflection matrix from a plane
  14729. * @param plane defines the reflection plane
  14730. * @param result defines the target matrix
  14731. */
  14732. static ReflectionToRef(plane: Plane, result: Matrix): void;
  14733. /**
  14734. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  14735. * @param xaxis defines the value of the 1st axis
  14736. * @param yaxis defines the value of the 2nd axis
  14737. * @param zaxis defines the value of the 3rd axis
  14738. * @param result defines the target matrix
  14739. */
  14740. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  14741. /**
  14742. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  14743. * @param quat defines the quaternion to use
  14744. * @param result defines the target matrix
  14745. */
  14746. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  14747. }
  14748. class Plane {
  14749. normal: Vector3;
  14750. d: number;
  14751. /**
  14752. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  14753. */
  14754. constructor(a: number, b: number, c: number, d: number);
  14755. /**
  14756. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  14757. */
  14758. asArray(): number[];
  14759. /**
  14760. * Returns a new plane copied from the current Plane.
  14761. */
  14762. clone(): Plane;
  14763. /**
  14764. * Returns the string "Plane".
  14765. */
  14766. getClassName(): string;
  14767. /**
  14768. * Returns the Plane hash code.
  14769. */
  14770. getHashCode(): number;
  14771. /**
  14772. * Normalize the current Plane in place.
  14773. * Returns the updated Plane.
  14774. */
  14775. normalize(): Plane;
  14776. /**
  14777. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  14778. */
  14779. transform(transformation: Matrix): Plane;
  14780. /**
  14781. * Returns the dot product (float) of the point coordinates and the plane normal.
  14782. */
  14783. dotCoordinate(point: Vector3): number;
  14784. /**
  14785. * Updates the current Plane from the plane defined by the three given points.
  14786. * Returns the updated Plane.
  14787. */
  14788. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  14789. /**
  14790. * Boolean : True is the vector "direction" is the same side than the plane normal.
  14791. */
  14792. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  14793. /**
  14794. * Returns the signed distance (float) from the given point to the Plane.
  14795. */
  14796. signedDistanceTo(point: Vector3): number;
  14797. /**
  14798. * Returns a new Plane from the given array.
  14799. */
  14800. static FromArray(array: ArrayLike<number>): Plane;
  14801. /**
  14802. * Returns a new Plane defined by the three given points.
  14803. */
  14804. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  14805. /**
  14806. * Returns a new Plane the normal vector to this plane at the given origin point.
  14807. * Note : the vector "normal" is updated because normalized.
  14808. */
  14809. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  14810. /**
  14811. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  14812. */
  14813. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  14814. }
  14815. class Viewport {
  14816. x: number;
  14817. y: number;
  14818. width: number;
  14819. height: number;
  14820. /**
  14821. * Creates a Viewport object located at (x, y) and sized (width, height).
  14822. */
  14823. constructor(x: number, y: number, width: number, height: number);
  14824. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  14825. /**
  14826. * Returns a new Viewport copied from the current one.
  14827. */
  14828. clone(): Viewport;
  14829. }
  14830. class Frustum {
  14831. /**
  14832. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14833. */
  14834. static GetPlanes(transform: Matrix): Plane[];
  14835. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14836. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14837. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14838. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14839. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14840. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  14841. /**
  14842. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14843. */
  14844. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  14845. }
  14846. /** Defines supported spaces */
  14847. enum Space {
  14848. /** Local (object) space */
  14849. LOCAL = 0,
  14850. /** World space */
  14851. WORLD = 1,
  14852. /** Bone space */
  14853. BONE = 2,
  14854. }
  14855. /** Defines the 3 main axes */
  14856. class Axis {
  14857. /** X axis */
  14858. static X: Vector3;
  14859. /** Y axis */
  14860. static Y: Vector3;
  14861. /** Z axis */
  14862. static Z: Vector3;
  14863. }
  14864. class BezierCurve {
  14865. /**
  14866. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  14867. */
  14868. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  14869. }
  14870. /**
  14871. * Defines potential orientation for back face culling
  14872. */
  14873. enum Orientation {
  14874. /**
  14875. * Clockwise
  14876. */
  14877. CW = 0,
  14878. /** Counter clockwise */
  14879. CCW = 1,
  14880. }
  14881. /**
  14882. * Defines angle representation
  14883. */
  14884. class Angle {
  14885. private _radians;
  14886. /**
  14887. * Creates an Angle object of "radians" radians (float).
  14888. */
  14889. constructor(radians: number);
  14890. /**
  14891. * Get value in degrees
  14892. * @returns the Angle value in degrees (float)
  14893. */
  14894. degrees(): number;
  14895. /**
  14896. * Get value in radians
  14897. * @returns the Angle value in radians (float)
  14898. */
  14899. radians(): number;
  14900. /**
  14901. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  14902. * @param a defines first vector
  14903. * @param b defines second vector
  14904. * @returns a new Angle
  14905. */
  14906. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  14907. /**
  14908. * Gets a new Angle object from the given float in radians
  14909. * @param radians defines the angle value in radians
  14910. * @returns a new Angle
  14911. */
  14912. static FromRadians(radians: number): Angle;
  14913. /**
  14914. * Gets a new Angle object from the given float in degrees
  14915. * @param degrees defines the angle value in degrees
  14916. * @returns a new Angle
  14917. */
  14918. static FromDegrees(degrees: number): Angle;
  14919. }
  14920. class Arc2 {
  14921. startPoint: Vector2;
  14922. midPoint: Vector2;
  14923. endPoint: Vector2;
  14924. centerPoint: Vector2;
  14925. radius: number;
  14926. angle: Angle;
  14927. startAngle: Angle;
  14928. orientation: Orientation;
  14929. /**
  14930. * Creates an Arc object from the three given points : start, middle and end.
  14931. */
  14932. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  14933. }
  14934. class Path2 {
  14935. private _points;
  14936. private _length;
  14937. closed: boolean;
  14938. /**
  14939. * Creates a Path2 object from the starting 2D coordinates x and y.
  14940. */
  14941. constructor(x: number, y: number);
  14942. /**
  14943. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  14944. * Returns the updated Path2.
  14945. */
  14946. addLineTo(x: number, y: number): Path2;
  14947. /**
  14948. * 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.
  14949. * Returns the updated Path2.
  14950. */
  14951. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  14952. /**
  14953. * Closes the Path2.
  14954. * Returns the Path2.
  14955. */
  14956. close(): Path2;
  14957. /**
  14958. * Returns the Path2 total length (float).
  14959. */
  14960. length(): number;
  14961. /**
  14962. * Returns the Path2 internal array of points.
  14963. */
  14964. getPoints(): Vector2[];
  14965. /**
  14966. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  14967. */
  14968. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  14969. /**
  14970. * Returns a new Path2 starting at the coordinates (x, y).
  14971. */
  14972. static StartingAt(x: number, y: number): Path2;
  14973. }
  14974. class Path3D {
  14975. path: Vector3[];
  14976. private _curve;
  14977. private _distances;
  14978. private _tangents;
  14979. private _normals;
  14980. private _binormals;
  14981. private _raw;
  14982. /**
  14983. * new Path3D(path, normal, raw)
  14984. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  14985. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  14986. * path : an array of Vector3, the curve axis of the Path3D
  14987. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  14988. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  14989. */
  14990. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  14991. /**
  14992. * Returns the Path3D array of successive Vector3 designing its curve.
  14993. */
  14994. getCurve(): Vector3[];
  14995. /**
  14996. * Returns an array populated with tangent vectors on each Path3D curve point.
  14997. */
  14998. getTangents(): Vector3[];
  14999. /**
  15000. * Returns an array populated with normal vectors on each Path3D curve point.
  15001. */
  15002. getNormals(): Vector3[];
  15003. /**
  15004. * Returns an array populated with binormal vectors on each Path3D curve point.
  15005. */
  15006. getBinormals(): Vector3[];
  15007. /**
  15008. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  15009. */
  15010. getDistances(): number[];
  15011. /**
  15012. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  15013. * Returns the same object updated.
  15014. */
  15015. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  15016. private _compute(firstNormal);
  15017. private _getFirstNonNullVector(index);
  15018. private _getLastNonNullVector(index);
  15019. private _normalVector(v0, vt, va);
  15020. }
  15021. class Curve3 {
  15022. private _points;
  15023. private _length;
  15024. /**
  15025. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  15026. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  15027. * @param v1 (Vector3) the control point
  15028. * @param v2 (Vector3) the end point of the Quadratic Bezier
  15029. * @param nbPoints (integer) the wanted number of points in the curve
  15030. */
  15031. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  15032. /**
  15033. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  15034. * @param v0 (Vector3) the origin point of the Cubic Bezier
  15035. * @param v1 (Vector3) the first control point
  15036. * @param v2 (Vector3) the second control point
  15037. * @param v3 (Vector3) the end point of the Cubic Bezier
  15038. * @param nbPoints (integer) the wanted number of points in the curve
  15039. */
  15040. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  15041. /**
  15042. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  15043. * @param p1 (Vector3) the origin point of the Hermite Spline
  15044. * @param t1 (Vector3) the tangent vector at the origin point
  15045. * @param p2 (Vector3) the end point of the Hermite Spline
  15046. * @param t2 (Vector3) the tangent vector at the end point
  15047. * @param nbPoints (integer) the wanted number of points in the curve
  15048. */
  15049. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  15050. /**
  15051. * Returns a Curve3 object along a CatmullRom Spline curve :
  15052. * @param points (array of Vector3) the points the spline must pass through. At least, four points required.
  15053. * @param nbPoints (integer) the wanted number of points between each curve control points.
  15054. */
  15055. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3;
  15056. /**
  15057. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  15058. * A Curve3 is designed from a series of successive Vector3.
  15059. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  15060. */
  15061. constructor(points: Vector3[]);
  15062. /**
  15063. * Returns the Curve3 stored array of successive Vector3
  15064. */
  15065. getPoints(): Vector3[];
  15066. /**
  15067. * Returns the computed length (float) of the curve.
  15068. */
  15069. length(): number;
  15070. /**
  15071. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  15072. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  15073. * curveA and curveB keep unchanged.
  15074. */
  15075. continue(curve: Curve3): Curve3;
  15076. private _computeLength(path);
  15077. }
  15078. class PositionNormalVertex {
  15079. position: Vector3;
  15080. normal: Vector3;
  15081. constructor(position?: Vector3, normal?: Vector3);
  15082. clone(): PositionNormalVertex;
  15083. }
  15084. class PositionNormalTextureVertex {
  15085. position: Vector3;
  15086. normal: Vector3;
  15087. uv: Vector2;
  15088. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  15089. clone(): PositionNormalTextureVertex;
  15090. }
  15091. class Tmp {
  15092. static Color3: Color3[];
  15093. static Vector2: Vector2[];
  15094. static Vector3: Vector3[];
  15095. static Vector4: Vector4[];
  15096. static Quaternion: Quaternion[];
  15097. static Matrix: Matrix[];
  15098. }
  15099. }
  15100. declare module BABYLON {
  15101. class SphericalPolynomial {
  15102. x: Vector3;
  15103. y: Vector3;
  15104. z: Vector3;
  15105. xx: Vector3;
  15106. yy: Vector3;
  15107. zz: Vector3;
  15108. xy: Vector3;
  15109. yz: Vector3;
  15110. zx: Vector3;
  15111. addAmbient(color: Color3): void;
  15112. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  15113. scale(scale: number): void;
  15114. }
  15115. class SphericalHarmonics {
  15116. L00: Vector3;
  15117. L1_1: Vector3;
  15118. L10: Vector3;
  15119. L11: Vector3;
  15120. L2_2: Vector3;
  15121. L2_1: Vector3;
  15122. L20: Vector3;
  15123. L21: Vector3;
  15124. L22: Vector3;
  15125. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  15126. scale(scale: number): void;
  15127. convertIncidentRadianceToIrradiance(): void;
  15128. convertIrradianceToLambertianRadiance(): void;
  15129. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  15130. }
  15131. }
  15132. declare module BABYLON {
  15133. /**
  15134. * Defines a target to use with MorphTargetManager
  15135. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  15136. */
  15137. class MorphTarget implements IAnimatable {
  15138. /** defines the name of the target */
  15139. name: string;
  15140. /**
  15141. * Gets or sets the list of animations
  15142. */
  15143. animations: Animation[];
  15144. private _scene;
  15145. private _positions;
  15146. private _normals;
  15147. private _tangents;
  15148. private _influence;
  15149. /**
  15150. * Observable raised when the influence changes
  15151. */
  15152. onInfluenceChanged: Observable<boolean>;
  15153. /**
  15154. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  15155. */
  15156. influence: number;
  15157. private _animationPropertiesOverride;
  15158. /**
  15159. * Gets or sets the animation properties override
  15160. */
  15161. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  15162. /**
  15163. * Creates a new MorphTarget
  15164. * @param name defines the name of the target
  15165. * @param influence defines the influence to use
  15166. */
  15167. constructor(
  15168. /** defines the name of the target */
  15169. name: string, influence?: number, scene?: Nullable<Scene>);
  15170. /**
  15171. * Gets a boolean defining if the target contains position data
  15172. */
  15173. readonly hasPositions: boolean;
  15174. /**
  15175. * Gets a boolean defining if the target contains normal data
  15176. */
  15177. readonly hasNormals: boolean;
  15178. /**
  15179. * Gets a boolean defining if the target contains tangent data
  15180. */
  15181. readonly hasTangents: boolean;
  15182. /**
  15183. * Affects position data to this target
  15184. * @param data defines the position data to use
  15185. */
  15186. setPositions(data: Nullable<FloatArray>): void;
  15187. /**
  15188. * Gets the position data stored in this target
  15189. * @returns a FloatArray containing the position data (or null if not present)
  15190. */
  15191. getPositions(): Nullable<FloatArray>;
  15192. /**
  15193. * Affects normal data to this target
  15194. * @param data defines the normal data to use
  15195. */
  15196. setNormals(data: Nullable<FloatArray>): void;
  15197. /**
  15198. * Gets the normal data stored in this target
  15199. * @returns a FloatArray containing the normal data (or null if not present)
  15200. */
  15201. getNormals(): Nullable<FloatArray>;
  15202. /**
  15203. * Affects tangent data to this target
  15204. * @param data defines the tangent data to use
  15205. */
  15206. setTangents(data: Nullable<FloatArray>): void;
  15207. /**
  15208. * Gets the tangent data stored in this target
  15209. * @returns a FloatArray containing the tangent data (or null if not present)
  15210. */
  15211. getTangents(): Nullable<FloatArray>;
  15212. /**
  15213. * Serializes the current target into a Serialization object
  15214. * @returns the serialized object
  15215. */
  15216. serialize(): any;
  15217. /**
  15218. * Creates a new target from serialized data
  15219. * @param serializationObject defines the serialized data to use
  15220. * @returns a new MorphTarget
  15221. */
  15222. static Parse(serializationObject: any): MorphTarget;
  15223. /**
  15224. * Creates a MorphTarget from mesh data
  15225. * @param mesh defines the source mesh
  15226. * @param name defines the name to use for the new target
  15227. * @param influence defines the influence to attach to the target
  15228. * @returns a new MorphTarget
  15229. */
  15230. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  15231. }
  15232. }
  15233. declare module BABYLON {
  15234. /**
  15235. * This class is used to deform meshes using morphing between different targets
  15236. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  15237. */
  15238. class MorphTargetManager {
  15239. private _targets;
  15240. private _targetObservable;
  15241. private _activeTargets;
  15242. private _scene;
  15243. private _influences;
  15244. private _supportsNormals;
  15245. private _supportsTangents;
  15246. private _vertexCount;
  15247. private _uniqueId;
  15248. private _tempInfluences;
  15249. /**
  15250. * Creates a new MorphTargetManager
  15251. * @param scene defines the current scene
  15252. */
  15253. constructor(scene?: Nullable<Scene>);
  15254. /**
  15255. * Gets the unique ID of this manager
  15256. */
  15257. readonly uniqueId: number;
  15258. /**
  15259. * Gets the number of vertices handled by this manager
  15260. */
  15261. readonly vertexCount: number;
  15262. /**
  15263. * Gets a boolean indicating if this manager supports morphing of normals
  15264. */
  15265. readonly supportsNormals: boolean;
  15266. /**
  15267. * Gets a boolean indicating if this manager supports morphing of tangents
  15268. */
  15269. readonly supportsTangents: boolean;
  15270. /**
  15271. * Gets the number of targets stored in this manager
  15272. */
  15273. readonly numTargets: number;
  15274. /**
  15275. * Gets the number of influencers (ie. the number of targets with influences > 0)
  15276. */
  15277. readonly numInfluencers: number;
  15278. /**
  15279. * Gets the list of influences (one per target)
  15280. */
  15281. readonly influences: Float32Array;
  15282. /**
  15283. * Gets the active target at specified index. An active target is a target with an influence > 0
  15284. * @param index defines the index to check
  15285. * @returns the requested target
  15286. */
  15287. getActiveTarget(index: number): MorphTarget;
  15288. /**
  15289. * Gets the target at specified index
  15290. * @param index defines the index to check
  15291. * @returns the requested target
  15292. */
  15293. getTarget(index: number): MorphTarget;
  15294. /**
  15295. * Add a new target to this manager
  15296. * @param target defines the target to add
  15297. */
  15298. addTarget(target: MorphTarget): void;
  15299. /**
  15300. * Removes a target from the manager
  15301. * @param target defines the target to remove
  15302. */
  15303. removeTarget(target: MorphTarget): void;
  15304. /**
  15305. * Serializes the current manager into a Serialization object
  15306. * @returns the serialized object
  15307. */
  15308. serialize(): any;
  15309. private _syncActiveTargets(needUpdate);
  15310. /**
  15311. * Syncrhonize the targets with all the meshes using this morph target manager
  15312. */
  15313. synchronize(): void;
  15314. /**
  15315. * Creates a new MorphTargetManager from serialized data
  15316. * @param serializationObject defines the serialized data
  15317. * @param scene defines the hosting scene
  15318. * @returns the new MorphTargetManager
  15319. */
  15320. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  15321. }
  15322. }
  15323. declare module BABYLON {
  15324. /**
  15325. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  15326. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  15327. * 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;
  15328. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  15329. */
  15330. class ColorCurves {
  15331. private _dirty;
  15332. private _tempColor;
  15333. private _globalCurve;
  15334. private _highlightsCurve;
  15335. private _midtonesCurve;
  15336. private _shadowsCurve;
  15337. private _positiveCurve;
  15338. private _negativeCurve;
  15339. private _globalHue;
  15340. private _globalDensity;
  15341. private _globalSaturation;
  15342. private _globalExposure;
  15343. /**
  15344. * Gets the global Hue value.
  15345. * 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).
  15346. */
  15347. /**
  15348. * Sets the global Hue value.
  15349. * 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).
  15350. */
  15351. globalHue: number;
  15352. /**
  15353. * Gets the global Density value.
  15354. * 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.
  15355. * Values less than zero provide a filter of opposite hue.
  15356. */
  15357. /**
  15358. * Sets the global Density value.
  15359. * 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.
  15360. * Values less than zero provide a filter of opposite hue.
  15361. */
  15362. globalDensity: number;
  15363. /**
  15364. * Gets the global Saturation value.
  15365. * 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.
  15366. */
  15367. /**
  15368. * Sets the global Saturation value.
  15369. * 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.
  15370. */
  15371. globalSaturation: number;
  15372. private _highlightsHue;
  15373. private _highlightsDensity;
  15374. private _highlightsSaturation;
  15375. private _highlightsExposure;
  15376. /**
  15377. * Gets the highlights Hue value.
  15378. * 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).
  15379. */
  15380. /**
  15381. * Sets the highlights Hue value.
  15382. * 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).
  15383. */
  15384. highlightsHue: number;
  15385. /**
  15386. * Gets the highlights Density value.
  15387. * 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.
  15388. * Values less than zero provide a filter of opposite hue.
  15389. */
  15390. /**
  15391. * Sets the highlights Density value.
  15392. * 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.
  15393. * Values less than zero provide a filter of opposite hue.
  15394. */
  15395. highlightsDensity: number;
  15396. /**
  15397. * Gets the highlights Saturation value.
  15398. * 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.
  15399. */
  15400. /**
  15401. * Sets the highlights Saturation value.
  15402. * 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.
  15403. */
  15404. highlightsSaturation: number;
  15405. /**
  15406. * Gets the highlights Exposure value.
  15407. * 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.
  15408. */
  15409. /**
  15410. * Sets the highlights Exposure value.
  15411. * 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.
  15412. */
  15413. highlightsExposure: number;
  15414. private _midtonesHue;
  15415. private _midtonesDensity;
  15416. private _midtonesSaturation;
  15417. private _midtonesExposure;
  15418. /**
  15419. * Gets the midtones Hue value.
  15420. * 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).
  15421. */
  15422. /**
  15423. * Sets the midtones Hue value.
  15424. * 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).
  15425. */
  15426. midtonesHue: number;
  15427. /**
  15428. * Gets the midtones Density value.
  15429. * 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.
  15430. * Values less than zero provide a filter of opposite hue.
  15431. */
  15432. /**
  15433. * Sets the midtones Density value.
  15434. * 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.
  15435. * Values less than zero provide a filter of opposite hue.
  15436. */
  15437. midtonesDensity: number;
  15438. /**
  15439. * Gets the midtones Saturation value.
  15440. * 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.
  15441. */
  15442. /**
  15443. * Sets the midtones Saturation value.
  15444. * 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.
  15445. */
  15446. midtonesSaturation: number;
  15447. /**
  15448. * Gets the midtones Exposure value.
  15449. * 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.
  15450. */
  15451. /**
  15452. * Sets the midtones Exposure value.
  15453. * 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.
  15454. */
  15455. midtonesExposure: number;
  15456. private _shadowsHue;
  15457. private _shadowsDensity;
  15458. private _shadowsSaturation;
  15459. private _shadowsExposure;
  15460. /**
  15461. * Gets the shadows Hue value.
  15462. * 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).
  15463. */
  15464. /**
  15465. * Sets the shadows Hue value.
  15466. * 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).
  15467. */
  15468. shadowsHue: number;
  15469. /**
  15470. * Gets the shadows Density value.
  15471. * 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.
  15472. * Values less than zero provide a filter of opposite hue.
  15473. */
  15474. /**
  15475. * Sets the shadows Density value.
  15476. * 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.
  15477. * Values less than zero provide a filter of opposite hue.
  15478. */
  15479. shadowsDensity: number;
  15480. /**
  15481. * Gets the shadows Saturation value.
  15482. * 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.
  15483. */
  15484. /**
  15485. * Sets the shadows Saturation value.
  15486. * 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.
  15487. */
  15488. shadowsSaturation: number;
  15489. /**
  15490. * Gets the shadows Exposure value.
  15491. * 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.
  15492. */
  15493. /**
  15494. * Sets the shadows Exposure value.
  15495. * 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.
  15496. */
  15497. shadowsExposure: number;
  15498. getClassName(): string;
  15499. /**
  15500. * Binds the color curves to the shader.
  15501. * @param colorCurves The color curve to bind
  15502. * @param effect The effect to bind to
  15503. */
  15504. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  15505. /**
  15506. * Prepare the list of uniforms associated with the ColorCurves effects.
  15507. * @param uniformsList The list of uniforms used in the effect
  15508. */
  15509. static PrepareUniforms(uniformsList: string[]): void;
  15510. /**
  15511. * Returns color grading data based on a hue, density, saturation and exposure value.
  15512. * @param filterHue The hue of the color filter.
  15513. * @param filterDensity The density of the color filter.
  15514. * @param saturation The saturation.
  15515. * @param exposure The exposure.
  15516. * @param result The result data container.
  15517. */
  15518. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  15519. /**
  15520. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  15521. * @param value The input slider value in range [-100,100].
  15522. * @returns Adjusted value.
  15523. */
  15524. private static applyColorGradingSliderNonlinear(value);
  15525. /**
  15526. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  15527. * @param hue The hue (H) input.
  15528. * @param saturation The saturation (S) input.
  15529. * @param brightness The brightness (B) input.
  15530. * @result An RGBA color represented as Vector4.
  15531. */
  15532. private static fromHSBToRef(hue, saturation, brightness, result);
  15533. /**
  15534. * Returns a value clamped between min and max
  15535. * @param value The value to clamp
  15536. * @param min The minimum of value
  15537. * @param max The maximum of value
  15538. * @returns The clamped value.
  15539. */
  15540. private static clamp(value, min, max);
  15541. /**
  15542. * Clones the current color curve instance.
  15543. * @return The cloned curves
  15544. */
  15545. clone(): ColorCurves;
  15546. /**
  15547. * Serializes the current color curve instance to a json representation.
  15548. * @return a JSON representation
  15549. */
  15550. serialize(): any;
  15551. /**
  15552. * Parses the color curve from a json representation.
  15553. * @param source the JSON source to parse
  15554. * @return The parsed curves
  15555. */
  15556. static Parse(source: any): ColorCurves;
  15557. }
  15558. }
  15559. declare module BABYLON {
  15560. /**
  15561. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  15562. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  15563. */
  15564. class EffectFallbacks {
  15565. private _defines;
  15566. private _currentRank;
  15567. private _maxRank;
  15568. private _mesh;
  15569. /**
  15570. * Removes the fallback from the bound mesh.
  15571. */
  15572. unBindMesh(): void;
  15573. /**
  15574. * Adds a fallback on the specified property.
  15575. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  15576. * @param define The name of the define in the shader
  15577. */
  15578. addFallback(rank: number, define: string): void;
  15579. /**
  15580. * Sets the mesh to use CPU skinning when needing to fallback.
  15581. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  15582. * @param mesh The mesh to use the fallbacks.
  15583. */
  15584. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  15585. /**
  15586. * Checks to see if more fallbacks are still availible.
  15587. */
  15588. readonly isMoreFallbacks: boolean;
  15589. /**
  15590. * Removes the defines that shoould be removed when falling back.
  15591. * @param currentDefines defines the current define statements for the shader.
  15592. * @param effect defines the current effect we try to compile
  15593. * @returns The resulting defines with defines of the current rank removed.
  15594. */
  15595. reduce(currentDefines: string, effect: Effect): string;
  15596. }
  15597. /**
  15598. * Options to be used when creating an effect.
  15599. */
  15600. class EffectCreationOptions {
  15601. /**
  15602. * Atrributes that will be used in the shader.
  15603. */
  15604. attributes: string[];
  15605. /**
  15606. * Uniform varible names that will be set in the shader.
  15607. */
  15608. uniformsNames: string[];
  15609. /**
  15610. * Uniform buffer varible names that will be set in the shader.
  15611. */
  15612. uniformBuffersNames: string[];
  15613. /**
  15614. * Sampler texture variable names that will be set in the shader.
  15615. */
  15616. samplers: string[];
  15617. /**
  15618. * Define statements that will be set in the shader.
  15619. */
  15620. defines: any;
  15621. /**
  15622. * Possible fallbacks for this effect to improve performance when needed.
  15623. */
  15624. fallbacks: Nullable<EffectFallbacks>;
  15625. /**
  15626. * Callback that will be called when the shader is compiled.
  15627. */
  15628. onCompiled: Nullable<(effect: Effect) => void>;
  15629. /**
  15630. * Callback that will be called if an error occurs during shader compilation.
  15631. */
  15632. onError: Nullable<(effect: Effect, errors: string) => void>;
  15633. /**
  15634. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  15635. */
  15636. indexParameters: any;
  15637. /**
  15638. * Max number of lights that can be used in the shader.
  15639. */
  15640. maxSimultaneousLights: number;
  15641. /**
  15642. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  15643. */
  15644. transformFeedbackVaryings: Nullable<string[]>;
  15645. }
  15646. /**
  15647. * Effect containing vertex and fragment shader that can be executed on an object.
  15648. */
  15649. class Effect {
  15650. /**
  15651. * Name of the effect.
  15652. */
  15653. name: any;
  15654. /**
  15655. * String container all the define statements that should be set on the shader.
  15656. */
  15657. defines: string;
  15658. /**
  15659. * Callback that will be called when the shader is compiled.
  15660. */
  15661. onCompiled: Nullable<(effect: Effect) => void>;
  15662. /**
  15663. * Callback that will be called if an error occurs during shader compilation.
  15664. */
  15665. onError: Nullable<(effect: Effect, errors: string) => void>;
  15666. /**
  15667. * Callback that will be called when effect is bound.
  15668. */
  15669. onBind: Nullable<(effect: Effect) => void>;
  15670. /**
  15671. * Unique ID of the effect.
  15672. */
  15673. uniqueId: number;
  15674. /**
  15675. * Observable that will be called when the shader is compiled.
  15676. */
  15677. onCompileObservable: Observable<Effect>;
  15678. /**
  15679. * Observable that will be called if an error occurs during shader compilation.
  15680. */
  15681. onErrorObservable: Observable<Effect>;
  15682. /**
  15683. * Observable that will be called when effect is bound.
  15684. */
  15685. onBindObservable: Observable<Effect>;
  15686. private static _uniqueIdSeed;
  15687. private _engine;
  15688. private _uniformBuffersNames;
  15689. private _uniformsNames;
  15690. private _samplers;
  15691. private _isReady;
  15692. private _compilationError;
  15693. private _attributesNames;
  15694. private _attributes;
  15695. private _uniforms;
  15696. /**
  15697. * Key for the effect.
  15698. */
  15699. _key: string;
  15700. private _indexParameters;
  15701. private _fallbacks;
  15702. private _vertexSourceCode;
  15703. private _fragmentSourceCode;
  15704. private _vertexSourceCodeOverride;
  15705. private _fragmentSourceCodeOverride;
  15706. private _transformFeedbackVaryings;
  15707. /**
  15708. * Compiled shader to webGL program.
  15709. */
  15710. _program: WebGLProgram;
  15711. private _valueCache;
  15712. private static _baseCache;
  15713. /**
  15714. * Instantiates an effect.
  15715. * An effect can be used to create/manage/execute vertex and fragment shaders.
  15716. * @param baseName Name of the effect.
  15717. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  15718. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  15719. * @param samplers List of sampler variables that will be passed to the shader.
  15720. * @param engine Engine to be used to render the effect
  15721. * @param defines Define statements to be added to the shader.
  15722. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  15723. * @param onCompiled Callback that will be called when the shader is compiled.
  15724. * @param onError Callback that will be called if an error occurs during shader compilation.
  15725. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  15726. */
  15727. 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);
  15728. /**
  15729. * Unique key for this effect
  15730. */
  15731. readonly key: string;
  15732. /**
  15733. * If the effect has been compiled and prepared.
  15734. * @returns if the effect is compiled and prepared.
  15735. */
  15736. isReady(): boolean;
  15737. /**
  15738. * The engine the effect was initialized with.
  15739. * @returns the engine.
  15740. */
  15741. getEngine(): Engine;
  15742. /**
  15743. * The compiled webGL program for the effect
  15744. * @returns the webGL program.
  15745. */
  15746. getProgram(): WebGLProgram;
  15747. /**
  15748. * The set of names of attribute variables for the shader.
  15749. * @returns An array of attribute names.
  15750. */
  15751. getAttributesNames(): string[];
  15752. /**
  15753. * Returns the attribute at the given index.
  15754. * @param index The index of the attribute.
  15755. * @returns The location of the attribute.
  15756. */
  15757. getAttributeLocation(index: number): number;
  15758. /**
  15759. * Returns the attribute based on the name of the variable.
  15760. * @param name of the attribute to look up.
  15761. * @returns the attribute location.
  15762. */
  15763. getAttributeLocationByName(name: string): number;
  15764. /**
  15765. * The number of attributes.
  15766. * @returns the numnber of attributes.
  15767. */
  15768. getAttributesCount(): number;
  15769. /**
  15770. * Gets the index of a uniform variable.
  15771. * @param uniformName of the uniform to look up.
  15772. * @returns the index.
  15773. */
  15774. getUniformIndex(uniformName: string): number;
  15775. /**
  15776. * Returns the attribute based on the name of the variable.
  15777. * @param uniformName of the uniform to look up.
  15778. * @returns the location of the uniform.
  15779. */
  15780. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  15781. /**
  15782. * Returns an array of sampler variable names
  15783. * @returns The array of sampler variable neames.
  15784. */
  15785. getSamplers(): string[];
  15786. /**
  15787. * The error from the last compilation.
  15788. * @returns the error string.
  15789. */
  15790. getCompilationError(): string;
  15791. /**
  15792. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  15793. * @param func The callback to be used.
  15794. */
  15795. executeWhenCompiled(func: (effect: Effect) => void): void;
  15796. /** @hidden */
  15797. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  15798. /** @hidden */
  15799. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  15800. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  15801. private _processShaderConversion(sourceCode, isFragment, callback);
  15802. private _processIncludes(sourceCode, callback);
  15803. private _processPrecision(source);
  15804. /**
  15805. * Recompiles the webGL program
  15806. * @param vertexSourceCode The source code for the vertex shader.
  15807. * @param fragmentSourceCode The source code for the fragment shader.
  15808. * @param onCompiled Callback called when completed.
  15809. * @param onError Callback called on error.
  15810. */
  15811. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  15812. /**
  15813. * Gets the uniform locations of the the specified variable names
  15814. * @param names THe names of the variables to lookup.
  15815. * @returns Array of locations in the same order as variable names.
  15816. */
  15817. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  15818. /**
  15819. * Prepares the effect
  15820. */
  15821. _prepareEffect(): void;
  15822. /**
  15823. * Checks if the effect is supported. (Must be called after compilation)
  15824. */
  15825. readonly isSupported: boolean;
  15826. /**
  15827. * Binds a texture to the engine to be used as output of the shader.
  15828. * @param channel Name of the output variable.
  15829. * @param texture Texture to bind.
  15830. */
  15831. _bindTexture(channel: string, texture: InternalTexture): void;
  15832. /**
  15833. * Sets a texture on the engine to be used in the shader.
  15834. * @param channel Name of the sampler variable.
  15835. * @param texture Texture to set.
  15836. */
  15837. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  15838. /**
  15839. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  15840. * @param channel Name of the sampler variable.
  15841. * @param texture Texture to set.
  15842. */
  15843. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  15844. /**
  15845. * Sets an array of textures on the engine to be used in the shader.
  15846. * @param channel Name of the variable.
  15847. * @param textures Textures to set.
  15848. */
  15849. setTextureArray(channel: string, textures: BaseTexture[]): void;
  15850. /**
  15851. * 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)
  15852. * @param channel Name of the sampler variable.
  15853. * @param postProcess Post process to get the input texture from.
  15854. */
  15855. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  15856. /**
  15857. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  15858. * 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)
  15859. * @param channel Name of the sampler variable.
  15860. * @param postProcess Post process to get the output texture from.
  15861. */
  15862. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  15863. /** @hidden */
  15864. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  15865. /** @hidden */
  15866. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  15867. /** @hidden */
  15868. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  15869. /** @hidden */
  15870. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  15871. /**
  15872. * Binds a buffer to a uniform.
  15873. * @param buffer Buffer to bind.
  15874. * @param name Name of the uniform variable to bind to.
  15875. */
  15876. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  15877. /**
  15878. * Binds block to a uniform.
  15879. * @param blockName Name of the block to bind.
  15880. * @param index Index to bind.
  15881. */
  15882. bindUniformBlock(blockName: string, index: number): void;
  15883. /**
  15884. * Sets an interger value on a uniform variable.
  15885. * @param uniformName Name of the variable.
  15886. * @param value Value to be set.
  15887. * @returns this effect.
  15888. */
  15889. setInt(uniformName: string, value: number): Effect;
  15890. /**
  15891. * Sets an int array on a uniform variable.
  15892. * @param uniformName Name of the variable.
  15893. * @param array array to be set.
  15894. * @returns this effect.
  15895. */
  15896. setIntArray(uniformName: string, array: Int32Array): Effect;
  15897. /**
  15898. * 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)
  15899. * @param uniformName Name of the variable.
  15900. * @param array array to be set.
  15901. * @returns this effect.
  15902. */
  15903. setIntArray2(uniformName: string, array: Int32Array): Effect;
  15904. /**
  15905. * 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)
  15906. * @param uniformName Name of the variable.
  15907. * @param array array to be set.
  15908. * @returns this effect.
  15909. */
  15910. setIntArray3(uniformName: string, array: Int32Array): Effect;
  15911. /**
  15912. * 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)
  15913. * @param uniformName Name of the variable.
  15914. * @param array array to be set.
  15915. * @returns this effect.
  15916. */
  15917. setIntArray4(uniformName: string, array: Int32Array): Effect;
  15918. /**
  15919. * Sets an float array on a uniform variable.
  15920. * @param uniformName Name of the variable.
  15921. * @param array array to be set.
  15922. * @returns this effect.
  15923. */
  15924. setFloatArray(uniformName: string, array: Float32Array): Effect;
  15925. /**
  15926. * 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)
  15927. * @param uniformName Name of the variable.
  15928. * @param array array to be set.
  15929. * @returns this effect.
  15930. */
  15931. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  15932. /**
  15933. * 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)
  15934. * @param uniformName Name of the variable.
  15935. * @param array array to be set.
  15936. * @returns this effect.
  15937. */
  15938. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  15939. /**
  15940. * 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)
  15941. * @param uniformName Name of the variable.
  15942. * @param array array to be set.
  15943. * @returns this effect.
  15944. */
  15945. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  15946. /**
  15947. * Sets an array on a uniform variable.
  15948. * @param uniformName Name of the variable.
  15949. * @param array array to be set.
  15950. * @returns this effect.
  15951. */
  15952. setArray(uniformName: string, array: number[]): Effect;
  15953. /**
  15954. * 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)
  15955. * @param uniformName Name of the variable.
  15956. * @param array array to be set.
  15957. * @returns this effect.
  15958. */
  15959. setArray2(uniformName: string, array: number[]): Effect;
  15960. /**
  15961. * 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)
  15962. * @param uniformName Name of the variable.
  15963. * @param array array to be set.
  15964. * @returns this effect.
  15965. */
  15966. setArray3(uniformName: string, array: number[]): Effect;
  15967. /**
  15968. * 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)
  15969. * @param uniformName Name of the variable.
  15970. * @param array array to be set.
  15971. * @returns this effect.
  15972. */
  15973. setArray4(uniformName: string, array: number[]): Effect;
  15974. /**
  15975. * Sets matrices on a uniform variable.
  15976. * @param uniformName Name of the variable.
  15977. * @param matrices matrices to be set.
  15978. * @returns this effect.
  15979. */
  15980. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  15981. /**
  15982. * Sets matrix on a uniform variable.
  15983. * @param uniformName Name of the variable.
  15984. * @param matrix matrix to be set.
  15985. * @returns this effect.
  15986. */
  15987. setMatrix(uniformName: string, matrix: Matrix): Effect;
  15988. /**
  15989. * 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)
  15990. * @param uniformName Name of the variable.
  15991. * @param matrix matrix to be set.
  15992. * @returns this effect.
  15993. */
  15994. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  15995. /**
  15996. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  15997. * @param uniformName Name of the variable.
  15998. * @param matrix matrix to be set.
  15999. * @returns this effect.
  16000. */
  16001. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  16002. /**
  16003. * Sets a float on a uniform variable.
  16004. * @param uniformName Name of the variable.
  16005. * @param value value to be set.
  16006. * @returns this effect.
  16007. */
  16008. setFloat(uniformName: string, value: number): Effect;
  16009. /**
  16010. * Sets a boolean on a uniform variable.
  16011. * @param uniformName Name of the variable.
  16012. * @param bool value to be set.
  16013. * @returns this effect.
  16014. */
  16015. setBool(uniformName: string, bool: boolean): Effect;
  16016. /**
  16017. * Sets a Vector2 on a uniform variable.
  16018. * @param uniformName Name of the variable.
  16019. * @param vector2 vector2 to be set.
  16020. * @returns this effect.
  16021. */
  16022. setVector2(uniformName: string, vector2: Vector2): Effect;
  16023. /**
  16024. * Sets a float2 on a uniform variable.
  16025. * @param uniformName Name of the variable.
  16026. * @param x First float in float2.
  16027. * @param y Second float in float2.
  16028. * @returns this effect.
  16029. */
  16030. setFloat2(uniformName: string, x: number, y: number): Effect;
  16031. /**
  16032. * Sets a Vector3 on a uniform variable.
  16033. * @param uniformName Name of the variable.
  16034. * @param vector3 Value to be set.
  16035. * @returns this effect.
  16036. */
  16037. setVector3(uniformName: string, vector3: Vector3): Effect;
  16038. /**
  16039. * Sets a float3 on a uniform variable.
  16040. * @param uniformName Name of the variable.
  16041. * @param x First float in float3.
  16042. * @param y Second float in float3.
  16043. * @param z Third float in float3.
  16044. * @returns this effect.
  16045. */
  16046. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  16047. /**
  16048. * Sets a Vector4 on a uniform variable.
  16049. * @param uniformName Name of the variable.
  16050. * @param vector4 Value to be set.
  16051. * @returns this effect.
  16052. */
  16053. setVector4(uniformName: string, vector4: Vector4): Effect;
  16054. /**
  16055. * Sets a float4 on a uniform variable.
  16056. * @param uniformName Name of the variable.
  16057. * @param x First float in float4.
  16058. * @param y Second float in float4.
  16059. * @param z Third float in float4.
  16060. * @param w Fourth float in float4.
  16061. * @returns this effect.
  16062. */
  16063. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  16064. /**
  16065. * Sets a Color3 on a uniform variable.
  16066. * @param uniformName Name of the variable.
  16067. * @param color3 Value to be set.
  16068. * @returns this effect.
  16069. */
  16070. setColor3(uniformName: string, color3: Color3): Effect;
  16071. /**
  16072. * Sets a Color4 on a uniform variable.
  16073. * @param uniformName Name of the variable.
  16074. * @param color3 Value to be set.
  16075. * @param alpha Alpha value to be set.
  16076. * @returns this effect.
  16077. */
  16078. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  16079. /**
  16080. * Sets a Color4 on a uniform variable
  16081. * @param uniformName defines the name of the variable
  16082. * @param color4 defines the value to be set
  16083. * @returns this effect.
  16084. */
  16085. setDirectColor4(uniformName: string, color4: Color4): Effect;
  16086. /**
  16087. * Store of each shader (The can be looked up using effect.key)
  16088. */
  16089. static ShadersStore: {
  16090. [key: string]: string;
  16091. };
  16092. /**
  16093. * Store of each included file for a shader (The can be looked up using effect.key)
  16094. */
  16095. static IncludesShadersStore: {
  16096. [key: string]: string;
  16097. };
  16098. /**
  16099. * Resets the cache of effects.
  16100. */
  16101. static ResetCache(): void;
  16102. }
  16103. }
  16104. declare module BABYLON {
  16105. class FresnelParameters {
  16106. private _isEnabled;
  16107. isEnabled: boolean;
  16108. leftColor: Color3;
  16109. rightColor: Color3;
  16110. bias: number;
  16111. power: number;
  16112. clone(): FresnelParameters;
  16113. serialize(): any;
  16114. static Parse(parsedFresnelParameters: any): FresnelParameters;
  16115. }
  16116. }
  16117. declare module BABYLON {
  16118. /**
  16119. * Interface to follow in your material defines to integrate easily the
  16120. * Image proccessing functions.
  16121. * @hidden
  16122. */
  16123. interface IImageProcessingConfigurationDefines {
  16124. IMAGEPROCESSING: boolean;
  16125. VIGNETTE: boolean;
  16126. VIGNETTEBLENDMODEMULTIPLY: boolean;
  16127. VIGNETTEBLENDMODEOPAQUE: boolean;
  16128. TONEMAPPING: boolean;
  16129. CONTRAST: boolean;
  16130. EXPOSURE: boolean;
  16131. COLORCURVES: boolean;
  16132. COLORGRADING: boolean;
  16133. COLORGRADING3D: boolean;
  16134. SAMPLER3DGREENDEPTH: boolean;
  16135. SAMPLER3DBGRMAP: boolean;
  16136. IMAGEPROCESSINGPOSTPROCESS: boolean;
  16137. }
  16138. /**
  16139. * This groups together the common properties used for image processing either in direct forward pass
  16140. * or through post processing effect depending on the use of the image processing pipeline in your scene
  16141. * or not.
  16142. */
  16143. class ImageProcessingConfiguration {
  16144. /**
  16145. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  16146. */
  16147. colorCurves: Nullable<ColorCurves>;
  16148. private _colorCurvesEnabled;
  16149. /**
  16150. * Gets wether the color curves effect is enabled.
  16151. */
  16152. /**
  16153. * Sets wether the color curves effect is enabled.
  16154. */
  16155. colorCurvesEnabled: boolean;
  16156. /**
  16157. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  16158. */
  16159. colorGradingTexture: Nullable<BaseTexture>;
  16160. private _colorGradingEnabled;
  16161. /**
  16162. * Gets wether the color grading effect is enabled.
  16163. */
  16164. /**
  16165. * Sets wether the color grading effect is enabled.
  16166. */
  16167. colorGradingEnabled: boolean;
  16168. private _colorGradingWithGreenDepth;
  16169. /**
  16170. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  16171. */
  16172. /**
  16173. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  16174. */
  16175. colorGradingWithGreenDepth: boolean;
  16176. private _colorGradingBGR;
  16177. /**
  16178. * Gets wether the color grading texture contains BGR values.
  16179. */
  16180. /**
  16181. * Sets wether the color grading texture contains BGR values.
  16182. */
  16183. colorGradingBGR: boolean;
  16184. _exposure: number;
  16185. /**
  16186. * Gets the Exposure used in the effect.
  16187. */
  16188. /**
  16189. * Sets the Exposure used in the effect.
  16190. */
  16191. exposure: number;
  16192. private _toneMappingEnabled;
  16193. /**
  16194. * Gets wether the tone mapping effect is enabled.
  16195. */
  16196. /**
  16197. * Sets wether the tone mapping effect is enabled.
  16198. */
  16199. toneMappingEnabled: boolean;
  16200. protected _contrast: number;
  16201. /**
  16202. * Gets the contrast used in the effect.
  16203. */
  16204. /**
  16205. * Sets the contrast used in the effect.
  16206. */
  16207. contrast: number;
  16208. /**
  16209. * Vignette stretch size.
  16210. */
  16211. vignetteStretch: number;
  16212. /**
  16213. * Vignette centre X Offset.
  16214. */
  16215. vignetteCentreX: number;
  16216. /**
  16217. * Vignette centre Y Offset.
  16218. */
  16219. vignetteCentreY: number;
  16220. /**
  16221. * Vignette weight or intensity of the vignette effect.
  16222. */
  16223. vignetteWeight: number;
  16224. /**
  16225. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  16226. * if vignetteEnabled is set to true.
  16227. */
  16228. vignetteColor: Color4;
  16229. /**
  16230. * Camera field of view used by the Vignette effect.
  16231. */
  16232. vignetteCameraFov: number;
  16233. private _vignetteBlendMode;
  16234. /**
  16235. * Gets the vignette blend mode allowing different kind of effect.
  16236. */
  16237. /**
  16238. * Sets the vignette blend mode allowing different kind of effect.
  16239. */
  16240. vignetteBlendMode: number;
  16241. private _vignetteEnabled;
  16242. /**
  16243. * Gets wether the vignette effect is enabled.
  16244. */
  16245. /**
  16246. * Sets wether the vignette effect is enabled.
  16247. */
  16248. vignetteEnabled: boolean;
  16249. private _applyByPostProcess;
  16250. /**
  16251. * Gets wether the image processing is applied through a post process or not.
  16252. */
  16253. /**
  16254. * Sets wether the image processing is applied through a post process or not.
  16255. */
  16256. applyByPostProcess: boolean;
  16257. private _isEnabled;
  16258. /**
  16259. * Gets wether the image processing is enabled or not.
  16260. */
  16261. /**
  16262. * Sets wether the image processing is enabled or not.
  16263. */
  16264. isEnabled: boolean;
  16265. /**
  16266. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  16267. */
  16268. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  16269. /**
  16270. * Method called each time the image processing information changes requires to recompile the effect.
  16271. */
  16272. protected _updateParameters(): void;
  16273. getClassName(): string;
  16274. /**
  16275. * Prepare the list of uniforms associated with the Image Processing effects.
  16276. * @param uniformsList The list of uniforms used in the effect
  16277. * @param defines the list of defines currently in use
  16278. */
  16279. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  16280. /**
  16281. * Prepare the list of samplers associated with the Image Processing effects.
  16282. * @param uniformsList The list of uniforms used in the effect
  16283. * @param defines the list of defines currently in use
  16284. */
  16285. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  16286. /**
  16287. * Prepare the list of defines associated to the shader.
  16288. * @param defines the list of defines to complete
  16289. */
  16290. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  16291. /**
  16292. * Returns true if all the image processing information are ready.
  16293. */
  16294. isReady(): boolean;
  16295. /**
  16296. * Binds the image processing to the shader.
  16297. * @param effect The effect to bind to
  16298. */
  16299. bind(effect: Effect, aspectRatio?: number): void;
  16300. /**
  16301. * Clones the current image processing instance.
  16302. * @return The cloned image processing
  16303. */
  16304. clone(): ImageProcessingConfiguration;
  16305. /**
  16306. * Serializes the current image processing instance to a json representation.
  16307. * @return a JSON representation
  16308. */
  16309. serialize(): any;
  16310. /**
  16311. * Parses the image processing from a json representation.
  16312. * @param source the JSON source to parse
  16313. * @return The parsed image processing
  16314. */
  16315. static Parse(source: any): ImageProcessingConfiguration;
  16316. private static _VIGNETTEMODE_MULTIPLY;
  16317. private static _VIGNETTEMODE_OPAQUE;
  16318. /**
  16319. * Used to apply the vignette as a mix with the pixel color.
  16320. */
  16321. static readonly VIGNETTEMODE_MULTIPLY: number;
  16322. /**
  16323. * Used to apply the vignette as a replacement of the pixel color.
  16324. */
  16325. static readonly VIGNETTEMODE_OPAQUE: number;
  16326. }
  16327. }
  16328. declare module BABYLON {
  16329. /**
  16330. * Manages the defines for the Material
  16331. */
  16332. class MaterialDefines {
  16333. private _keys;
  16334. private _isDirty;
  16335. /** @hidden */
  16336. _renderId: number;
  16337. /** @hidden */
  16338. _areLightsDirty: boolean;
  16339. /** @hidden */
  16340. _areAttributesDirty: boolean;
  16341. /** @hidden */
  16342. _areTexturesDirty: boolean;
  16343. /** @hidden */
  16344. _areFresnelDirty: boolean;
  16345. /** @hidden */
  16346. _areMiscDirty: boolean;
  16347. /** @hidden */
  16348. _areImageProcessingDirty: boolean;
  16349. /** @hidden */
  16350. _normals: boolean;
  16351. /** @hidden */
  16352. _uvs: boolean;
  16353. /** @hidden */
  16354. _needNormals: boolean;
  16355. /** @hidden */
  16356. _needUVs: boolean;
  16357. /**
  16358. * Specifies if the material needs to be re-calculated
  16359. */
  16360. readonly isDirty: boolean;
  16361. /**
  16362. * Marks the material to indicate that it has been re-calculated
  16363. */
  16364. markAsProcessed(): void;
  16365. /**
  16366. * Marks the material to indicate that it needs to be re-calculated
  16367. */
  16368. markAsUnprocessed(): void;
  16369. /**
  16370. * Marks the material to indicate all of its defines need to be re-calculated
  16371. */
  16372. markAllAsDirty(): void;
  16373. /**
  16374. * Marks the material to indicate that image processing needs to be re-calculated
  16375. */
  16376. markAsImageProcessingDirty(): void;
  16377. /**
  16378. * Marks the material to indicate the lights need to be re-calculated
  16379. */
  16380. markAsLightDirty(): void;
  16381. /**
  16382. * Marks the attribute state as changed
  16383. */
  16384. markAsAttributesDirty(): void;
  16385. /**
  16386. * Marks the texture state as changed
  16387. */
  16388. markAsTexturesDirty(): void;
  16389. /**
  16390. * Marks the fresnel state as changed
  16391. */
  16392. markAsFresnelDirty(): void;
  16393. /**
  16394. * Marks the misc state as changed
  16395. */
  16396. markAsMiscDirty(): void;
  16397. /**
  16398. * Rebuilds the material defines
  16399. */
  16400. rebuild(): void;
  16401. /**
  16402. * Specifies if two material defines are equal
  16403. * @param other - A material define instance to compare to
  16404. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  16405. */
  16406. isEqual(other: MaterialDefines): boolean;
  16407. /**
  16408. * Clones this instance's defines to another instance
  16409. * @param other - material defines to clone values to
  16410. */
  16411. cloneTo(other: MaterialDefines): void;
  16412. /**
  16413. * Resets the material define values
  16414. */
  16415. reset(): void;
  16416. /**
  16417. * Converts the material define values to a string
  16418. * @returns - String of material define information
  16419. */
  16420. toString(): string;
  16421. }
  16422. /**
  16423. * Base class for the main features of a material in Babylon.js
  16424. */
  16425. class Material implements IAnimatable {
  16426. private static _TriangleFillMode;
  16427. private static _WireFrameFillMode;
  16428. private static _PointFillMode;
  16429. private static _PointListDrawMode;
  16430. private static _LineListDrawMode;
  16431. private static _LineLoopDrawMode;
  16432. private static _LineStripDrawMode;
  16433. private static _TriangleStripDrawMode;
  16434. private static _TriangleFanDrawMode;
  16435. /**
  16436. * Returns the triangle fill mode
  16437. */
  16438. static readonly TriangleFillMode: number;
  16439. /**
  16440. * Returns the wireframe mode
  16441. */
  16442. static readonly WireFrameFillMode: number;
  16443. /**
  16444. * Returns the point fill mode
  16445. */
  16446. static readonly PointFillMode: number;
  16447. /**
  16448. * Returns the point list draw mode
  16449. */
  16450. static readonly PointListDrawMode: number;
  16451. /**
  16452. * Returns the line list draw mode
  16453. */
  16454. static readonly LineListDrawMode: number;
  16455. /**
  16456. * Returns the line loop draw mode
  16457. */
  16458. static readonly LineLoopDrawMode: number;
  16459. /**
  16460. * Returns the line strip draw mode
  16461. */
  16462. static readonly LineStripDrawMode: number;
  16463. /**
  16464. * Returns the triangle strip draw mode
  16465. */
  16466. static readonly TriangleStripDrawMode: number;
  16467. /**
  16468. * Returns the triangle fan draw mode
  16469. */
  16470. static readonly TriangleFanDrawMode: number;
  16471. /**
  16472. * Stores the clock-wise side orientation
  16473. */
  16474. private static _ClockWiseSideOrientation;
  16475. /**
  16476. * Stores the counter clock-wise side orientation
  16477. */
  16478. private static _CounterClockWiseSideOrientation;
  16479. /**
  16480. * Returns the clock-wise side orientation
  16481. */
  16482. static readonly ClockWiseSideOrientation: number;
  16483. /**
  16484. * Returns the counter clock-wise side orientation
  16485. */
  16486. static readonly CounterClockWiseSideOrientation: number;
  16487. /**
  16488. * The dirty texture flag value
  16489. */
  16490. private static _TextureDirtyFlag;
  16491. /**
  16492. * The dirty light flag value
  16493. */
  16494. private static _LightDirtyFlag;
  16495. /**
  16496. * The dirty fresnel flag value
  16497. */
  16498. private static _FresnelDirtyFlag;
  16499. /**
  16500. * The dirty attribute flag value
  16501. */
  16502. private static _AttributesDirtyFlag;
  16503. /**
  16504. * The dirty misc flag value
  16505. */
  16506. private static _MiscDirtyFlag;
  16507. /**
  16508. * Returns the dirty texture flag value
  16509. */
  16510. static readonly TextureDirtyFlag: number;
  16511. /**
  16512. * Returns the dirty light flag value
  16513. */
  16514. static readonly LightDirtyFlag: number;
  16515. /**
  16516. * Returns the dirty fresnel flag value
  16517. */
  16518. static readonly FresnelDirtyFlag: number;
  16519. /**
  16520. * Returns the dirty attributes flag value
  16521. */
  16522. static readonly AttributesDirtyFlag: number;
  16523. /**
  16524. * Returns the dirty misc flag value
  16525. */
  16526. static readonly MiscDirtyFlag: number;
  16527. /**
  16528. * The ID of the material
  16529. */
  16530. id: string;
  16531. /**
  16532. * The name of the material
  16533. */
  16534. name: string;
  16535. /**
  16536. * Specifies if the ready state should be checked on each call
  16537. */
  16538. checkReadyOnEveryCall: boolean;
  16539. /**
  16540. * Specifies if the ready state should be checked once
  16541. */
  16542. checkReadyOnlyOnce: boolean;
  16543. /**
  16544. * The state of the material
  16545. */
  16546. state: string;
  16547. /**
  16548. * The alpha value of the material
  16549. */
  16550. protected _alpha: number;
  16551. /**
  16552. * Gets the alpha value of the material
  16553. */
  16554. /**
  16555. * Sets the alpha value of the material
  16556. */
  16557. alpha: number;
  16558. /**
  16559. * Specifies if back face culling is enabled
  16560. */
  16561. protected _backFaceCulling: boolean;
  16562. /**
  16563. * Gets the back-face culling state
  16564. */
  16565. /**
  16566. * Sets the back-face culling state
  16567. */
  16568. backFaceCulling: boolean;
  16569. /**
  16570. * Stores the value for side orientation
  16571. */
  16572. sideOrientation: number;
  16573. /**
  16574. * Callback triggered when the material is compiled
  16575. */
  16576. onCompiled: (effect: Effect) => void;
  16577. /**
  16578. * Callback triggered when an error occurs
  16579. */
  16580. onError: (effect: Effect, errors: string) => void;
  16581. /**
  16582. * Callback triggered to get the render target textures
  16583. */
  16584. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  16585. /**
  16586. * Specifies if the material should be serialized
  16587. */
  16588. doNotSerialize: boolean;
  16589. /**
  16590. * Specifies if the effect should be stored on sub meshes
  16591. */
  16592. storeEffectOnSubMeshes: boolean;
  16593. /**
  16594. * Stores the animations for the material
  16595. */
  16596. animations: Array<Animation>;
  16597. /**
  16598. * An event triggered when the material is disposed
  16599. */
  16600. onDisposeObservable: Observable<Material>;
  16601. /**
  16602. * An observer which watches for dispose events
  16603. */
  16604. private _onDisposeObserver;
  16605. /**
  16606. * Called during a dispose event
  16607. */
  16608. onDispose: () => void;
  16609. /**
  16610. * An event triggered when the material is bound
  16611. */
  16612. onBindObservable: Observable<AbstractMesh>;
  16613. /**
  16614. * An observer which watches for bind events
  16615. */
  16616. private _onBindObserver;
  16617. /**
  16618. * Called during a bind event
  16619. */
  16620. onBind: (Mesh: AbstractMesh) => void;
  16621. /**
  16622. * An event triggered when the material is unbound
  16623. */
  16624. onUnBindObservable: Observable<Material>;
  16625. /**
  16626. * Stores the value of the alpha mode
  16627. */
  16628. private _alphaMode;
  16629. /**
  16630. * Gets the value of the alpha mode
  16631. */
  16632. /**
  16633. * Sets the value of the alpha mode.
  16634. *
  16635. * | Value | Type | Description |
  16636. * | --- | --- | --- |
  16637. * | 0 | ALPHA_DISABLE | |
  16638. * | 1 | ALPHA_ADD | |
  16639. * | 2 | ALPHA_COMBINE | |
  16640. * | 3 | ALPHA_SUBTRACT | |
  16641. * | 4 | ALPHA_MULTIPLY | |
  16642. * | 5 | ALPHA_MAXIMIZED | |
  16643. * | 6 | ALPHA_ONEONE | |
  16644. * | 7 | ALPHA_PREMULTIPLIED | |
  16645. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  16646. * | 9 | ALPHA_INTERPOLATE | |
  16647. * | 10 | ALPHA_SCREENMODE | |
  16648. *
  16649. */
  16650. alphaMode: number;
  16651. /**
  16652. * Stores the state of the need depth pre-pass value
  16653. */
  16654. private _needDepthPrePass;
  16655. /**
  16656. * Gets the depth pre-pass value
  16657. */
  16658. /**
  16659. * Sets the need depth pre-pass value
  16660. */
  16661. needDepthPrePass: boolean;
  16662. /**
  16663. * Specifies if depth writing should be disabled
  16664. */
  16665. disableDepthWrite: boolean;
  16666. /**
  16667. * Specifies if depth writing should be forced
  16668. */
  16669. forceDepthWrite: boolean;
  16670. /**
  16671. * Specifies if there should be a separate pass for culling
  16672. */
  16673. separateCullingPass: boolean;
  16674. /**
  16675. * Stores the state specifing if fog should be enabled
  16676. */
  16677. private _fogEnabled;
  16678. /**
  16679. * Gets the value of the fog enabled state
  16680. */
  16681. /**
  16682. * Sets the state for enabling fog
  16683. */
  16684. fogEnabled: boolean;
  16685. /**
  16686. * Stores the size of points
  16687. */
  16688. pointSize: number;
  16689. /**
  16690. * Stores the z offset value
  16691. */
  16692. zOffset: number;
  16693. /**
  16694. * Gets a value specifying if wireframe mode is enabled
  16695. */
  16696. /**
  16697. * Sets the state of wireframe mode
  16698. */
  16699. wireframe: boolean;
  16700. /**
  16701. * Gets the value specifying if point clouds are enabled
  16702. */
  16703. /**
  16704. * Sets the state of point cloud mode
  16705. */
  16706. pointsCloud: boolean;
  16707. /**
  16708. * Gets the material fill mode
  16709. */
  16710. /**
  16711. * Sets the material fill mode
  16712. */
  16713. fillMode: number;
  16714. /**
  16715. * Stores the effects for the material
  16716. */
  16717. _effect: Nullable<Effect>;
  16718. /**
  16719. * Specifies if the material was previously ready
  16720. */
  16721. _wasPreviouslyReady: boolean;
  16722. /**
  16723. * Specifies if uniform buffers should be used
  16724. */
  16725. private _useUBO;
  16726. /**
  16727. * Stores a reference to the scene
  16728. */
  16729. private _scene;
  16730. /**
  16731. * Stores the fill mode state
  16732. */
  16733. private _fillMode;
  16734. /**
  16735. * Specifies if the depth write state should be cached
  16736. */
  16737. private _cachedDepthWriteState;
  16738. /**
  16739. * Stores the uniform buffer
  16740. */
  16741. protected _uniformBuffer: UniformBuffer;
  16742. /**
  16743. * Creates a material instance
  16744. * @param name defines the name of the material
  16745. * @param scene defines the scene to reference
  16746. * @param doNotAdd specifies if the material should be added to the scene
  16747. */
  16748. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  16749. /**
  16750. * Returns a string representation of the current material
  16751. * @param fullDetails defines a boolean indicating which levels of logging is desired
  16752. * @returns a string with material information
  16753. */
  16754. toString(fullDetails?: boolean): string;
  16755. /**
  16756. * Gets the class name of the material
  16757. * @returns a string with the class name of the material
  16758. */
  16759. getClassName(): string;
  16760. /**
  16761. * Specifies if updates for the material been locked
  16762. */
  16763. readonly isFrozen: boolean;
  16764. /**
  16765. * Locks updates for the material
  16766. */
  16767. freeze(): void;
  16768. /**
  16769. * Unlocks updates for the material
  16770. */
  16771. unfreeze(): void;
  16772. /**
  16773. * Specifies if the material is ready to be used
  16774. * @param mesh defines the mesh to check
  16775. * @param useInstances specifies if instances should be used
  16776. * @returns a boolean indicating if the material is ready to be used
  16777. */
  16778. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16779. /**
  16780. * Specifies that the submesh is ready to be used
  16781. * @param mesh defines the mesh to check
  16782. * @param subMesh defines which submesh to check
  16783. * @param useInstances specifies that instances should be used
  16784. * @returns a boolean indicating that the submesh is ready or not
  16785. */
  16786. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16787. /**
  16788. * Returns the material effect
  16789. * @returns the effect associated with the material
  16790. */
  16791. getEffect(): Nullable<Effect>;
  16792. /**
  16793. * Returns the current scene
  16794. * @returns a Scene
  16795. */
  16796. getScene(): Scene;
  16797. /**
  16798. * Specifies if the material will require alpha blending
  16799. * @returns a boolean specifying if alpha blending is needed
  16800. */
  16801. needAlphaBlending(): boolean;
  16802. /**
  16803. * Specifies if the mesh will require alpha blending
  16804. * @param mesh defines the mesh to check
  16805. * @returns a boolean specifying if alpha blending is needed for the mesh
  16806. */
  16807. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  16808. /**
  16809. * Specifies if this material should be rendered in alpha test mode
  16810. * @returns a boolean specifying if an alpha test is needed.
  16811. */
  16812. needAlphaTesting(): boolean;
  16813. /**
  16814. * Gets the texture used for the alpha test
  16815. * @returns the texture to use for alpha testing
  16816. */
  16817. getAlphaTestTexture(): Nullable<BaseTexture>;
  16818. /**
  16819. * Marks the material to indicate that it needs to be re-calculated
  16820. */
  16821. markDirty(): void;
  16822. /** @hidden */
  16823. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  16824. /**
  16825. * Binds the material to the mesh
  16826. * @param world defines the world transformation matrix
  16827. * @param mesh defines the mesh to bind the material to
  16828. */
  16829. bind(world: Matrix, mesh?: Mesh): void;
  16830. /**
  16831. * Binds the submesh to the material
  16832. * @param world defines the world transformation matrix
  16833. * @param mesh defines the mesh containing the submesh
  16834. * @param subMesh defines the submesh to bind the material to
  16835. */
  16836. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16837. /**
  16838. * Binds the world matrix to the material
  16839. * @param world defines the world transformation matrix
  16840. */
  16841. bindOnlyWorldMatrix(world: Matrix): void;
  16842. /**
  16843. * Binds the scene's uniform buffer to the effect.
  16844. * @param effect defines the effect to bind to the scene uniform buffer
  16845. * @param sceneUbo defines the uniform buffer storing scene data
  16846. */
  16847. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  16848. /**
  16849. * Binds the view matrix to the effect
  16850. * @param effect defines the effect to bind the view matrix to
  16851. */
  16852. bindView(effect: Effect): void;
  16853. /**
  16854. * Binds the view projection matrix to the effect
  16855. * @param effect defines the effect to bind the view projection matrix to
  16856. */
  16857. bindViewProjection(effect: Effect): void;
  16858. /**
  16859. * Specifies if material alpha testing should be turned on for the mesh
  16860. * @param mesh defines the mesh to check
  16861. */
  16862. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  16863. /**
  16864. * Processes to execute after binding the material to a mesh
  16865. * @param mesh defines the rendered mesh
  16866. */
  16867. protected _afterBind(mesh?: Mesh): void;
  16868. /**
  16869. * Unbinds the material from the mesh
  16870. */
  16871. unbind(): void;
  16872. /**
  16873. * Gets the active textures from the material
  16874. * @returns an array of textures
  16875. */
  16876. getActiveTextures(): BaseTexture[];
  16877. /**
  16878. * Specifies if the material uses a texture
  16879. * @param texture defines the texture to check against the material
  16880. * @returns a boolean specifying if the material uses the texture
  16881. */
  16882. hasTexture(texture: BaseTexture): boolean;
  16883. /**
  16884. * Makes a duplicate of the material, and gives it a new name
  16885. * @param name defines the new name for the duplicated material
  16886. * @returns the cloned material
  16887. */
  16888. clone(name: string): Nullable<Material>;
  16889. /**
  16890. * Gets the meshes bound to the material
  16891. * @returns an array of meshes bound to the material
  16892. */
  16893. getBindedMeshes(): AbstractMesh[];
  16894. /**
  16895. * Force shader compilation
  16896. * @param mesh defines the mesh associated with this material
  16897. * @param onCompiled defines a function to execute once the material is compiled
  16898. * @param options defines the options to configure the compilation
  16899. */
  16900. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  16901. clipPlane: boolean;
  16902. }>): void;
  16903. /**
  16904. * Force shader compilation
  16905. * @param mesh defines the mesh that will use this material
  16906. * @param options defines additional options for compiling the shaders
  16907. * @returns a promise that resolves when the compilation completes
  16908. */
  16909. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  16910. clipPlane: boolean;
  16911. }>): Promise<void>;
  16912. /**
  16913. * Marks a define in the material to indicate that it needs to be re-computed
  16914. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  16915. */
  16916. markAsDirty(flag: number): void;
  16917. /**
  16918. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  16919. * @param func defines a function which checks material defines against the submeshes
  16920. */
  16921. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  16922. /**
  16923. * Indicates that image processing needs to be re-calculated for all submeshes
  16924. */
  16925. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  16926. /**
  16927. * Indicates that textures need to be re-calculated for all submeshes
  16928. */
  16929. protected _markAllSubMeshesAsTexturesDirty(): void;
  16930. /**
  16931. * Indicates that fresnel needs to be re-calculated for all submeshes
  16932. */
  16933. protected _markAllSubMeshesAsFresnelDirty(): void;
  16934. /**
  16935. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  16936. */
  16937. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  16938. /**
  16939. * Indicates that lights need to be re-calculated for all submeshes
  16940. */
  16941. protected _markAllSubMeshesAsLightsDirty(): void;
  16942. /**
  16943. * Indicates that attributes need to be re-calculated for all submeshes
  16944. */
  16945. protected _markAllSubMeshesAsAttributesDirty(): void;
  16946. /**
  16947. * Indicates that misc needs to be re-calculated for all submeshes
  16948. */
  16949. protected _markAllSubMeshesAsMiscDirty(): void;
  16950. /**
  16951. * Indicates that textures and misc need to be re-calculated for all submeshes
  16952. */
  16953. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  16954. /**
  16955. * Disposes the material
  16956. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16957. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16958. */
  16959. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  16960. /**
  16961. * Serializes this material
  16962. * @returns the serialized material object
  16963. */
  16964. serialize(): any;
  16965. /**
  16966. * Creates a MultiMaterial from parsed MultiMaterial data.
  16967. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  16968. * @param scene defines the hosting scene
  16969. * @returns a new MultiMaterial
  16970. */
  16971. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  16972. /**
  16973. * Creates a material from parsed material data
  16974. * @param parsedMaterial defines parsed material data
  16975. * @param scene defines the hosting scene
  16976. * @param rootUrl defines the root URL to use to load textures
  16977. * @returns a new material
  16978. */
  16979. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  16980. }
  16981. }
  16982. declare module BABYLON {
  16983. /**
  16984. * "Static Class" containing the most commonly used helper while dealing with material for
  16985. * rendering purpose.
  16986. *
  16987. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  16988. *
  16989. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  16990. */
  16991. class MaterialHelper {
  16992. /**
  16993. * Bind the current view position to an effect.
  16994. * @param effect The effect to be bound
  16995. * @param scene The scene the eyes position is used from
  16996. */
  16997. static BindEyePosition(effect: Effect, scene: Scene): void;
  16998. /**
  16999. * Helps preparing the defines values about the UVs in used in the effect.
  17000. * UVs are shared as much as we can accross chanels in the shaders.
  17001. * @param texture The texture we are preparing the UVs for
  17002. * @param defines The defines to update
  17003. * @param key The chanel key "diffuse", "specular"... used in the shader
  17004. */
  17005. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  17006. /**
  17007. * Binds a texture matrix value to its corrsponding uniform
  17008. * @param texture The texture to bind the matrix for
  17009. * @param uniformBuffer The uniform buffer receivin the data
  17010. * @param key The chanel key "diffuse", "specular"... used in the shader
  17011. */
  17012. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  17013. /**
  17014. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  17015. * @param mesh defines the current mesh
  17016. * @param scene defines the current scene
  17017. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  17018. * @param pointsCloud defines if point cloud rendering has to be turned on
  17019. * @param fogEnabled defines if fog has to be turned on
  17020. * @param alphaTest defines if alpha testing has to be turned on
  17021. * @param defines defines the current list of defines
  17022. */
  17023. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  17024. /**
  17025. * Helper used to prepare the list of defines associated with frame values for shader compilation
  17026. * @param scene defines the current scene
  17027. * @param engine defines the current engine
  17028. * @param defines specifies the list of active defines
  17029. * @param useInstances defines if instances have to be turned on
  17030. * @param useClipPlane defines if clip plane have to be turned on
  17031. */
  17032. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  17033. /**
  17034. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  17035. * @param mesh The mesh containing the geometry data we will draw
  17036. * @param defines The defines to update
  17037. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  17038. * @param useBones Precise whether bones should be used or not (override mesh info)
  17039. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  17040. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  17041. * @returns false if defines are considered not dirty and have not been checked
  17042. */
  17043. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  17044. /**
  17045. * Prepares the defines related to the light information passed in parameter
  17046. * @param scene The scene we are intending to draw
  17047. * @param mesh The mesh the effect is compiling for
  17048. * @param defines The defines to update
  17049. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  17050. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  17051. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  17052. * @returns true if normals will be required for the rest of the effect
  17053. */
  17054. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  17055. /**
  17056. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  17057. * that won t be acctive due to defines being turned off.
  17058. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  17059. * @param samplersList The samplers list
  17060. * @param defines The defines helping in the list generation
  17061. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  17062. */
  17063. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  17064. /**
  17065. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  17066. * @param defines The defines to update while falling back
  17067. * @param fallbacks The authorized effect fallbacks
  17068. * @param maxSimultaneousLights The maximum number of lights allowed
  17069. * @param rank the current rank of the Effect
  17070. * @returns The newly affected rank
  17071. */
  17072. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  17073. /**
  17074. * Prepares the list of attributes required for morph targets according to the effect defines.
  17075. * @param attribs The current list of supported attribs
  17076. * @param mesh The mesh to prepare the morph targets attributes for
  17077. * @param defines The current Defines of the effect
  17078. */
  17079. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  17080. /**
  17081. * Prepares the list of attributes required for bones according to the effect defines.
  17082. * @param attribs The current list of supported attribs
  17083. * @param mesh The mesh to prepare the bones attributes for
  17084. * @param defines The current Defines of the effect
  17085. * @param fallbacks The current efffect fallback strategy
  17086. */
  17087. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  17088. /**
  17089. * Prepares the list of attributes required for instances according to the effect defines.
  17090. * @param attribs The current list of supported attribs
  17091. * @param defines The current Defines of the effect
  17092. */
  17093. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  17094. /**
  17095. * Binds the light shadow information to the effect for the given mesh.
  17096. * @param light The light containing the generator
  17097. * @param scene The scene the lights belongs to
  17098. * @param mesh The mesh we are binding the information to render
  17099. * @param lightIndex The light index in the effect used to render the mesh
  17100. * @param effect The effect we are binding the data to
  17101. */
  17102. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  17103. /**
  17104. * Binds the light information to the effect.
  17105. * @param light The light containing the generator
  17106. * @param effect The effect we are binding the data to
  17107. * @param lightIndex The light index in the effect used to render
  17108. */
  17109. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  17110. /**
  17111. * Binds the lights information from the scene to the effect for the given mesh.
  17112. * @param scene The scene the lights belongs to
  17113. * @param mesh The mesh we are binding the information to render
  17114. * @param effect The effect we are binding the data to
  17115. * @param defines The generated defines for the effect
  17116. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  17117. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  17118. */
  17119. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  17120. /**
  17121. * Binds the fog information from the scene to the effect for the given mesh.
  17122. * @param scene The scene the lights belongs to
  17123. * @param mesh The mesh we are binding the information to render
  17124. * @param effect The effect we are binding the data to
  17125. */
  17126. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  17127. /**
  17128. * Binds the bones information from the mesh to the effect.
  17129. * @param mesh The mesh we are binding the information to render
  17130. * @param effect The effect we are binding the data to
  17131. */
  17132. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  17133. /**
  17134. * Binds the morph targets information from the mesh to the effect.
  17135. * @param abstractMesh The mesh we are binding the information to render
  17136. * @param effect The effect we are binding the data to
  17137. */
  17138. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  17139. /**
  17140. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  17141. * @param defines The generated defines used in the effect
  17142. * @param effect The effect we are binding the data to
  17143. * @param scene The scene we are willing to render with logarithmic scale for
  17144. */
  17145. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  17146. /**
  17147. * Binds the clip plane information from the scene to the effect.
  17148. * @param scene The scene the clip plane information are extracted from
  17149. * @param effect The effect we are binding the data to
  17150. */
  17151. static BindClipPlane(effect: Effect, scene: Scene): void;
  17152. }
  17153. }
  17154. declare module BABYLON {
  17155. class MultiMaterial extends Material {
  17156. private _subMaterials;
  17157. subMaterials: Nullable<Material>[];
  17158. constructor(name: string, scene: Scene);
  17159. private _hookArray(array);
  17160. getSubMaterial(index: number): Nullable<Material>;
  17161. getActiveTextures(): BaseTexture[];
  17162. getClassName(): string;
  17163. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17164. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  17165. serialize(): any;
  17166. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17167. }
  17168. }
  17169. declare module BABYLON {
  17170. class PushMaterial extends Material {
  17171. protected _activeEffect: Effect;
  17172. protected _normalMatrix: Matrix;
  17173. constructor(name: string, scene: Scene);
  17174. getEffect(): Effect;
  17175. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17176. /**
  17177. * Binds the given world matrix to the active effect
  17178. *
  17179. * @param world the matrix to bind
  17180. */
  17181. bindOnlyWorldMatrix(world: Matrix): void;
  17182. /**
  17183. * Binds the given normal matrix to the active effect
  17184. *
  17185. * @param normalMatrix the matrix to bind
  17186. */
  17187. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  17188. bind(world: Matrix, mesh?: Mesh): void;
  17189. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  17190. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  17191. }
  17192. }
  17193. declare module BABYLON {
  17194. class ShaderMaterial extends Material {
  17195. private _shaderPath;
  17196. private _options;
  17197. private _textures;
  17198. private _textureArrays;
  17199. private _floats;
  17200. private _ints;
  17201. private _floatsArrays;
  17202. private _colors3;
  17203. private _colors3Arrays;
  17204. private _colors4;
  17205. private _vectors2;
  17206. private _vectors3;
  17207. private _vectors4;
  17208. private _matrices;
  17209. private _matrices3x3;
  17210. private _matrices2x2;
  17211. private _vectors2Arrays;
  17212. private _vectors3Arrays;
  17213. private _cachedWorldViewMatrix;
  17214. private _renderId;
  17215. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  17216. getClassName(): string;
  17217. needAlphaBlending(): boolean;
  17218. needAlphaTesting(): boolean;
  17219. private _checkUniform(uniformName);
  17220. setTexture(name: string, texture: Texture): ShaderMaterial;
  17221. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17222. setFloat(name: string, value: number): ShaderMaterial;
  17223. setInt(name: string, value: number): ShaderMaterial;
  17224. setFloats(name: string, value: number[]): ShaderMaterial;
  17225. setColor3(name: string, value: Color3): ShaderMaterial;
  17226. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17227. setColor4(name: string, value: Color4): ShaderMaterial;
  17228. setVector2(name: string, value: Vector2): ShaderMaterial;
  17229. setVector3(name: string, value: Vector3): ShaderMaterial;
  17230. setVector4(name: string, value: Vector4): ShaderMaterial;
  17231. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17232. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17233. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17234. setArray2(name: string, value: number[]): ShaderMaterial;
  17235. setArray3(name: string, value: number[]): ShaderMaterial;
  17236. private _checkCache(scene, mesh?, useInstances?);
  17237. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17238. bindOnlyWorldMatrix(world: Matrix): void;
  17239. bind(world: Matrix, mesh?: Mesh): void;
  17240. getActiveTextures(): BaseTexture[];
  17241. hasTexture(texture: BaseTexture): boolean;
  17242. clone(name: string): ShaderMaterial;
  17243. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17244. serialize(): any;
  17245. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17246. }
  17247. }
  17248. declare module BABYLON {
  17249. /** @hidden */
  17250. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17251. MAINUV1: boolean;
  17252. MAINUV2: boolean;
  17253. DIFFUSE: boolean;
  17254. DIFFUSEDIRECTUV: number;
  17255. AMBIENT: boolean;
  17256. AMBIENTDIRECTUV: number;
  17257. OPACITY: boolean;
  17258. OPACITYDIRECTUV: number;
  17259. OPACITYRGB: boolean;
  17260. REFLECTION: boolean;
  17261. EMISSIVE: boolean;
  17262. EMISSIVEDIRECTUV: number;
  17263. SPECULAR: boolean;
  17264. SPECULARDIRECTUV: number;
  17265. BUMP: boolean;
  17266. BUMPDIRECTUV: number;
  17267. PARALLAX: boolean;
  17268. PARALLAXOCCLUSION: boolean;
  17269. SPECULAROVERALPHA: boolean;
  17270. CLIPPLANE: boolean;
  17271. ALPHATEST: boolean;
  17272. DEPTHPREPASS: boolean;
  17273. ALPHAFROMDIFFUSE: boolean;
  17274. POINTSIZE: boolean;
  17275. FOG: boolean;
  17276. SPECULARTERM: boolean;
  17277. DIFFUSEFRESNEL: boolean;
  17278. OPACITYFRESNEL: boolean;
  17279. REFLECTIONFRESNEL: boolean;
  17280. REFRACTIONFRESNEL: boolean;
  17281. EMISSIVEFRESNEL: boolean;
  17282. FRESNEL: boolean;
  17283. NORMAL: boolean;
  17284. UV1: boolean;
  17285. UV2: boolean;
  17286. VERTEXCOLOR: boolean;
  17287. VERTEXALPHA: boolean;
  17288. NUM_BONE_INFLUENCERS: number;
  17289. BonesPerMesh: number;
  17290. INSTANCES: boolean;
  17291. GLOSSINESS: boolean;
  17292. ROUGHNESS: boolean;
  17293. EMISSIVEASILLUMINATION: boolean;
  17294. LINKEMISSIVEWITHDIFFUSE: boolean;
  17295. REFLECTIONFRESNELFROMSPECULAR: boolean;
  17296. LIGHTMAP: boolean;
  17297. LIGHTMAPDIRECTUV: number;
  17298. OBJECTSPACE_NORMALMAP: boolean;
  17299. USELIGHTMAPASSHADOWMAP: boolean;
  17300. REFLECTIONMAP_3D: boolean;
  17301. REFLECTIONMAP_SPHERICAL: boolean;
  17302. REFLECTIONMAP_PLANAR: boolean;
  17303. REFLECTIONMAP_CUBIC: boolean;
  17304. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  17305. REFLECTIONMAP_PROJECTION: boolean;
  17306. REFLECTIONMAP_SKYBOX: boolean;
  17307. REFLECTIONMAP_EXPLICIT: boolean;
  17308. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  17309. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  17310. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  17311. INVERTCUBICMAP: boolean;
  17312. LOGARITHMICDEPTH: boolean;
  17313. REFRACTION: boolean;
  17314. REFRACTIONMAP_3D: boolean;
  17315. REFLECTIONOVERALPHA: boolean;
  17316. TWOSIDEDLIGHTING: boolean;
  17317. SHADOWFLOAT: boolean;
  17318. MORPHTARGETS: boolean;
  17319. MORPHTARGETS_NORMAL: boolean;
  17320. MORPHTARGETS_TANGENT: boolean;
  17321. NUM_MORPH_INFLUENCERS: number;
  17322. NONUNIFORMSCALING: boolean;
  17323. PREMULTIPLYALPHA: boolean;
  17324. IMAGEPROCESSING: boolean;
  17325. VIGNETTE: boolean;
  17326. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17327. VIGNETTEBLENDMODEOPAQUE: boolean;
  17328. TONEMAPPING: boolean;
  17329. CONTRAST: boolean;
  17330. COLORCURVES: boolean;
  17331. COLORGRADING: boolean;
  17332. COLORGRADING3D: boolean;
  17333. SAMPLER3DGREENDEPTH: boolean;
  17334. SAMPLER3DBGRMAP: boolean;
  17335. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17336. /**
  17337. * If the reflection texture on this material is in linear color space
  17338. * @hidden
  17339. */
  17340. IS_REFLECTION_LINEAR: boolean;
  17341. /**
  17342. * If the refraction texture on this material is in linear color space
  17343. * @hidden
  17344. */
  17345. IS_REFRACTION_LINEAR: boolean;
  17346. EXPOSURE: boolean;
  17347. constructor();
  17348. setReflectionMode(modeToEnable: string): void;
  17349. }
  17350. class StandardMaterial extends PushMaterial {
  17351. private _diffuseTexture;
  17352. diffuseTexture: Nullable<BaseTexture>;
  17353. private _ambientTexture;
  17354. ambientTexture: Nullable<BaseTexture>;
  17355. private _opacityTexture;
  17356. opacityTexture: Nullable<BaseTexture>;
  17357. private _reflectionTexture;
  17358. reflectionTexture: Nullable<BaseTexture>;
  17359. private _emissiveTexture;
  17360. emissiveTexture: Nullable<BaseTexture>;
  17361. private _specularTexture;
  17362. specularTexture: Nullable<BaseTexture>;
  17363. private _bumpTexture;
  17364. bumpTexture: Nullable<BaseTexture>;
  17365. private _lightmapTexture;
  17366. lightmapTexture: Nullable<BaseTexture>;
  17367. private _refractionTexture;
  17368. refractionTexture: Nullable<BaseTexture>;
  17369. ambientColor: Color3;
  17370. diffuseColor: Color3;
  17371. specularColor: Color3;
  17372. emissiveColor: Color3;
  17373. specularPower: number;
  17374. private _useAlphaFromDiffuseTexture;
  17375. useAlphaFromDiffuseTexture: boolean;
  17376. private _useEmissiveAsIllumination;
  17377. useEmissiveAsIllumination: boolean;
  17378. private _linkEmissiveWithDiffuse;
  17379. linkEmissiveWithDiffuse: boolean;
  17380. private _useSpecularOverAlpha;
  17381. useSpecularOverAlpha: boolean;
  17382. private _useReflectionOverAlpha;
  17383. useReflectionOverAlpha: boolean;
  17384. private _disableLighting;
  17385. disableLighting: boolean;
  17386. private _useObjectSpaceNormalMap;
  17387. /**
  17388. * Allows using an object space normal map (instead of tangent space).
  17389. */
  17390. useObjectSpaceNormalMap: boolean;
  17391. private _useParallax;
  17392. useParallax: boolean;
  17393. private _useParallaxOcclusion;
  17394. useParallaxOcclusion: boolean;
  17395. parallaxScaleBias: number;
  17396. private _roughness;
  17397. roughness: number;
  17398. indexOfRefraction: number;
  17399. invertRefractionY: boolean;
  17400. /**
  17401. * Defines the alpha limits in alpha test mode
  17402. */
  17403. alphaCutOff: number;
  17404. private _useLightmapAsShadowmap;
  17405. useLightmapAsShadowmap: boolean;
  17406. private _diffuseFresnelParameters;
  17407. diffuseFresnelParameters: FresnelParameters;
  17408. private _opacityFresnelParameters;
  17409. opacityFresnelParameters: FresnelParameters;
  17410. private _reflectionFresnelParameters;
  17411. reflectionFresnelParameters: FresnelParameters;
  17412. private _refractionFresnelParameters;
  17413. refractionFresnelParameters: FresnelParameters;
  17414. private _emissiveFresnelParameters;
  17415. emissiveFresnelParameters: FresnelParameters;
  17416. private _useReflectionFresnelFromSpecular;
  17417. useReflectionFresnelFromSpecular: boolean;
  17418. private _useGlossinessFromSpecularMapAlpha;
  17419. useGlossinessFromSpecularMapAlpha: boolean;
  17420. private _maxSimultaneousLights;
  17421. maxSimultaneousLights: number;
  17422. /**
  17423. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  17424. */
  17425. private _invertNormalMapX;
  17426. invertNormalMapX: boolean;
  17427. /**
  17428. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  17429. */
  17430. private _invertNormalMapY;
  17431. invertNormalMapY: boolean;
  17432. /**
  17433. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  17434. */
  17435. private _twoSidedLighting;
  17436. twoSidedLighting: boolean;
  17437. /**
  17438. * Default configuration related to image processing available in the standard Material.
  17439. */
  17440. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17441. /**
  17442. * Gets the image processing configuration used either in this material.
  17443. */
  17444. /**
  17445. * Sets the Default image processing configuration used either in the this material.
  17446. *
  17447. * If sets to null, the scene one is in use.
  17448. */
  17449. imageProcessingConfiguration: ImageProcessingConfiguration;
  17450. /**
  17451. * Keep track of the image processing observer to allow dispose and replace.
  17452. */
  17453. private _imageProcessingObserver;
  17454. /**
  17455. * Attaches a new image processing configuration to the Standard Material.
  17456. * @param configuration
  17457. */
  17458. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17459. /**
  17460. * Gets wether the color curves effect is enabled.
  17461. */
  17462. /**
  17463. * Sets wether the color curves effect is enabled.
  17464. */
  17465. cameraColorCurvesEnabled: boolean;
  17466. /**
  17467. * Gets wether the color grading effect is enabled.
  17468. */
  17469. /**
  17470. * Gets wether the color grading effect is enabled.
  17471. */
  17472. cameraColorGradingEnabled: boolean;
  17473. /**
  17474. * Gets wether tonemapping is enabled or not.
  17475. */
  17476. /**
  17477. * Sets wether tonemapping is enabled or not
  17478. */
  17479. cameraToneMappingEnabled: boolean;
  17480. /**
  17481. * The camera exposure used on this material.
  17482. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  17483. * This corresponds to a photographic exposure.
  17484. */
  17485. /**
  17486. * The camera exposure used on this material.
  17487. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  17488. * This corresponds to a photographic exposure.
  17489. */
  17490. cameraExposure: number;
  17491. /**
  17492. * Gets The camera contrast used on this material.
  17493. */
  17494. /**
  17495. * Sets The camera contrast used on this material.
  17496. */
  17497. cameraContrast: number;
  17498. /**
  17499. * Gets the Color Grading 2D Lookup Texture.
  17500. */
  17501. /**
  17502. * Sets the Color Grading 2D Lookup Texture.
  17503. */
  17504. cameraColorGradingTexture: Nullable<BaseTexture>;
  17505. /**
  17506. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  17507. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  17508. * 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;
  17509. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  17510. */
  17511. /**
  17512. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  17513. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  17514. * 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;
  17515. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  17516. */
  17517. cameraColorCurves: Nullable<ColorCurves>;
  17518. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  17519. protected _renderTargets: SmartArray<RenderTargetTexture>;
  17520. protected _worldViewProjectionMatrix: Matrix;
  17521. protected _globalAmbientColor: Color3;
  17522. protected _useLogarithmicDepth: boolean;
  17523. constructor(name: string, scene: Scene);
  17524. getClassName(): string;
  17525. useLogarithmicDepth: boolean;
  17526. needAlphaBlending(): boolean;
  17527. needAlphaTesting(): boolean;
  17528. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  17529. getAlphaTestTexture(): Nullable<BaseTexture>;
  17530. /**
  17531. * Child classes can use it to update shaders
  17532. */
  17533. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17534. buildUniformLayout(): void;
  17535. unbind(): void;
  17536. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17537. getAnimatables(): IAnimatable[];
  17538. getActiveTextures(): BaseTexture[];
  17539. hasTexture(texture: BaseTexture): boolean;
  17540. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17541. clone(name: string): StandardMaterial;
  17542. serialize(): any;
  17543. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  17544. static _DiffuseTextureEnabled: boolean;
  17545. static DiffuseTextureEnabled: boolean;
  17546. static _AmbientTextureEnabled: boolean;
  17547. static AmbientTextureEnabled: boolean;
  17548. static _OpacityTextureEnabled: boolean;
  17549. static OpacityTextureEnabled: boolean;
  17550. static _ReflectionTextureEnabled: boolean;
  17551. static ReflectionTextureEnabled: boolean;
  17552. static _EmissiveTextureEnabled: boolean;
  17553. static EmissiveTextureEnabled: boolean;
  17554. static _SpecularTextureEnabled: boolean;
  17555. static SpecularTextureEnabled: boolean;
  17556. static _BumpTextureEnabled: boolean;
  17557. static BumpTextureEnabled: boolean;
  17558. static _LightmapTextureEnabled: boolean;
  17559. static LightmapTextureEnabled: boolean;
  17560. static _RefractionTextureEnabled: boolean;
  17561. static RefractionTextureEnabled: boolean;
  17562. static _ColorGradingTextureEnabled: boolean;
  17563. static ColorGradingTextureEnabled: boolean;
  17564. static _FresnelEnabled: boolean;
  17565. static FresnelEnabled: boolean;
  17566. }
  17567. }
  17568. declare module BABYLON {
  17569. class UniformBuffer {
  17570. private _engine;
  17571. private _buffer;
  17572. private _data;
  17573. private _bufferData;
  17574. private _dynamic?;
  17575. private _uniformLocations;
  17576. private _uniformSizes;
  17577. private _uniformLocationPointer;
  17578. private _needSync;
  17579. private _noUBO;
  17580. private _currentEffect;
  17581. private static _MAX_UNIFORM_SIZE;
  17582. private static _tempBuffer;
  17583. /**
  17584. * Wrapper for updateUniform.
  17585. * @method updateMatrix3x3
  17586. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17587. * @param {Float32Array} matrix
  17588. */
  17589. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  17590. /**
  17591. * Wrapper for updateUniform.
  17592. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17593. * @param {Float32Array} matrix
  17594. */
  17595. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  17596. /**
  17597. * Wrapper for updateUniform.
  17598. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17599. * @param {number} x
  17600. */
  17601. updateFloat: (name: string, x: number) => void;
  17602. /**
  17603. * Wrapper for updateUniform.
  17604. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17605. * @param {number} x
  17606. * @param {number} y
  17607. * @param {string} [suffix] Suffix to add to the uniform name.
  17608. */
  17609. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  17610. /**
  17611. * Wrapper for updateUniform.
  17612. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17613. * @param {number} x
  17614. * @param {number} y
  17615. * @param {number} z
  17616. * @param {string} [suffix] Suffix to add to the uniform name.
  17617. */
  17618. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  17619. /**
  17620. * Wrapper for updateUniform.
  17621. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17622. * @param {number} x
  17623. * @param {number} y
  17624. * @param {number} z
  17625. * @param {number} w
  17626. * @param {string} [suffix] Suffix to add to the uniform name.
  17627. */
  17628. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  17629. /**
  17630. * Wrapper for updateUniform.
  17631. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17632. * @param {Matrix} A 4x4 matrix.
  17633. */
  17634. updateMatrix: (name: string, mat: Matrix) => void;
  17635. /**
  17636. * Wrapper for updateUniform.
  17637. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17638. * @param {Vector3} vector
  17639. */
  17640. updateVector3: (name: string, vector: Vector3) => void;
  17641. /**
  17642. * Wrapper for updateUniform.
  17643. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17644. * @param {Vector4} vector
  17645. */
  17646. updateVector4: (name: string, vector: Vector4) => void;
  17647. /**
  17648. * Wrapper for updateUniform.
  17649. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17650. * @param {Color3} color
  17651. * @param {string} [suffix] Suffix to add to the uniform name.
  17652. */
  17653. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  17654. /**
  17655. * Wrapper for updateUniform.
  17656. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17657. * @param {Color3} color
  17658. * @param {number} alpha
  17659. * @param {string} [suffix] Suffix to add to the uniform name.
  17660. */
  17661. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  17662. /**
  17663. * Uniform buffer objects.
  17664. *
  17665. * Handles blocks of uniform on the GPU.
  17666. *
  17667. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  17668. *
  17669. * For more information, please refer to :
  17670. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  17671. */
  17672. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  17673. /**
  17674. * Indicates if the buffer is using the WebGL2 UBO implementation,
  17675. * or just falling back on setUniformXXX calls.
  17676. */
  17677. readonly useUbo: boolean;
  17678. /**
  17679. * Indicates if the WebGL underlying uniform buffer is in sync
  17680. * with the javascript cache data.
  17681. */
  17682. readonly isSync: boolean;
  17683. /**
  17684. * Indicates if the WebGL underlying uniform buffer is dynamic.
  17685. * Also, a dynamic UniformBuffer will disable cache verification and always
  17686. * update the underlying WebGL uniform buffer to the GPU.
  17687. */
  17688. isDynamic(): boolean;
  17689. /**
  17690. * The data cache on JS side.
  17691. */
  17692. getData(): Float32Array;
  17693. /**
  17694. * The underlying WebGL Uniform buffer.
  17695. */
  17696. getBuffer(): Nullable<WebGLBuffer>;
  17697. /**
  17698. * std140 layout specifies how to align data within an UBO structure.
  17699. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  17700. * for specs.
  17701. */
  17702. private _fillAlignment(size);
  17703. /**
  17704. * Adds an uniform in the buffer.
  17705. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  17706. * for the layout to be correct !
  17707. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17708. * @param {number|number[]} size Data size, or data directly.
  17709. */
  17710. addUniform(name: string, size: number | number[]): void;
  17711. /**
  17712. * Wrapper for addUniform.
  17713. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17714. * @param {Matrix} mat A 4x4 matrix.
  17715. */
  17716. addMatrix(name: string, mat: Matrix): void;
  17717. /**
  17718. * Wrapper for addUniform.
  17719. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17720. * @param {number} x
  17721. * @param {number} y
  17722. */
  17723. addFloat2(name: string, x: number, y: number): void;
  17724. /**
  17725. * Wrapper for addUniform.
  17726. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17727. * @param {number} x
  17728. * @param {number} y
  17729. * @param {number} z
  17730. */
  17731. addFloat3(name: string, x: number, y: number, z: number): void;
  17732. /**
  17733. * Wrapper for addUniform.
  17734. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17735. * @param {Color3} color
  17736. */
  17737. addColor3(name: string, color: Color3): void;
  17738. /**
  17739. * Wrapper for addUniform.
  17740. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17741. * @param {Color3} color
  17742. * @param {number} alpha
  17743. */
  17744. addColor4(name: string, color: Color3, alpha: number): void;
  17745. /**
  17746. * Wrapper for addUniform.
  17747. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17748. * @param {Vector3} vector
  17749. */
  17750. addVector3(name: string, vector: Vector3): void;
  17751. /**
  17752. * Wrapper for addUniform.
  17753. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17754. */
  17755. addMatrix3x3(name: string): void;
  17756. /**
  17757. * Wrapper for addUniform.
  17758. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  17759. */
  17760. addMatrix2x2(name: string): void;
  17761. /**
  17762. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  17763. */
  17764. create(): void;
  17765. _rebuild(): void;
  17766. /**
  17767. * Updates the WebGL Uniform Buffer on the GPU.
  17768. * If the `dynamic` flag is set to true, no cache comparison is done.
  17769. * Otherwise, the buffer will be updated only if the cache differs.
  17770. */
  17771. update(): void;
  17772. /**
  17773. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  17774. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  17775. * @param {number[]|Float32Array} data Flattened data
  17776. * @param {number} size Size of the data.
  17777. */
  17778. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  17779. private _updateMatrix3x3ForUniform(name, matrix);
  17780. private _updateMatrix3x3ForEffect(name, matrix);
  17781. private _updateMatrix2x2ForEffect(name, matrix);
  17782. private _updateMatrix2x2ForUniform(name, matrix);
  17783. private _updateFloatForEffect(name, x);
  17784. private _updateFloatForUniform(name, x);
  17785. private _updateFloat2ForEffect(name, x, y, suffix?);
  17786. private _updateFloat2ForUniform(name, x, y, suffix?);
  17787. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  17788. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  17789. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  17790. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  17791. private _updateMatrixForEffect(name, mat);
  17792. private _updateMatrixForUniform(name, mat);
  17793. private _updateVector3ForEffect(name, vector);
  17794. private _updateVector3ForUniform(name, vector);
  17795. private _updateVector4ForEffect(name, vector);
  17796. private _updateVector4ForUniform(name, vector);
  17797. private _updateColor3ForEffect(name, color, suffix?);
  17798. private _updateColor3ForUniform(name, color, suffix?);
  17799. private _updateColor4ForEffect(name, color, alpha, suffix?);
  17800. private _updateColor4ForUniform(name, color, alpha, suffix?);
  17801. /**
  17802. * Sets a sampler uniform on the effect.
  17803. * @param {string} name Name of the sampler.
  17804. * @param {Texture} texture
  17805. */
  17806. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  17807. /**
  17808. * Directly updates the value of the uniform in the cache AND on the GPU.
  17809. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  17810. * @param {number[]|Float32Array} data Flattened data
  17811. */
  17812. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  17813. /**
  17814. * Binds this uniform buffer to an effect.
  17815. * @param {Effect} effect
  17816. * @param {string} name Name of the uniform block in the shader.
  17817. */
  17818. bindToEffect(effect: Effect, name: string): void;
  17819. /**
  17820. * Disposes the uniform buffer.
  17821. */
  17822. dispose(): void;
  17823. }
  17824. }
  17825. declare module BABYLON {
  17826. /**
  17827. * Class used to store all common mesh properties
  17828. */
  17829. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  17830. /** No occlusion */
  17831. static OCCLUSION_TYPE_NONE: number;
  17832. /** Occlusion set to optimisitic */
  17833. static OCCLUSION_TYPE_OPTIMISTIC: number;
  17834. /** Occlusion set to strict */
  17835. static OCCLUSION_TYPE_STRICT: number;
  17836. /** Use an accurante occlusion algorithm */
  17837. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  17838. /** Use a conservative occlusion algorithm */
  17839. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  17840. /**
  17841. * No billboard
  17842. */
  17843. static readonly BILLBOARDMODE_NONE: number;
  17844. /** Billboard on X axis */
  17845. static readonly BILLBOARDMODE_X: number;
  17846. /** Billboard on Y axis */
  17847. static readonly BILLBOARDMODE_Y: number;
  17848. /** Billboard on Z axis */
  17849. static readonly BILLBOARDMODE_Z: number;
  17850. /** Billboard on all axes */
  17851. static readonly BILLBOARDMODE_ALL: number;
  17852. private _facetPositions;
  17853. private _facetNormals;
  17854. private _facetPartitioning;
  17855. private _facetNb;
  17856. private _partitioningSubdivisions;
  17857. private _partitioningBBoxRatio;
  17858. private _facetDataEnabled;
  17859. private _facetParameters;
  17860. private _bbSize;
  17861. private _subDiv;
  17862. private _facetDepthSort;
  17863. private _facetDepthSortEnabled;
  17864. private _depthSortedIndices;
  17865. private _depthSortedFacets;
  17866. private _facetDepthSortFunction;
  17867. private _facetDepthSortFrom;
  17868. private _facetDepthSortOrigin;
  17869. private _invertedMatrix;
  17870. /**
  17871. * Gets the number of facets in the mesh
  17872. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  17873. */
  17874. readonly facetNb: number;
  17875. /**
  17876. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  17877. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  17878. */
  17879. partitioningSubdivisions: number;
  17880. /**
  17881. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  17882. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  17883. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  17884. */
  17885. partitioningBBoxRatio: number;
  17886. /**
  17887. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  17888. * Works only for updatable meshes.
  17889. * Doesn't work with multi-materials
  17890. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  17891. */
  17892. mustDepthSortFacets: boolean;
  17893. /**
  17894. * The location (Vector3) where the facet depth sort must be computed from.
  17895. * By default, the active camera position.
  17896. * Used only when facet depth sort is enabled
  17897. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  17898. */
  17899. facetDepthSortFrom: Vector3;
  17900. /**
  17901. * gets a boolean indicating if facetData is enabled
  17902. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  17903. */
  17904. readonly isFacetDataEnabled: boolean;
  17905. /** @hidden */
  17906. _updateNonUniformScalingState(value: boolean): boolean;
  17907. /**
  17908. * An event triggered when this mesh collides with another one
  17909. */
  17910. onCollideObservable: Observable<AbstractMesh>;
  17911. private _onCollideObserver;
  17912. /** Set a function to call when this mesh collides with another one */
  17913. onCollide: () => void;
  17914. /**
  17915. * An event triggered when the collision's position changes
  17916. */
  17917. onCollisionPositionChangeObservable: Observable<Vector3>;
  17918. private _onCollisionPositionChangeObserver;
  17919. /** Set a function to call when the collision's position changes */
  17920. onCollisionPositionChange: () => void;
  17921. /**
  17922. * An event triggered when material is changed
  17923. */
  17924. onMaterialChangedObservable: Observable<AbstractMesh>;
  17925. /**
  17926. * Gets or sets the orientation for POV movement & rotation
  17927. */
  17928. definedFacingForward: boolean;
  17929. /**
  17930. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  17931. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  17932. * * 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.
  17933. * @see http://doc.babylonjs.com/features/occlusionquery
  17934. */
  17935. occlusionQueryAlgorithmType: number;
  17936. /**
  17937. * 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:
  17938. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  17939. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  17940. * * 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.
  17941. * @see http://doc.babylonjs.com/features/occlusionquery
  17942. */
  17943. occlusionType: number;
  17944. /**
  17945. * 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.
  17946. * The default value is -1 which means don't break the query and wait till the result
  17947. * @see http://doc.babylonjs.com/features/occlusionquery
  17948. */
  17949. occlusionRetryCount: number;
  17950. private _occlusionInternalRetryCounter;
  17951. protected _isOccluded: boolean;
  17952. /**
  17953. * 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
  17954. * @see http://doc.babylonjs.com/features/occlusionquery
  17955. */
  17956. isOccluded: boolean;
  17957. private _isOcclusionQueryInProgress;
  17958. /**
  17959. * Flag to check the progress status of the query
  17960. * @see http://doc.babylonjs.com/features/occlusionquery
  17961. */
  17962. readonly isOcclusionQueryInProgress: boolean;
  17963. private _occlusionQuery;
  17964. private _visibility;
  17965. /**
  17966. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  17967. */
  17968. /**
  17969. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  17970. */
  17971. visibility: number;
  17972. /** Gets or sets the alpha index used to sort transparent meshes
  17973. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  17974. */
  17975. alphaIndex: number;
  17976. /**
  17977. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  17978. */
  17979. isVisible: boolean;
  17980. /**
  17981. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  17982. */
  17983. isPickable: boolean;
  17984. /**
  17985. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  17986. */
  17987. showBoundingBox: boolean;
  17988. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  17989. showSubMeshesBoundingBox: boolean;
  17990. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  17991. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  17992. */
  17993. isBlocker: boolean;
  17994. /**
  17995. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  17996. */
  17997. enablePointerMoveEvents: boolean;
  17998. /**
  17999. * Specifies the rendering group id for this mesh (0 by default)
  18000. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  18001. */
  18002. renderingGroupId: number;
  18003. private _material;
  18004. /** Gets or sets current material */
  18005. material: Nullable<Material>;
  18006. private _receiveShadows;
  18007. /**
  18008. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  18009. * @see http://doc.babylonjs.com/babylon101/shadows
  18010. */
  18011. receiveShadows: boolean;
  18012. /**
  18013. * Gets or sets a boolean indicating if the outline must be rendered as well
  18014. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  18015. */
  18016. renderOutline: boolean;
  18017. /** Defines color to use when rendering outline */
  18018. outlineColor: Color3;
  18019. /** Define width to use when rendering outline */
  18020. outlineWidth: number;
  18021. /**
  18022. * Gets or sets a boolean indicating if the overlay must be rendered as well
  18023. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  18024. */
  18025. renderOverlay: boolean;
  18026. /** Defines color to use when rendering overlay */
  18027. overlayColor: Color3;
  18028. /** Defines alpha to use when rendering overlay */
  18029. overlayAlpha: number;
  18030. private _hasVertexAlpha;
  18031. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  18032. hasVertexAlpha: boolean;
  18033. private _useVertexColors;
  18034. /** 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) */
  18035. useVertexColors: boolean;
  18036. private _computeBonesUsingShaders;
  18037. /**
  18038. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  18039. */
  18040. computeBonesUsingShaders: boolean;
  18041. private _numBoneInfluencers;
  18042. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  18043. numBoneInfluencers: number;
  18044. private _applyFog;
  18045. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  18046. applyFog: boolean;
  18047. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  18048. useOctreeForRenderingSelection: boolean;
  18049. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  18050. useOctreeForPicking: boolean;
  18051. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  18052. useOctreeForCollisions: boolean;
  18053. private _layerMask;
  18054. /**
  18055. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  18056. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  18057. */
  18058. layerMask: number;
  18059. /**
  18060. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  18061. */
  18062. alwaysSelectAsActiveMesh: boolean;
  18063. /**
  18064. * Gets or sets the current action manager
  18065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18066. */
  18067. actionManager: Nullable<ActionManager>;
  18068. /**
  18069. * Gets or sets impostor used for physic simulation
  18070. * @see http://doc.babylonjs.com/features/physics_engine
  18071. */
  18072. physicsImpostor: Nullable<PhysicsImpostor>;
  18073. private _checkCollisions;
  18074. private _collisionMask;
  18075. private _collisionGroup;
  18076. /**
  18077. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  18078. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18079. */
  18080. ellipsoid: Vector3;
  18081. /**
  18082. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  18083. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18084. */
  18085. ellipsoidOffset: Vector3;
  18086. private _collider;
  18087. private _oldPositionForCollisions;
  18088. private _diffPositionForCollisions;
  18089. /**
  18090. * Gets or sets a collision mask used to mask collisions (default is -1).
  18091. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  18092. */
  18093. collisionMask: number;
  18094. /**
  18095. * Gets or sets the current collision group mask (-1 by default).
  18096. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  18097. */
  18098. collisionGroup: number;
  18099. /**
  18100. * Defines edge width used when edgesRenderer is enabled
  18101. * @see https://www.babylonjs-playground.com/#10OJSG#13
  18102. */
  18103. edgesWidth: number;
  18104. /**
  18105. * Defines edge color used when edgesRenderer is enabled
  18106. * @see https://www.babylonjs-playground.com/#10OJSG#13
  18107. */
  18108. edgesColor: Color4;
  18109. /** @hidden */
  18110. _edgesRenderer: Nullable<EdgesRenderer>;
  18111. private _collisionsTransformMatrix;
  18112. private _collisionsScalingMatrix;
  18113. /** @hidden */
  18114. _masterMesh: Nullable<AbstractMesh>;
  18115. /** @hidden */
  18116. _boundingInfo: Nullable<BoundingInfo>;
  18117. /** @hidden */
  18118. _renderId: number;
  18119. /**
  18120. * Gets or sets the list of subMeshes
  18121. * @see http://doc.babylonjs.com/how_to/multi_materials
  18122. */
  18123. subMeshes: SubMesh[];
  18124. /** @hidden */
  18125. _submeshesOctree: Octree<SubMesh>;
  18126. /** @hidden */
  18127. _intersectionsInProgress: AbstractMesh[];
  18128. /** @hidden */
  18129. _unIndexed: boolean;
  18130. /** @hidden */
  18131. _lightSources: Light[];
  18132. /** @hidden */
  18133. readonly _positions: Nullable<Vector3[]>;
  18134. /** @hidden */
  18135. _waitingActions: any;
  18136. /** @hidden */
  18137. _waitingFreezeWorldMatrix: Nullable<boolean>;
  18138. private _skeleton;
  18139. /** @hidden */
  18140. _bonesTransformMatrices: Nullable<Float32Array>;
  18141. /**
  18142. * Gets or sets a skeleton to apply skining transformations
  18143. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18144. */
  18145. skeleton: Nullable<Skeleton>;
  18146. /**
  18147. * Creates a new AbstractMesh
  18148. * @param name defines the name of the mesh
  18149. * @param scene defines the hosting scene
  18150. */
  18151. constructor(name: string, scene?: Nullable<Scene>);
  18152. /**
  18153. * Returns the string "AbstractMesh"
  18154. * @returns "AbstractMesh"
  18155. */
  18156. getClassName(): string;
  18157. /**
  18158. * Gets a string representation of the current mesh
  18159. * @param fullDetails defines a boolean indicating if full details must be included
  18160. * @returns a string representation of the current mesh
  18161. */
  18162. toString(fullDetails?: boolean): string;
  18163. /** @hidden */
  18164. _rebuild(): void;
  18165. /** @hidden */
  18166. _resyncLightSources(): void;
  18167. /** @hidden */
  18168. _resyncLighSource(light: Light): void;
  18169. /** @hidden */
  18170. _unBindEffect(): void;
  18171. /** @hidden */
  18172. _removeLightSource(light: Light): void;
  18173. private _markSubMeshesAsDirty(func);
  18174. /** @hidden */
  18175. _markSubMeshesAsLightDirty(): void;
  18176. /** @hidden */
  18177. _markSubMeshesAsAttributesDirty(): void;
  18178. /** @hidden */
  18179. _markSubMeshesAsMiscDirty(): void;
  18180. /**
  18181. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  18182. */
  18183. scaling: Vector3;
  18184. /**
  18185. * Disables the mesh edge rendering mode
  18186. * @returns the currentAbstractMesh
  18187. */
  18188. disableEdgesRendering(): AbstractMesh;
  18189. /**
  18190. * Enables the edge rendering mode on the mesh.
  18191. * This mode makes the mesh edges visible
  18192. * @param epsilon defines the maximal distance between two angles to detect a face
  18193. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  18194. * @returns the currentAbstractMesh
  18195. * @see https://www.babylonjs-playground.com/#19O9TU#0
  18196. */
  18197. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  18198. /**
  18199. * Returns true if the mesh is blocked. Implemented by child classes
  18200. */
  18201. readonly isBlocked: boolean;
  18202. /**
  18203. * Returns the mesh itself by default. Implemented by child classes
  18204. * @param camera defines the camera to use to pick the right LOD level
  18205. * @returns the currentAbstractMesh
  18206. */
  18207. getLOD(camera: Camera): AbstractMesh;
  18208. /**
  18209. * Returns 0 by default. Implemented by child classes
  18210. * @returns an integer
  18211. */
  18212. getTotalVertices(): number;
  18213. /**
  18214. * Returns null by default. Implemented by child classes
  18215. * @returns null
  18216. */
  18217. getIndices(): Nullable<IndicesArray>;
  18218. /**
  18219. * Returns the array of the requested vertex data kind. Implemented by child classes
  18220. * @param kind defines the vertex data kind to use
  18221. * @returns null
  18222. */
  18223. getVerticesData(kind: string): Nullable<FloatArray>;
  18224. /**
  18225. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18226. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18227. * Note that a new underlying VertexBuffer object is created each call.
  18228. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18229. * @param kind defines vertex data kind:
  18230. * * BABYLON.VertexBuffer.PositionKind
  18231. * * BABYLON.VertexBuffer.UVKind
  18232. * * BABYLON.VertexBuffer.UV2Kind
  18233. * * BABYLON.VertexBuffer.UV3Kind
  18234. * * BABYLON.VertexBuffer.UV4Kind
  18235. * * BABYLON.VertexBuffer.UV5Kind
  18236. * * BABYLON.VertexBuffer.UV6Kind
  18237. * * BABYLON.VertexBuffer.ColorKind
  18238. * * BABYLON.VertexBuffer.MatricesIndicesKind
  18239. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  18240. * * BABYLON.VertexBuffer.MatricesWeightsKind
  18241. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  18242. * @param data defines the data source
  18243. * @param updatable defines if the data must be flagged as updatable (or static)
  18244. * @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
  18245. * @returns the current mesh
  18246. */
  18247. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18248. /**
  18249. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18250. * If the mesh has no geometry, it is simply returned as it is.
  18251. * @param kind defines vertex data kind:
  18252. * * BABYLON.VertexBuffer.PositionKind
  18253. * * BABYLON.VertexBuffer.UVKind
  18254. * * BABYLON.VertexBuffer.UV2Kind
  18255. * * BABYLON.VertexBuffer.UV3Kind
  18256. * * BABYLON.VertexBuffer.UV4Kind
  18257. * * BABYLON.VertexBuffer.UV5Kind
  18258. * * BABYLON.VertexBuffer.UV6Kind
  18259. * * BABYLON.VertexBuffer.ColorKind
  18260. * * BABYLON.VertexBuffer.MatricesIndicesKind
  18261. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  18262. * * BABYLON.VertexBuffer.MatricesWeightsKind
  18263. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  18264. * @param data defines the data source
  18265. * @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
  18266. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  18267. * @returns the current mesh
  18268. */
  18269. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  18270. /**
  18271. * Sets the mesh indices,
  18272. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18273. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  18274. * @param totalVertices Defines the total number of vertices
  18275. * @returns the current mesh
  18276. */
  18277. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  18278. /**
  18279. * Gets a boolean indicating if specific vertex data is present
  18280. * @param kind defines the vertex data kind to use
  18281. * @returns true is data kind is present
  18282. */
  18283. isVerticesDataPresent(kind: string): boolean;
  18284. /**
  18285. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  18286. * @returns a BoundingInfo
  18287. */
  18288. getBoundingInfo(): BoundingInfo;
  18289. /**
  18290. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  18291. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  18292. * @returns the current mesh
  18293. */
  18294. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  18295. /**
  18296. * Overwrite the current bounding info
  18297. * @param boundingInfo defines the new bounding info
  18298. * @returns the current mesh
  18299. */
  18300. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  18301. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  18302. readonly useBones: boolean;
  18303. /** @hidden */
  18304. _preActivate(): void;
  18305. /** @hidden */
  18306. _preActivateForIntermediateRendering(renderId: number): void;
  18307. /** @hidden */
  18308. _activate(renderId: number): void;
  18309. /**
  18310. * Gets the current world matrix
  18311. * @returns a Matrix
  18312. */
  18313. getWorldMatrix(): Matrix;
  18314. /** @hidden */
  18315. _getWorldMatrixDeterminant(): number;
  18316. /**
  18317. * Perform relative position change from the point of view of behind the front of the mesh.
  18318. * This is performed taking into account the meshes current rotation, so you do not have to care.
  18319. * Supports definition of mesh facing forward or backward
  18320. * @param amountRight defines the distance on the right axis
  18321. * @param amountUp defines the distance on the up axis
  18322. * @param amountForward defines the distance on the forward axis
  18323. * @returns the current mesh
  18324. */
  18325. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  18326. /**
  18327. * Calculate relative position change from the point of view of behind the front of the mesh.
  18328. * This is performed taking into account the meshes current rotation, so you do not have to care.
  18329. * Supports definition of mesh facing forward or backward
  18330. * @param amountRight defines the distance on the right axis
  18331. * @param amountUp defines the distance on the up axis
  18332. * @param amountForward defines the distance on the forward axis
  18333. * @returns the new displacement vector
  18334. */
  18335. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  18336. /**
  18337. * Perform relative rotation change from the point of view of behind the front of the mesh.
  18338. * Supports definition of mesh facing forward or backward
  18339. * @param flipBack defines the flip
  18340. * @param twirlClockwise defines the twirl
  18341. * @param tiltRight defines the tilt
  18342. * @returns the current mesh
  18343. */
  18344. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  18345. /**
  18346. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  18347. * Supports definition of mesh facing forward or backward.
  18348. * @param flipBack defines the flip
  18349. * @param twirlClockwise defines the twirl
  18350. * @param tiltRight defines the tilt
  18351. * @returns the new rotation vector
  18352. */
  18353. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  18354. /**
  18355. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  18356. * @param includeDescendants Include bounding info from descendants as well (true by default)
  18357. * @returns the new bounding vectors
  18358. */
  18359. getHierarchyBoundingVectors(includeDescendants?: boolean): {
  18360. min: Vector3;
  18361. max: Vector3;
  18362. };
  18363. /** @hidden */
  18364. _updateBoundingInfo(): AbstractMesh;
  18365. /** @hidden */
  18366. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  18367. /** @hidden */
  18368. protected _afterComputeWorldMatrix(): void;
  18369. /**
  18370. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  18371. * A mesh is in the frustum if its bounding box intersects the frustum
  18372. * @param frustumPlanes defines the frustum to test
  18373. * @returns true if the mesh is in the frustum planes
  18374. */
  18375. isInFrustum(frustumPlanes: Plane[]): boolean;
  18376. /**
  18377. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  18378. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  18379. * @param frustumPlanes defines the frustum to test
  18380. * @returns true if the mesh is completely in the frustum planes
  18381. */
  18382. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  18383. /**
  18384. * True if the mesh intersects another mesh or a SolidParticle object
  18385. * @param mesh defines a target mesh or SolidParticle to test
  18386. * @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)
  18387. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  18388. * @returns true if there is an intersection
  18389. */
  18390. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  18391. /**
  18392. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  18393. * @param point defines the point to test
  18394. * @returns true if there is an intersection
  18395. */
  18396. intersectsPoint(point: Vector3): boolean;
  18397. /**
  18398. * Gets the current physics impostor
  18399. * @see http://doc.babylonjs.com/features/physics_engine
  18400. * @returns a physics impostor or null
  18401. */
  18402. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  18403. /**
  18404. * Gets the position of the current mesh in camera space
  18405. * @param camera defines the camera to use
  18406. * @returns a position
  18407. */
  18408. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  18409. /**
  18410. * Returns the distance from the mesh to the active camera
  18411. * @param camera defines the camera to use
  18412. * @returns the distance
  18413. */
  18414. getDistanceToCamera(camera?: Nullable<Camera>): number;
  18415. /**
  18416. * Apply a physic impulse to the mesh
  18417. * @param force defines the force to apply
  18418. * @param contactPoint defines where to apply the force
  18419. * @returns the current mesh
  18420. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18421. */
  18422. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  18423. /**
  18424. * Creates a physic joint between two meshes
  18425. * @param otherMesh defines the other mesh to use
  18426. * @param pivot1 defines the pivot to use on this mesh
  18427. * @param pivot2 defines the pivot to use on the other mesh
  18428. * @param options defines additional options (can be plugin dependent)
  18429. * @returns the current mesh
  18430. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  18431. */
  18432. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  18433. /**
  18434. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  18435. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18436. */
  18437. checkCollisions: boolean;
  18438. /**
  18439. * Gets Collider object used to compute collisions (not physics)
  18440. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18441. */
  18442. readonly collider: Collider;
  18443. /**
  18444. * Move the mesh using collision engine
  18445. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18446. * @param displacement defines the requested displacement vector
  18447. * @returns the current mesh
  18448. */
  18449. moveWithCollisions(displacement: Vector3): AbstractMesh;
  18450. private _onCollisionPositionChange;
  18451. /**
  18452. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  18453. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18454. * @param maxCapacity defines the maximum size of each block (64 by default)
  18455. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  18456. * @returns the new octree
  18457. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  18458. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  18459. */
  18460. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  18461. /** @hidden */
  18462. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  18463. /** @hidden */
  18464. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  18465. /** @hidden */
  18466. _checkCollision(collider: Collider): AbstractMesh;
  18467. /** @hidden */
  18468. _generatePointsArray(): boolean;
  18469. /**
  18470. * Checks if the passed Ray intersects with the mesh
  18471. * @param ray defines the ray to use
  18472. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  18473. * @returns the picking info
  18474. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  18475. */
  18476. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  18477. /**
  18478. * Clones the current mesh
  18479. * @param name defines the mesh name
  18480. * @param newParent defines the new mesh parent
  18481. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  18482. * @returns the new mesh
  18483. */
  18484. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18485. /**
  18486. * Disposes all the submeshes of the current meshnp
  18487. * @returns the current mesh
  18488. */
  18489. releaseSubMeshes(): AbstractMesh;
  18490. /**
  18491. * Releases resources associated with this abstract mesh.
  18492. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18493. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18494. */
  18495. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18496. /**
  18497. * Adds the passed mesh as a child to the current mesh
  18498. * @param mesh defines the child mesh
  18499. * @returns the current mesh
  18500. */
  18501. addChild(mesh: AbstractMesh): AbstractMesh;
  18502. /**
  18503. * Removes the passed mesh from the current mesh children list
  18504. * @param mesh defines the child mesh
  18505. * @returns the current mesh
  18506. */
  18507. removeChild(mesh: AbstractMesh): AbstractMesh;
  18508. /** @hidden */
  18509. private _initFacetData();
  18510. /**
  18511. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  18512. * This method can be called within the render loop.
  18513. * 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
  18514. * @returns the current mesh
  18515. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18516. */
  18517. updateFacetData(): AbstractMesh;
  18518. /**
  18519. * Returns the facetLocalNormals array.
  18520. * The normals are expressed in the mesh local spac
  18521. * @returns an array of Vector3
  18522. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18523. */
  18524. getFacetLocalNormals(): Vector3[];
  18525. /**
  18526. * Returns the facetLocalPositions array.
  18527. * The facet positions are expressed in the mesh local space
  18528. * @returns an array of Vector3
  18529. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18530. */
  18531. getFacetLocalPositions(): Vector3[];
  18532. /**
  18533. * Returns the facetLocalPartioning array
  18534. * @returns an array of array of numbers
  18535. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18536. */
  18537. getFacetLocalPartitioning(): number[][];
  18538. /**
  18539. * Returns the i-th facet position in the world system.
  18540. * This method allocates a new Vector3 per call
  18541. * @param i defines the facet index
  18542. * @returns a new Vector3
  18543. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18544. */
  18545. getFacetPosition(i: number): Vector3;
  18546. /**
  18547. * Sets the reference Vector3 with the i-th facet position in the world system
  18548. * @param i defines the facet index
  18549. * @param ref defines the target vector
  18550. * @returns the current mesh
  18551. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18552. */
  18553. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  18554. /**
  18555. * Returns the i-th facet normal in the world system.
  18556. * This method allocates a new Vector3 per call
  18557. * @param i defines the facet index
  18558. * @returns a new Vector3
  18559. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18560. */
  18561. getFacetNormal(i: number): Vector3;
  18562. /**
  18563. * Sets the reference Vector3 with the i-th facet normal in the world system
  18564. * @param i defines the facet index
  18565. * @param ref defines the target vector
  18566. * @returns the current mesh
  18567. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18568. */
  18569. getFacetNormalToRef(i: number, ref: Vector3): this;
  18570. /**
  18571. * 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)
  18572. * @param x defines x coordinate
  18573. * @param y defines y coordinate
  18574. * @param z defines z coordinate
  18575. * @returns the array of facet indexes
  18576. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18577. */
  18578. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  18579. /**
  18580. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  18581. * @param projected sets as the (x,y,z) world projection on the facet
  18582. * @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
  18583. * @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
  18584. * @param x defines x coordinate
  18585. * @param y defines y coordinate
  18586. * @param z defines z coordinate
  18587. * @returns the face index if found (or null instead)
  18588. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18589. */
  18590. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  18591. /**
  18592. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  18593. * @param projected sets as the (x,y,z) local projection on the facet
  18594. * @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
  18595. * @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
  18596. * @param x defines x coordinate
  18597. * @param y defines y coordinate
  18598. * @param z defines z coordinate
  18599. * @returns the face index if found (or null instead)
  18600. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18601. */
  18602. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  18603. /**
  18604. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  18605. * @returns the parameters
  18606. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18607. */
  18608. getFacetDataParameters(): any;
  18609. /**
  18610. * Disables the feature FacetData and frees the related memory
  18611. * @returns the current mesh
  18612. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18613. */
  18614. disableFacetData(): AbstractMesh;
  18615. /**
  18616. * Updates the AbstractMesh indices array
  18617. * @param indices defines the data source
  18618. * @returns the current mesh
  18619. */
  18620. updateIndices(indices: IndicesArray): AbstractMesh;
  18621. /**
  18622. * Creates new normals data for the mesh
  18623. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  18624. * @returns the current mesh
  18625. */
  18626. createNormals(updatable: boolean): AbstractMesh;
  18627. /**
  18628. * Align the mesh with a normal
  18629. * @param normal defines the normal to use
  18630. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  18631. * @returns the current mesh
  18632. */
  18633. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  18634. /** @hidden */
  18635. protected _checkOcclusionQuery(): void;
  18636. }
  18637. }
  18638. declare module BABYLON {
  18639. class Buffer {
  18640. private _engine;
  18641. private _buffer;
  18642. private _data;
  18643. private _updatable;
  18644. private _instanced;
  18645. /**
  18646. * Gets the byte stride.
  18647. */
  18648. readonly byteStride: number;
  18649. /**
  18650. * Constructor
  18651. * @param engine the engine
  18652. * @param data the data to use for this buffer
  18653. * @param updatable whether the data is updatable
  18654. * @param stride the stride (optional)
  18655. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  18656. * @param instanced whether the buffer is instanced (optional)
  18657. * @param useBytes set to true if the stride in in bytes (optional)
  18658. */
  18659. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  18660. /**
  18661. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  18662. * @param kind defines the vertex buffer kind (position, normal, etc.)
  18663. * @param offset defines offset in the buffer (0 by default)
  18664. * @param size defines the size in floats of attributes (position is 3 for instance)
  18665. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  18666. * @param instanced defines if the vertex buffer contains indexed data
  18667. * @param useBytes defines if the offset and stride are in bytes
  18668. * @returns the new vertex buffer
  18669. */
  18670. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  18671. isUpdatable(): boolean;
  18672. getData(): Nullable<DataArray>;
  18673. getBuffer(): Nullable<WebGLBuffer>;
  18674. /**
  18675. * Gets the stride in float32 units (i.e. byte stride / 4).
  18676. * May not be an integer if the byte stride is not divisible by 4.
  18677. * DEPRECATED. Use byteStride instead.
  18678. * @returns the stride in float32 units
  18679. */
  18680. getStrideSize(): number;
  18681. create(data?: Nullable<DataArray>): void;
  18682. _rebuild(): void;
  18683. update(data: DataArray): void;
  18684. /**
  18685. * Updates the data directly.
  18686. * @param data the new data
  18687. * @param offset the new offset
  18688. * @param vertexCount the vertex count (optional)
  18689. * @param useBytes set to true if the offset is in bytes
  18690. */
  18691. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  18692. dispose(): void;
  18693. }
  18694. }
  18695. declare module BABYLON {
  18696. class CSG {
  18697. private polygons;
  18698. matrix: Matrix;
  18699. position: Vector3;
  18700. rotation: Vector3;
  18701. rotationQuaternion: Nullable<Quaternion>;
  18702. scaling: Vector3;
  18703. static FromMesh(mesh: Mesh): CSG;
  18704. private static FromPolygons(polygons);
  18705. clone(): CSG;
  18706. union(csg: CSG): CSG;
  18707. unionInPlace(csg: CSG): void;
  18708. subtract(csg: CSG): CSG;
  18709. subtractInPlace(csg: CSG): void;
  18710. intersect(csg: CSG): CSG;
  18711. intersectInPlace(csg: CSG): void;
  18712. inverse(): CSG;
  18713. inverseInPlace(): void;
  18714. copyTransformAttributes(csg: CSG): CSG;
  18715. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  18716. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  18717. }
  18718. }
  18719. declare module BABYLON {
  18720. /**
  18721. * Class used to store geometry data (vertex buffers + index buffer)
  18722. */
  18723. class Geometry implements IGetSetVerticesData {
  18724. /**
  18725. * Gets or sets the unique ID of the geometry
  18726. */
  18727. id: string;
  18728. /**
  18729. * Gets the delay loading state of the geometry (none by default which means not delayed)
  18730. */
  18731. delayLoadState: number;
  18732. /**
  18733. * Gets the file containing the data to load when running in delay load state
  18734. */
  18735. delayLoadingFile: Nullable<string>;
  18736. /**
  18737. * Callback called when the geometry is updated
  18738. */
  18739. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  18740. private _scene;
  18741. private _engine;
  18742. private _meshes;
  18743. private _totalVertices;
  18744. private _indices;
  18745. private _vertexBuffers;
  18746. private _isDisposed;
  18747. private _extend;
  18748. private _boundingBias;
  18749. /** @hidden */
  18750. _delayInfo: Array<string>;
  18751. private _indexBuffer;
  18752. private _indexBufferIsUpdatable;
  18753. /** @hidden */
  18754. _boundingInfo: Nullable<BoundingInfo>;
  18755. /** @hidden */
  18756. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  18757. /** @hidden */
  18758. _softwareSkinningRenderId: number;
  18759. private _vertexArrayObjects;
  18760. private _updatable;
  18761. /** @hidden */
  18762. _positions: Nullable<Vector3[]>;
  18763. /**
  18764. * 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
  18765. */
  18766. /**
  18767. * 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
  18768. */
  18769. boundingBias: Vector2;
  18770. /**
  18771. * Static function used to attach a new empty geometry to a mesh
  18772. * @param mesh defines the mesh to attach the geometry to
  18773. * @returns the new {BABYLON.Geometry}
  18774. */
  18775. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  18776. /**
  18777. * Creates a new geometry
  18778. * @param id defines the unique ID
  18779. * @param scene defines the hosting scene
  18780. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  18781. * @param updatable defines if geometry must be updatable (false by default)
  18782. * @param mesh defines the mesh that will be associated with the geometry
  18783. */
  18784. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  18785. /**
  18786. * Gets the current extend of the geometry
  18787. */
  18788. readonly extend: {
  18789. minimum: Vector3;
  18790. maximum: Vector3;
  18791. };
  18792. /**
  18793. * Gets the hosting scene
  18794. * @returns the hosting {BABYLON.Scene}
  18795. */
  18796. getScene(): Scene;
  18797. /**
  18798. * Gets the hosting engine
  18799. * @returns the hosting {BABYLON.Engine}
  18800. */
  18801. getEngine(): Engine;
  18802. /**
  18803. * Defines if the geometry is ready to use
  18804. * @returns true if the geometry is ready to be used
  18805. */
  18806. isReady(): boolean;
  18807. /**
  18808. * Gets a value indicating that the geometry should not be serialized
  18809. */
  18810. readonly doNotSerialize: boolean;
  18811. /** @hidden */
  18812. _rebuild(): void;
  18813. /**
  18814. * Affects all gemetry data in one call
  18815. * @param vertexData defines the geometry data
  18816. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  18817. */
  18818. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  18819. /**
  18820. * Set specific vertex data
  18821. * @param kind defines the data kind (Position, normal, etc...)
  18822. * @param data defines the vertex data to use
  18823. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  18824. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  18825. */
  18826. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  18827. /**
  18828. * Removes a specific vertex data
  18829. * @param kind defines the data kind (Position, normal, etc...)
  18830. */
  18831. removeVerticesData(kind: string): void;
  18832. /**
  18833. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  18834. * @param buffer defines the vertex buffer to use
  18835. * @param totalVertices defines the total number of vertices for position kind (could be null)
  18836. */
  18837. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  18838. /**
  18839. * Update a specific vertex buffer
  18840. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  18841. * It will do nothing if the buffer is not updatable
  18842. * @param kind defines the data kind (Position, normal, etc...)
  18843. * @param data defines the data to use
  18844. * @param offset defines the offset in the target buffer where to store the data
  18845. * @param useBytes set to true if the offset is in bytes
  18846. */
  18847. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  18848. /**
  18849. * Update a specific vertex buffer
  18850. * This function will create a new buffer if the current one is not updatable
  18851. * @param kind defines the data kind (Position, normal, etc...)
  18852. * @param data defines the data to use
  18853. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  18854. */
  18855. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  18856. private _updateBoundingInfo(updateExtends, data);
  18857. /** @hidden */
  18858. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  18859. /**
  18860. * Gets total number of vertices
  18861. * @returns the total number of vertices
  18862. */
  18863. getTotalVertices(): number;
  18864. /**
  18865. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  18866. * @param kind defines the data kind (Position, normal, etc...)
  18867. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  18868. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  18869. * @returns a float array containing vertex data
  18870. */
  18871. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  18872. /**
  18873. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  18874. * @param kind defines the data kind (Position, normal, etc...)
  18875. * @returns true if the vertex buffer with the specified kind is updatable
  18876. */
  18877. isVertexBufferUpdatable(kind: string): boolean;
  18878. /**
  18879. * Gets a specific vertex buffer
  18880. * @param kind defines the data kind (Position, normal, etc...)
  18881. * @returns a {BABYLON.VertexBuffer}
  18882. */
  18883. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  18884. /**
  18885. * Returns all vertex buffers
  18886. * @return an object holding all vertex buffers indexed by kind
  18887. */
  18888. getVertexBuffers(): Nullable<{
  18889. [key: string]: VertexBuffer;
  18890. }>;
  18891. /**
  18892. * Gets a boolean indicating if specific vertex buffer is present
  18893. * @param kind defines the data kind (Position, normal, etc...)
  18894. * @returns true if data is present
  18895. */
  18896. isVerticesDataPresent(kind: string): boolean;
  18897. /**
  18898. * Gets a list of all attached data kinds (Position, normal, etc...)
  18899. * @returns a list of string containing all kinds
  18900. */
  18901. getVerticesDataKinds(): string[];
  18902. /**
  18903. * Update index buffer
  18904. * @param indices defines the indices to store in the index buffer
  18905. * @param offset defines the offset in the target buffer where to store the data
  18906. */
  18907. updateIndices(indices: IndicesArray, offset?: number): void;
  18908. /**
  18909. * Creates a new index buffer
  18910. * @param indices defines the indices to store in the index buffer
  18911. * @param totalVertices defines the total number of vertices (could be null)
  18912. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  18913. */
  18914. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  18915. /**
  18916. * Return the total number of indices
  18917. * @returns the total number of indices
  18918. */
  18919. getTotalIndices(): number;
  18920. /**
  18921. * Gets the index buffer array
  18922. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  18923. * @returns the index buffer array
  18924. */
  18925. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  18926. /**
  18927. * Gets the index buffer
  18928. * @return the index buffer
  18929. */
  18930. getIndexBuffer(): Nullable<WebGLBuffer>;
  18931. /** @hidden */
  18932. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  18933. /**
  18934. * Release the associated resources for a specific mesh
  18935. * @param mesh defines the source mesh
  18936. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  18937. */
  18938. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  18939. /**
  18940. * Apply current geometry to a given mesh
  18941. * @param mesh defines the mesh to apply geometry to
  18942. */
  18943. applyToMesh(mesh: Mesh): void;
  18944. private _updateExtend(data?);
  18945. private _applyToMesh(mesh);
  18946. private notifyUpdate(kind?);
  18947. /**
  18948. * Load the geometry if it was flagged as delay loaded
  18949. * @param scene defines the hosting scene
  18950. * @param onLoaded defines a callback called when the geometry is loaded
  18951. */
  18952. load(scene: Scene, onLoaded?: () => void): void;
  18953. private _queueLoad(scene, onLoaded?);
  18954. /**
  18955. * Invert the geometry to move from a right handed system to a left handed one.
  18956. */
  18957. toLeftHanded(): void;
  18958. /** @hidden */
  18959. _resetPointsArrayCache(): void;
  18960. /** @hidden */
  18961. _generatePointsArray(): boolean;
  18962. /**
  18963. * Gets a value indicating if the geometry is disposed
  18964. * @returns true if the geometry was disposed
  18965. */
  18966. isDisposed(): boolean;
  18967. private _disposeVertexArrayObjects();
  18968. /**
  18969. * Free all associated resources
  18970. */
  18971. dispose(): void;
  18972. /**
  18973. * Clone the current geometry into a new geometry
  18974. * @param id defines the unique ID of the new geometry
  18975. * @returns a new geometry object
  18976. */
  18977. copy(id: string): Geometry;
  18978. /**
  18979. * Serialize the current geometry info (and not the vertices data) into a JSON object
  18980. * @return a JSON representation of the current geometry data (without the vertices data)
  18981. */
  18982. serialize(): any;
  18983. private toNumberArray(origin);
  18984. /**
  18985. * Serialize all vertices data into a JSON oject
  18986. * @returns a JSON representation of the current geometry data
  18987. */
  18988. serializeVerticeData(): any;
  18989. /**
  18990. * Extracts a clone of a mesh geometry
  18991. * @param mesh defines the source mesh
  18992. * @param id defines the unique ID of the new geometry object
  18993. * @returns the new geometry object
  18994. */
  18995. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  18996. /**
  18997. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  18998. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  18999. * Be aware Math.random() could cause collisions, but:
  19000. * "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"
  19001. * @returns a string containing a new GUID
  19002. */
  19003. static RandomId(): string;
  19004. /** @hidden */
  19005. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  19006. private static _CleanMatricesWeights(parsedGeometry, mesh);
  19007. /**
  19008. * Create a new geometry from persisted data (Using .babylon file format)
  19009. * @param parsedVertexData defines the persisted data
  19010. * @param scene defines the hosting scene
  19011. * @param rootUrl defines the root url to use to load assets (like delayed data)
  19012. * @returns the new geometry object
  19013. */
  19014. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  19015. }
  19016. /**
  19017. * Abstract class used to provide common services for all typed geometries
  19018. * @hidden
  19019. */
  19020. class _PrimitiveGeometry extends Geometry {
  19021. private _canBeRegenerated;
  19022. private _beingRegenerated;
  19023. /**
  19024. * Creates a new typed geometry
  19025. * @param id defines the unique ID of the geometry
  19026. * @param scene defines the hosting scene
  19027. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19028. * @param mesh defines the hosting mesh (can be null)
  19029. */
  19030. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  19031. /**
  19032. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  19033. * @returns true if the geometry can be regenerated
  19034. */
  19035. canBeRegenerated(): boolean;
  19036. /**
  19037. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  19038. */
  19039. regenerate(): void;
  19040. /**
  19041. * Clone the geometry
  19042. * @param id defines the unique ID of the new geometry
  19043. * @returns the new geometry
  19044. */
  19045. asNewGeometry(id: string): Geometry;
  19046. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  19047. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  19048. /** @hidden */
  19049. _regenerateVertexData(): VertexData;
  19050. copy(id: string): Geometry;
  19051. serialize(): any;
  19052. }
  19053. /**
  19054. * Creates a ribbon geometry
  19055. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  19056. */
  19057. class RibbonGeometry extends _PrimitiveGeometry {
  19058. /**
  19059. * Defines the array of paths to use
  19060. */
  19061. pathArray: Vector3[][];
  19062. /**
  19063. * Defines if the last and first points of each path in your pathArray must be joined
  19064. */
  19065. closeArray: boolean;
  19066. /**
  19067. * Defines if the last and first points of each path in your pathArray must be joined
  19068. */
  19069. closePath: boolean;
  19070. /**
  19071. * Defines the offset between points
  19072. */
  19073. offset: number;
  19074. /**
  19075. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19076. */
  19077. side: number;
  19078. /**
  19079. * Creates a ribbon geometry
  19080. * @param id defines the unique ID of the geometry
  19081. * @param scene defines the hosting scene
  19082. * @param pathArray defines the array of paths to use
  19083. * @param closeArray defines if the last path and the first path must be joined
  19084. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  19085. * @param offset defines the offset between points
  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 array of paths to use
  19093. */
  19094. pathArray: Vector3[][],
  19095. /**
  19096. * Defines if the last and first points of each path in your pathArray must be joined
  19097. */
  19098. closeArray: boolean,
  19099. /**
  19100. * Defines if the last and first points of each path in your pathArray must be joined
  19101. */
  19102. closePath: boolean,
  19103. /**
  19104. * Defines the offset between points
  19105. */
  19106. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  19107. /**
  19108. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19109. */
  19110. side?: number);
  19111. /** @hidden */
  19112. _regenerateVertexData(): VertexData;
  19113. copy(id: string): Geometry;
  19114. }
  19115. /**
  19116. * Creates a box geometry
  19117. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  19118. */
  19119. class BoxGeometry extends _PrimitiveGeometry {
  19120. /**
  19121. * Defines the zise of the box (width, height and depth are the same)
  19122. */
  19123. size: number;
  19124. /**
  19125. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19126. */
  19127. side: number;
  19128. /**
  19129. * Creates a box geometry
  19130. * @param id defines the unique ID of the geometry
  19131. * @param scene defines the hosting scene
  19132. * @param size defines the zise of the box (width, height and depth are the same)
  19133. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19134. * @param mesh defines the hosting mesh (can be null)
  19135. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19136. */
  19137. constructor(id: string, scene: Scene,
  19138. /**
  19139. * Defines the zise of the box (width, height and depth are the same)
  19140. */
  19141. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19142. /**
  19143. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19144. */
  19145. side?: number);
  19146. _regenerateVertexData(): VertexData;
  19147. copy(id: string): Geometry;
  19148. serialize(): any;
  19149. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  19150. }
  19151. /**
  19152. * Creates a sphere geometry
  19153. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  19154. */
  19155. class SphereGeometry extends _PrimitiveGeometry {
  19156. /**
  19157. * Defines the number of segments to use to create the sphere
  19158. */
  19159. segments: number;
  19160. /**
  19161. * Defines the diameter of the sphere
  19162. */
  19163. diameter: number;
  19164. /**
  19165. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19166. */
  19167. side: number;
  19168. /**
  19169. * Create a new sphere geometry
  19170. * @param id defines the unique ID of the geometry
  19171. * @param scene defines the hosting scene
  19172. * @param segments defines the number of segments to use to create the sphere
  19173. * @param diameter defines the diameter of the sphere
  19174. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19175. * @param mesh defines the hosting mesh (can be null)
  19176. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19177. */
  19178. constructor(id: string, scene: Scene,
  19179. /**
  19180. * Defines the number of segments to use to create the sphere
  19181. */
  19182. segments: number,
  19183. /**
  19184. * Defines the diameter of the sphere
  19185. */
  19186. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19187. /**
  19188. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19189. */
  19190. side?: number);
  19191. _regenerateVertexData(): VertexData;
  19192. copy(id: string): Geometry;
  19193. serialize(): any;
  19194. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  19195. }
  19196. /**
  19197. * Creates a disc geometry
  19198. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  19199. */
  19200. class DiscGeometry extends _PrimitiveGeometry {
  19201. /**
  19202. * Defines the radius of the disc
  19203. */
  19204. radius: number;
  19205. /**
  19206. * Defines the tesselation factor to apply to the disc
  19207. */
  19208. tessellation: number;
  19209. /**
  19210. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19211. */
  19212. side: number;
  19213. /**
  19214. * Creates a new disc geometry
  19215. * @param id defines the unique ID of the geometry
  19216. * @param scene defines the hosting scene
  19217. * @param radius defines the radius of the disc
  19218. * @param tessellation defines the tesselation factor to apply to the disc
  19219. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19220. * @param mesh defines the hosting mesh (can be null)
  19221. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19222. */
  19223. constructor(id: string, scene: Scene,
  19224. /**
  19225. * Defines the radius of the disc
  19226. */
  19227. radius: number,
  19228. /**
  19229. * Defines the tesselation factor to apply to the disc
  19230. */
  19231. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19232. /**
  19233. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19234. */
  19235. side?: number);
  19236. _regenerateVertexData(): VertexData;
  19237. copy(id: string): Geometry;
  19238. }
  19239. /**
  19240. * Creates a new cylinder geometry
  19241. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  19242. */
  19243. class CylinderGeometry extends _PrimitiveGeometry {
  19244. /**
  19245. * Defines the height of the cylinder
  19246. */
  19247. height: number;
  19248. /**
  19249. * Defines the diameter of the cylinder's top cap
  19250. */
  19251. diameterTop: number;
  19252. /**
  19253. * Defines the diameter of the cylinder's bottom cap
  19254. */
  19255. diameterBottom: number;
  19256. /**
  19257. * Defines the tessellation factor to apply to the cylinder
  19258. */
  19259. tessellation: number;
  19260. /**
  19261. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  19262. */
  19263. subdivisions: number;
  19264. /**
  19265. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19266. */
  19267. side: number;
  19268. /**
  19269. * Creates a new cylinder geometry
  19270. * @param id defines the unique ID of the geometry
  19271. * @param scene defines the hosting scene
  19272. * @param height defines the height of the cylinder
  19273. * @param diameterTop defines the diameter of the cylinder's top cap
  19274. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  19275. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  19276. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  19277. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19278. * @param mesh defines the hosting mesh (can be null)
  19279. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19280. */
  19281. constructor(id: string, scene: Scene,
  19282. /**
  19283. * Defines the height of the cylinder
  19284. */
  19285. height: number,
  19286. /**
  19287. * Defines the diameter of the cylinder's top cap
  19288. */
  19289. diameterTop: number,
  19290. /**
  19291. * Defines the diameter of the cylinder's bottom cap
  19292. */
  19293. diameterBottom: number,
  19294. /**
  19295. * Defines the tessellation factor to apply to the cylinder
  19296. */
  19297. tessellation: number,
  19298. /**
  19299. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  19300. */
  19301. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19302. /**
  19303. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19304. */
  19305. side?: number);
  19306. _regenerateVertexData(): VertexData;
  19307. copy(id: string): Geometry;
  19308. serialize(): any;
  19309. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  19310. }
  19311. /**
  19312. * Creates a new torus geometry
  19313. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  19314. */
  19315. class TorusGeometry extends _PrimitiveGeometry {
  19316. /**
  19317. * Defines the diameter of the torus
  19318. */
  19319. diameter: number;
  19320. /**
  19321. * Defines the thickness of the torus (ie. internal diameter)
  19322. */
  19323. thickness: number;
  19324. /**
  19325. * Defines the tesselation factor to apply to the torus
  19326. */
  19327. tessellation: number;
  19328. /**
  19329. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19330. */
  19331. side: number;
  19332. /**
  19333. * Creates a new torus geometry
  19334. * @param id defines the unique ID of the geometry
  19335. * @param scene defines the hosting scene
  19336. * @param diameter defines the diameter of the torus
  19337. * @param thickness defines the thickness of the torus (ie. internal diameter)
  19338. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  19339. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19340. * @param mesh defines the hosting mesh (can be null)
  19341. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19342. */
  19343. constructor(id: string, scene: Scene,
  19344. /**
  19345. * Defines the diameter of the torus
  19346. */
  19347. diameter: number,
  19348. /**
  19349. * Defines the thickness of the torus (ie. internal diameter)
  19350. */
  19351. thickness: number,
  19352. /**
  19353. * Defines the tesselation factor to apply to the torus
  19354. */
  19355. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19356. /**
  19357. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19358. */
  19359. side?: number);
  19360. _regenerateVertexData(): VertexData;
  19361. copy(id: string): Geometry;
  19362. serialize(): any;
  19363. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  19364. }
  19365. /**
  19366. * Creates a new ground geometry
  19367. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  19368. */
  19369. class GroundGeometry extends _PrimitiveGeometry {
  19370. /**
  19371. * Defines the width of the ground
  19372. */
  19373. width: number;
  19374. /**
  19375. * Defines the height of the ground
  19376. */
  19377. height: number;
  19378. /**
  19379. * Defines the subdivisions to apply to the ground
  19380. */
  19381. subdivisions: number;
  19382. /**
  19383. * Creates a new ground geometry
  19384. * @param id defines the unique ID of the geometry
  19385. * @param scene defines the hosting scene
  19386. * @param width defines the width of the ground
  19387. * @param height defines the height of the ground
  19388. * @param subdivisions defines the subdivisions to apply to the ground
  19389. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19390. * @param mesh defines the hosting mesh (can be null)
  19391. */
  19392. constructor(id: string, scene: Scene,
  19393. /**
  19394. * Defines the width of the ground
  19395. */
  19396. width: number,
  19397. /**
  19398. * Defines the height of the ground
  19399. */
  19400. height: number,
  19401. /**
  19402. * Defines the subdivisions to apply to the ground
  19403. */
  19404. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  19405. _regenerateVertexData(): VertexData;
  19406. copy(id: string): Geometry;
  19407. serialize(): any;
  19408. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  19409. }
  19410. /**
  19411. * Creates a tiled ground geometry
  19412. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  19413. */
  19414. class TiledGroundGeometry extends _PrimitiveGeometry {
  19415. /**
  19416. * Defines the minimum value on X axis
  19417. */
  19418. xmin: number;
  19419. /**
  19420. * Defines the minimum value on Z axis
  19421. */
  19422. zmin: number;
  19423. /**
  19424. * Defines the maximum value on X axis
  19425. */
  19426. xmax: number;
  19427. /**
  19428. * Defines the maximum value on Z axis
  19429. */
  19430. zmax: number;
  19431. /**
  19432. * Defines the subdivisions to apply to the ground
  19433. */
  19434. subdivisions: {
  19435. w: number;
  19436. h: number;
  19437. };
  19438. /**
  19439. * Defines the precision to use when computing the tiles
  19440. */
  19441. precision: {
  19442. w: number;
  19443. h: number;
  19444. };
  19445. /**
  19446. * Creates a tiled ground geometry
  19447. * @param id defines the unique ID of the geometry
  19448. * @param scene defines the hosting scene
  19449. * @param xmin defines the minimum value on X axis
  19450. * @param zmin defines the minimum value on Z axis
  19451. * @param xmax defines the maximum value on X axis
  19452. * @param zmax defines the maximum value on Z axis
  19453. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  19454. * @param precision defines the precision to use when computing the tiles
  19455. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19456. * @param mesh defines the hosting mesh (can be null)
  19457. */
  19458. constructor(id: string, scene: Scene,
  19459. /**
  19460. * Defines the minimum value on X axis
  19461. */
  19462. xmin: number,
  19463. /**
  19464. * Defines the minimum value on Z axis
  19465. */
  19466. zmin: number,
  19467. /**
  19468. * Defines the maximum value on X axis
  19469. */
  19470. xmax: number,
  19471. /**
  19472. * Defines the maximum value on Z axis
  19473. */
  19474. zmax: number,
  19475. /**
  19476. * Defines the subdivisions to apply to the ground
  19477. */
  19478. subdivisions: {
  19479. w: number;
  19480. h: number;
  19481. },
  19482. /**
  19483. * Defines the precision to use when computing the tiles
  19484. */
  19485. precision: {
  19486. w: number;
  19487. h: number;
  19488. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  19489. _regenerateVertexData(): VertexData;
  19490. copy(id: string): Geometry;
  19491. }
  19492. /**
  19493. * Creates a plane geometry
  19494. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  19495. */
  19496. class PlaneGeometry extends _PrimitiveGeometry {
  19497. /**
  19498. * Defines the size of the plane (width === height)
  19499. */
  19500. size: number;
  19501. /**
  19502. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19503. */
  19504. side: number;
  19505. /**
  19506. * Creates a plane geometry
  19507. * @param id defines the unique ID of the geometry
  19508. * @param scene defines the hosting scene
  19509. * @param size defines the size of the plane (width === height)
  19510. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19511. * @param mesh defines the hosting mesh (can be null)
  19512. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19513. */
  19514. constructor(id: string, scene: Scene,
  19515. /**
  19516. * Defines the size of the plane (width === height)
  19517. */
  19518. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19519. /**
  19520. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19521. */
  19522. side?: number);
  19523. _regenerateVertexData(): VertexData;
  19524. copy(id: string): Geometry;
  19525. serialize(): any;
  19526. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  19527. }
  19528. /**
  19529. * Creates a torus knot geometry
  19530. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  19531. */
  19532. class TorusKnotGeometry extends _PrimitiveGeometry {
  19533. /**
  19534. * Defines the radius of the torus knot
  19535. */
  19536. radius: number;
  19537. /**
  19538. * Defines the thickness of the torus knot tube
  19539. */
  19540. tube: number;
  19541. /**
  19542. * Defines the number of radial segments
  19543. */
  19544. radialSegments: number;
  19545. /**
  19546. * Defines the number of tubular segments
  19547. */
  19548. tubularSegments: number;
  19549. /**
  19550. * Defines the first number of windings
  19551. */
  19552. p: number;
  19553. /**
  19554. * Defines the second number of windings
  19555. */
  19556. q: number;
  19557. /**
  19558. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19559. */
  19560. side: number;
  19561. /**
  19562. * Creates a torus knot geometry
  19563. * @param id defines the unique ID of the geometry
  19564. * @param scene defines the hosting scene
  19565. * @param radius defines the radius of the torus knot
  19566. * @param tube defines the thickness of the torus knot tube
  19567. * @param radialSegments defines the number of radial segments
  19568. * @param tubularSegments defines the number of tubular segments
  19569. * @param p defines the first number of windings
  19570. * @param q defines the second number of windings
  19571. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19572. * @param mesh defines the hosting mesh (can be null)
  19573. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19574. */
  19575. constructor(id: string, scene: Scene,
  19576. /**
  19577. * Defines the radius of the torus knot
  19578. */
  19579. radius: number,
  19580. /**
  19581. * Defines the thickness of the torus knot tube
  19582. */
  19583. tube: number,
  19584. /**
  19585. * Defines the number of radial segments
  19586. */
  19587. radialSegments: number,
  19588. /**
  19589. * Defines the number of tubular segments
  19590. */
  19591. tubularSegments: number,
  19592. /**
  19593. * Defines the first number of windings
  19594. */
  19595. p: number,
  19596. /**
  19597. * Defines the second number of windings
  19598. */
  19599. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19600. /**
  19601. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19602. */
  19603. side?: number);
  19604. _regenerateVertexData(): VertexData;
  19605. copy(id: string): Geometry;
  19606. serialize(): any;
  19607. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  19608. }
  19609. }
  19610. declare module BABYLON {
  19611. class GroundMesh extends Mesh {
  19612. generateOctree: boolean;
  19613. private _heightQuads;
  19614. _subdivisionsX: number;
  19615. _subdivisionsY: number;
  19616. _width: number;
  19617. _height: number;
  19618. _minX: number;
  19619. _maxX: number;
  19620. _minZ: number;
  19621. _maxZ: number;
  19622. constructor(name: string, scene: Scene);
  19623. getClassName(): string;
  19624. readonly subdivisions: number;
  19625. readonly subdivisionsX: number;
  19626. readonly subdivisionsY: number;
  19627. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19628. /**
  19629. * Returns a height (y) value in the Worl system :
  19630. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19631. * Returns the ground y position if (x, z) are outside the ground surface.
  19632. */
  19633. getHeightAtCoordinates(x: number, z: number): number;
  19634. /**
  19635. * Returns a normalized vector (Vector3) orthogonal to the ground
  19636. * at the ground coordinates (x, z) expressed in the World system.
  19637. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19638. */
  19639. getNormalAtCoordinates(x: number, z: number): Vector3;
  19640. /**
  19641. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19642. * at the ground coordinates (x, z) expressed in the World system.
  19643. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19644. * Returns the GroundMesh.
  19645. */
  19646. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19647. /**
  19648. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19649. * if the ground has been updated.
  19650. * This can be used in the render loop.
  19651. * Returns the GroundMesh.
  19652. */
  19653. updateCoordinateHeights(): GroundMesh;
  19654. private _getFacetAt(x, z);
  19655. private _initHeightQuads();
  19656. private _computeHeightQuads();
  19657. serialize(serializationObject: any): void;
  19658. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19659. }
  19660. }
  19661. declare module BABYLON {
  19662. /**
  19663. * Creates an instance based on a source mesh.
  19664. */
  19665. class InstancedMesh extends AbstractMesh {
  19666. private _sourceMesh;
  19667. private _currentLOD;
  19668. constructor(name: string, source: Mesh);
  19669. /**
  19670. * Returns the string "InstancedMesh".
  19671. */
  19672. getClassName(): string;
  19673. readonly receiveShadows: boolean;
  19674. readonly material: Nullable<Material>;
  19675. readonly visibility: number;
  19676. readonly skeleton: Nullable<Skeleton>;
  19677. renderingGroupId: number;
  19678. /**
  19679. * Returns the total number of vertices (integer).
  19680. */
  19681. getTotalVertices(): number;
  19682. readonly sourceMesh: Mesh;
  19683. /**
  19684. * Is this node ready to be used/rendered
  19685. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19686. * @return {boolean} is it ready
  19687. */
  19688. isReady(completeCheck?: boolean): boolean;
  19689. /**
  19690. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19691. */
  19692. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19693. /**
  19694. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19695. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19696. * The `data` are either a numeric array either a Float32Array.
  19697. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19698. * 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).
  19699. * Note that a new underlying VertexBuffer object is created each call.
  19700. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19701. *
  19702. * Possible `kind` values :
  19703. * - BABYLON.VertexBuffer.PositionKind
  19704. * - BABYLON.VertexBuffer.UVKind
  19705. * - BABYLON.VertexBuffer.UV2Kind
  19706. * - BABYLON.VertexBuffer.UV3Kind
  19707. * - BABYLON.VertexBuffer.UV4Kind
  19708. * - BABYLON.VertexBuffer.UV5Kind
  19709. * - BABYLON.VertexBuffer.UV6Kind
  19710. * - BABYLON.VertexBuffer.ColorKind
  19711. * - BABYLON.VertexBuffer.MatricesIndicesKind
  19712. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19713. * - BABYLON.VertexBuffer.MatricesWeightsKind
  19714. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19715. *
  19716. * Returns the Mesh.
  19717. */
  19718. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19719. /**
  19720. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19721. * If the mesh has no geometry, it is simply returned as it is.
  19722. * The `data` are either a numeric array either a Float32Array.
  19723. * No new underlying VertexBuffer object is created.
  19724. * 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.
  19725. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19726. *
  19727. * Possible `kind` values :
  19728. * - BABYLON.VertexBuffer.PositionKind
  19729. * - BABYLON.VertexBuffer.UVKind
  19730. * - BABYLON.VertexBuffer.UV2Kind
  19731. * - BABYLON.VertexBuffer.UV3Kind
  19732. * - BABYLON.VertexBuffer.UV4Kind
  19733. * - BABYLON.VertexBuffer.UV5Kind
  19734. * - BABYLON.VertexBuffer.UV6Kind
  19735. * - BABYLON.VertexBuffer.ColorKind
  19736. * - BABYLON.VertexBuffer.MatricesIndicesKind
  19737. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  19738. * - BABYLON.VertexBuffer.MatricesWeightsKind
  19739. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  19740. *
  19741. * Returns the Mesh.
  19742. */
  19743. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19744. /**
  19745. * Sets the mesh indices.
  19746. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19747. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19748. * This method creates a new index buffer each call.
  19749. * Returns the Mesh.
  19750. */
  19751. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19752. /**
  19753. * Boolean : True if the mesh owns the requested kind of data.
  19754. */
  19755. isVerticesDataPresent(kind: string): boolean;
  19756. /**
  19757. * Returns an array of indices (IndicesArray).
  19758. */
  19759. getIndices(): Nullable<IndicesArray>;
  19760. readonly _positions: Nullable<Vector3[]>;
  19761. /**
  19762. * Sets a new updated BoundingInfo to the mesh.
  19763. * Returns the mesh.
  19764. */
  19765. refreshBoundingInfo(): InstancedMesh;
  19766. _preActivate(): InstancedMesh;
  19767. _activate(renderId: number): InstancedMesh;
  19768. /**
  19769. * Returns the current associated LOD AbstractMesh.
  19770. */
  19771. getLOD(camera: Camera): AbstractMesh;
  19772. _syncSubMeshes(): InstancedMesh;
  19773. _generatePointsArray(): boolean;
  19774. /**
  19775. * Creates a new InstancedMesh from the current mesh.
  19776. * - name (string) : the cloned mesh name
  19777. * - newParent (optional Node) : the optional Node to parent the clone to.
  19778. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19779. *
  19780. * Returns the clone.
  19781. */
  19782. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  19783. /**
  19784. * Disposes the InstancedMesh.
  19785. * Returns nothing.
  19786. */
  19787. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19788. }
  19789. }
  19790. declare module BABYLON {
  19791. class LinesMesh extends Mesh {
  19792. useVertexColor: boolean | undefined;
  19793. useVertexAlpha: boolean | undefined;
  19794. color: Color3;
  19795. alpha: number;
  19796. /**
  19797. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19798. * This margin is expressed in world space coordinates, so its value may vary.
  19799. * Default value is 0.1
  19800. * @returns the intersection Threshold value.
  19801. */
  19802. /**
  19803. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19804. * This margin is expressed in world space coordinates, so its value may vary.
  19805. * @param value the new threshold to apply
  19806. */
  19807. intersectionThreshold: number;
  19808. private _intersectionThreshold;
  19809. private _colorShader;
  19810. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  19811. /**
  19812. * Returns the string "LineMesh"
  19813. */
  19814. getClassName(): string;
  19815. material: Material;
  19816. readonly checkCollisions: boolean;
  19817. createInstance(name: string): InstancedMesh;
  19818. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19819. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19820. dispose(doNotRecurse?: boolean): void;
  19821. /**
  19822. * Returns a new LineMesh object cloned from the current one.
  19823. */
  19824. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19825. }
  19826. }
  19827. declare module BABYLON {
  19828. /**
  19829. * @hidden
  19830. **/
  19831. class _InstancesBatch {
  19832. mustReturn: boolean;
  19833. visibleInstances: Nullable<InstancedMesh[]>[];
  19834. renderSelf: boolean[];
  19835. }
  19836. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  19837. static _FRONTSIDE: number;
  19838. static _BACKSIDE: number;
  19839. static _DOUBLESIDE: number;
  19840. static _DEFAULTSIDE: number;
  19841. static _NO_CAP: number;
  19842. static _CAP_START: number;
  19843. static _CAP_END: number;
  19844. static _CAP_ALL: number;
  19845. /**
  19846. * Mesh side orientation : usually the external or front surface
  19847. */
  19848. static readonly FRONTSIDE: number;
  19849. /**
  19850. * Mesh side orientation : usually the internal or back surface
  19851. */
  19852. static readonly BACKSIDE: number;
  19853. /**
  19854. * Mesh side orientation : both internal and external or front and back surfaces
  19855. */
  19856. static readonly DOUBLESIDE: number;
  19857. /**
  19858. * Mesh side orientation : by default, `FRONTSIDE`
  19859. */
  19860. static readonly DEFAULTSIDE: number;
  19861. /**
  19862. * Mesh cap setting : no cap
  19863. */
  19864. static readonly NO_CAP: number;
  19865. /**
  19866. * Mesh cap setting : one cap at the beginning of the mesh
  19867. */
  19868. static readonly CAP_START: number;
  19869. /**
  19870. * Mesh cap setting : one cap at the end of the mesh
  19871. */
  19872. static readonly CAP_END: number;
  19873. /**
  19874. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  19875. */
  19876. static readonly CAP_ALL: number;
  19877. /**
  19878. * An event triggered before rendering the mesh
  19879. */
  19880. onBeforeRenderObservable: Observable<Mesh>;
  19881. /**
  19882. * An event triggered after rendering the mesh
  19883. */
  19884. onAfterRenderObservable: Observable<Mesh>;
  19885. /**
  19886. * An event triggered before drawing the mesh
  19887. */
  19888. onBeforeDrawObservable: Observable<Mesh>;
  19889. private _onBeforeDrawObserver;
  19890. onBeforeDraw: () => void;
  19891. delayLoadState: number;
  19892. instances: InstancedMesh[];
  19893. delayLoadingFile: string;
  19894. _binaryInfo: any;
  19895. private _LODLevels;
  19896. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  19897. private _morphTargetManager;
  19898. morphTargetManager: Nullable<MorphTargetManager>;
  19899. _geometry: Nullable<Geometry>;
  19900. _delayInfo: Array<string>;
  19901. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  19902. _visibleInstances: any;
  19903. private _renderIdForInstances;
  19904. private _batchCache;
  19905. private _instancesBufferSize;
  19906. private _instancesBuffer;
  19907. private _instancesData;
  19908. private _overridenInstanceCount;
  19909. private _effectiveMaterial;
  19910. _shouldGenerateFlatShading: boolean;
  19911. private _preActivateId;
  19912. _originalBuilderSideOrientation: number;
  19913. overrideMaterialSideOrientation: Nullable<number>;
  19914. private _areNormalsFrozen;
  19915. private _sourcePositions;
  19916. private _sourceNormals;
  19917. private _source;
  19918. readonly source: Nullable<Mesh>;
  19919. isUnIndexed: boolean;
  19920. /**
  19921. * @constructor
  19922. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  19923. * @param {Scene} scene The scene to add this mesh to.
  19924. * @param {Node} parent The parent of this mesh, if it has one
  19925. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  19926. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19927. * When false, achieved by calling a clone(), also passing False.
  19928. * This will make creation of children, recursive.
  19929. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  19930. */
  19931. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  19932. /**
  19933. * Returns the string "Mesh".
  19934. */
  19935. getClassName(): string;
  19936. /**
  19937. * Returns a string.
  19938. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  19939. */
  19940. toString(fullDetails?: boolean): string;
  19941. _unBindEffect(): void;
  19942. /**
  19943. * True if the mesh has some Levels Of Details (LOD).
  19944. * Returns a boolean.
  19945. */
  19946. readonly hasLODLevels: boolean;
  19947. /**
  19948. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  19949. * @returns an array of {BABYLON.MeshLODLevel}
  19950. */
  19951. getLODLevels(): MeshLODLevel[];
  19952. private _sortLODLevels();
  19953. /**
  19954. * Add a mesh as LOD level triggered at the given distance.
  19955. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  19956. * @param {number} distance The distance from the center of the object to show this level
  19957. * @param {Mesh} mesh The mesh to be added as LOD level
  19958. * @return {Mesh} This mesh (for chaining)
  19959. */
  19960. addLODLevel(distance: number, mesh: Mesh): Mesh;
  19961. /**
  19962. * Returns the LOD level mesh at the passed distance or null if not found.
  19963. * It is related to the method `addLODLevel(distance, mesh)`.
  19964. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  19965. * Returns an object Mesh or `null`.
  19966. */
  19967. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  19968. /**
  19969. * Remove a mesh from the LOD array
  19970. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  19971. * @param {Mesh} mesh The mesh to be removed.
  19972. * @return {Mesh} This mesh (for chaining)
  19973. */
  19974. removeLODLevel(mesh: Mesh): Mesh;
  19975. /**
  19976. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  19977. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  19978. */
  19979. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  19980. /**
  19981. * Returns the mesh internal Geometry object.
  19982. */
  19983. readonly geometry: Nullable<Geometry>;
  19984. /**
  19985. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  19986. */
  19987. getTotalVertices(): number;
  19988. /**
  19989. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  19990. * 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.
  19991. * You can force the copy with forceCopy === true
  19992. * Returns null if the mesh has no geometry or no vertex buffer.
  19993. * Possible `kind` values :
  19994. * - BABYLON.VertexBuffer.PositionKind
  19995. * - BABYLON.VertexBuffer.UVKind
  19996. * - BABYLON.VertexBuffer.UV2Kind
  19997. * - BABYLON.VertexBuffer.UV3Kind
  19998. * - BABYLON.VertexBuffer.UV4Kind
  19999. * - BABYLON.VertexBuffer.UV5Kind
  20000. * - BABYLON.VertexBuffer.UV6Kind
  20001. * - BABYLON.VertexBuffer.ColorKind
  20002. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20003. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20004. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20005. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20006. */
  20007. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20008. /**
  20009. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  20010. * Returns `null` if the mesh has no geometry.
  20011. * Possible `kind` values :
  20012. * - BABYLON.VertexBuffer.PositionKind
  20013. * - BABYLON.VertexBuffer.UVKind
  20014. * - BABYLON.VertexBuffer.UV2Kind
  20015. * - BABYLON.VertexBuffer.UV3Kind
  20016. * - BABYLON.VertexBuffer.UV4Kind
  20017. * - BABYLON.VertexBuffer.UV5Kind
  20018. * - BABYLON.VertexBuffer.UV6Kind
  20019. * - BABYLON.VertexBuffer.ColorKind
  20020. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20021. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20022. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20023. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20024. */
  20025. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20026. isVerticesDataPresent(kind: string): boolean;
  20027. /**
  20028. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20029. * Possible `kind` values :
  20030. * - BABYLON.VertexBuffer.PositionKind
  20031. * - BABYLON.VertexBuffer.UVKind
  20032. * - BABYLON.VertexBuffer.UV2Kind
  20033. * - BABYLON.VertexBuffer.UV3Kind
  20034. * - BABYLON.VertexBuffer.UV4Kind
  20035. * - BABYLON.VertexBuffer.UV5Kind
  20036. * - BABYLON.VertexBuffer.UV6Kind
  20037. * - BABYLON.VertexBuffer.ColorKind
  20038. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20039. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20040. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20041. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20042. */
  20043. isVertexBufferUpdatable(kind: string): boolean;
  20044. /**
  20045. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  20046. * Possible `kind` values :
  20047. * - BABYLON.VertexBuffer.PositionKind
  20048. * - BABYLON.VertexBuffer.UVKind
  20049. * - BABYLON.VertexBuffer.UV2Kind
  20050. * - BABYLON.VertexBuffer.UV3Kind
  20051. * - BABYLON.VertexBuffer.UV4Kind
  20052. * - BABYLON.VertexBuffer.UV5Kind
  20053. * - BABYLON.VertexBuffer.UV6Kind
  20054. * - BABYLON.VertexBuffer.ColorKind
  20055. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20056. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20057. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20058. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20059. */
  20060. getVerticesDataKinds(): string[];
  20061. /**
  20062. * Returns a positive integer : the total number of indices in this mesh geometry.
  20063. * Returns zero if the mesh has no geometry.
  20064. */
  20065. getTotalIndices(): number;
  20066. /**
  20067. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20068. * 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.
  20069. * Returns an empty array if the mesh has no geometry.
  20070. */
  20071. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  20072. readonly isBlocked: boolean;
  20073. /**
  20074. * Determine if the current mesh is ready to be rendered
  20075. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20076. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20077. * @returns true if all associated assets are ready (material, textures, shaders)
  20078. */
  20079. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20080. /**
  20081. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  20082. * This property is pertinent only for updatable parametric shapes.
  20083. */
  20084. readonly areNormalsFrozen: boolean;
  20085. /**
  20086. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  20087. * It has no effect at all on other shapes.
  20088. * It prevents the mesh normals from being recomputed on next `positions` array update.
  20089. * Returns the Mesh.
  20090. */
  20091. freezeNormals(): Mesh;
  20092. /**
  20093. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  20094. * It has no effect at all on other shapes.
  20095. * It reactivates the mesh normals computation if it was previously frozen.
  20096. * Returns the Mesh.
  20097. */
  20098. unfreezeNormals(): Mesh;
  20099. /**
  20100. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20101. */
  20102. overridenInstanceCount: number;
  20103. _preActivate(): Mesh;
  20104. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20105. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20106. /**
  20107. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20108. * This means the mesh underlying bounding box and sphere are recomputed.
  20109. * Returns the Mesh.
  20110. */
  20111. refreshBoundingInfo(): Mesh;
  20112. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  20113. private _getPositionData(applySkeleton);
  20114. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20115. subdivide(count: number): void;
  20116. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20117. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20118. /**
  20119. * Sets the mesh VertexBuffer.
  20120. * Returns the Mesh.
  20121. */
  20122. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20123. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20124. /**
  20125. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20126. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20127. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  20128. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  20129. * Returns the Mesh.
  20130. */
  20131. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20132. /**
  20133. * Creates a un-shared specific occurence of the geometry for the mesh.
  20134. * Returns the Mesh.
  20135. */
  20136. makeGeometryUnique(): Mesh;
  20137. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20138. /**
  20139. * Update the current index buffer
  20140. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  20141. * Returns the Mesh.
  20142. */
  20143. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20144. /**
  20145. * Invert the geometry to move from a right handed system to a left handed one.
  20146. * Returns the Mesh.
  20147. */
  20148. toLeftHanded(): Mesh;
  20149. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20150. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20151. /**
  20152. * Registers for this mesh a javascript function called just before the rendering process.
  20153. * This function is passed the current mesh.
  20154. * Return the Mesh.
  20155. */
  20156. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20157. /**
  20158. * Disposes a previously registered javascript function called before the rendering.
  20159. * This function is passed the current mesh.
  20160. * Returns the Mesh.
  20161. */
  20162. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20163. /**
  20164. * Registers for this mesh a javascript function called just after the rendering is complete.
  20165. * This function is passed the current mesh.
  20166. * Returns the Mesh.
  20167. */
  20168. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20169. /**
  20170. * Disposes a previously registered javascript function called after the rendering.
  20171. * This function is passed the current mesh.
  20172. * Return the Mesh.
  20173. */
  20174. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20175. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20176. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20177. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20178. /**
  20179. * Triggers the draw call for the mesh.
  20180. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  20181. * Returns the Mesh.
  20182. */
  20183. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20184. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  20185. /**
  20186. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  20187. */
  20188. getEmittedParticleSystems(): IParticleSystem[];
  20189. /**
  20190. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  20191. */
  20192. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  20193. _checkDelayState(): Mesh;
  20194. private _queueLoad(scene);
  20195. /**
  20196. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  20197. */
  20198. isInFrustum(frustumPlanes: Plane[]): boolean;
  20199. /**
  20200. * Sets the mesh material by the material or multiMaterial `id` property.
  20201. * The material `id` is a string identifying the material or the multiMaterial.
  20202. * This method returns the Mesh.
  20203. */
  20204. setMaterialByID(id: string): Mesh;
  20205. /**
  20206. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20207. */
  20208. getAnimatables(): IAnimatable[];
  20209. /**
  20210. * Modifies the mesh geometry according to the passed transformation matrix.
  20211. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20212. * The mesh normals are modified accordingly the same transformation.
  20213. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  20214. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20215. * Returns the Mesh.
  20216. */
  20217. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20218. /**
  20219. * Modifies the mesh geometry according to its own current World Matrix.
  20220. * The mesh World Matrix is then reset.
  20221. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20222. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  20223. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20224. * Returns the Mesh.
  20225. */
  20226. bakeCurrentTransformIntoVertices(): Mesh;
  20227. readonly _positions: Nullable<Vector3[]>;
  20228. _resetPointsArrayCache(): Mesh;
  20229. _generatePointsArray(): boolean;
  20230. /**
  20231. * Returns a new Mesh object generated from the current mesh properties.
  20232. * This method must not get confused with createInstance().
  20233. * The parameter `name` is a string, the name given to the new mesh.
  20234. * The optional parameter `newParent` can be any Node object (default `null`).
  20235. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  20236. * 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.
  20237. */
  20238. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20239. /**
  20240. * Releases resources associated with this mesh.
  20241. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20242. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20243. */
  20244. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20245. /**
  20246. * Modifies the mesh geometry according to a displacement map.
  20247. * 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.
  20248. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20249. * This method returns nothing.
  20250. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  20251. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  20252. * 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.
  20253. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  20254. * The parameter `uvScale` is an optional vector2 used to scale UV.
  20255. *
  20256. * Returns the Mesh.
  20257. */
  20258. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  20259. /**
  20260. * Modifies the mesh geometry according to a displacementMap buffer.
  20261. * 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.
  20262. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20263. * This method returns nothing.
  20264. * 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.
  20265. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  20266. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  20267. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  20268. * The parameter `uvScale` is an optional vector2 used to scale UV.
  20269. *
  20270. * Returns the Mesh.
  20271. */
  20272. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  20273. /**
  20274. * Modify the mesh to get a flat shading rendering.
  20275. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20276. * This method returns the Mesh.
  20277. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20278. */
  20279. convertToFlatShadedMesh(): Mesh;
  20280. /**
  20281. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20282. * In other words, more vertices, no more indices and a single bigger VBO.
  20283. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20284. * Returns the Mesh.
  20285. */
  20286. convertToUnIndexedMesh(): Mesh;
  20287. /**
  20288. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  20289. * This method returns the Mesh.
  20290. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20291. */
  20292. flipFaces(flipNormals?: boolean): Mesh;
  20293. /**
  20294. * Creates a new InstancedMesh object from the mesh model.
  20295. * An instance shares the same properties and the same material than its model.
  20296. * Only these properties of each instance can then be set individually :
  20297. * - position
  20298. * - rotation
  20299. * - rotationQuaternion
  20300. * - setPivotMatrix
  20301. * - scaling
  20302. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  20303. * Warning : this method is not supported for Line mesh and LineSystem
  20304. */
  20305. createInstance(name: string): InstancedMesh;
  20306. /**
  20307. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20308. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20309. * This method returns the Mesh.
  20310. */
  20311. synchronizeInstances(): Mesh;
  20312. /**
  20313. * Simplify the mesh according to the given array of settings.
  20314. * Function will return immediately and will simplify async. It returns the Mesh.
  20315. * @param settings a collection of simplification settings.
  20316. * @param parallelProcessing should all levels calculate parallel or one after the other.
  20317. * @param type the type of simplification to run.
  20318. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  20319. */
  20320. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  20321. /**
  20322. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20323. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20324. * This should be used together with the simplification to avoid disappearing triangles.
  20325. * Returns the Mesh.
  20326. * @param successCallback an optional success callback to be called after the optimization finished.
  20327. */
  20328. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20329. serialize(serializationObject: any): void;
  20330. _syncGeometryWithMorphTargetManager(): void;
  20331. /**
  20332. * Returns a new Mesh object parsed from the source provided.
  20333. * The parameter `parsedMesh` is the source.
  20334. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  20335. */
  20336. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20337. /**
  20338. * Creates a ribbon mesh.
  20339. * Please consider using the same method from the MeshBuilder class instead.
  20340. * 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.
  20341. *
  20342. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  20343. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20344. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  20345. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  20346. * 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.
  20347. * 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.
  20348. * 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
  20349. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20350. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20351. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20352. */
  20353. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20354. /**
  20355. * Creates a plane polygonal mesh. By default, this is a disc.
  20356. * Please consider using the same method from the MeshBuilder class instead.
  20357. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  20358. * 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.
  20359. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20360. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20361. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20362. */
  20363. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20364. /**
  20365. * Creates a box mesh.
  20366. * Please consider using the same method from the MeshBuilder class instead.
  20367. * The parameter `size` sets the size (float) of each box side (default 1).
  20368. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20369. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20370. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20371. */
  20372. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20373. /**
  20374. * Creates a sphere mesh.
  20375. * Please consider using the same method from the MeshBuilder class instead.
  20376. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  20377. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  20378. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20379. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20380. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20381. */
  20382. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20383. /**
  20384. * Creates a cylinder or a cone mesh.
  20385. * Please consider using the same method from the MeshBuilder class instead.
  20386. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  20387. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  20388. * 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.
  20389. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  20390. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  20391. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20392. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20393. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20394. */
  20395. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  20396. /**
  20397. * Creates a torus mesh.
  20398. * Please consider using the same method from the MeshBuilder class instead.
  20399. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  20400. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  20401. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  20402. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20403. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20404. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20405. */
  20406. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20407. /**
  20408. * Creates a torus knot mesh.
  20409. * Please consider using the same method from the MeshBuilder class instead.
  20410. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  20411. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  20412. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  20413. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  20414. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20415. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20416. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20417. */
  20418. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20419. /**
  20420. * Creates a line mesh.
  20421. * Please consider using the same method from the MeshBuilder class instead.
  20422. * 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.
  20423. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  20424. * The parameter `points` is an array successive Vector3.
  20425. * 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
  20426. * When updating an instance, remember that only point positions can change, not the number of points.
  20427. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20428. */
  20429. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  20430. /**
  20431. * Creates a dashed line mesh.
  20432. * Please consider using the same method from the MeshBuilder class instead.
  20433. * 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.
  20434. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  20435. * The parameter `points` is an array successive Vector3.
  20436. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  20437. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  20438. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  20439. * 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
  20440. * When updating an instance, remember that only point positions can change, not the number of points.
  20441. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20442. */
  20443. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  20444. /**
  20445. * Creates a polygon mesh.
  20446. * Please consider using the same method from the MeshBuilder class instead.
  20447. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  20448. * 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.
  20449. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20450. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20451. * Remember you can only change the shape positions, not their number when updating a polygon.
  20452. */
  20453. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  20454. /**
  20455. * Creates an extruded polygon mesh, with depth in the Y direction.
  20456. * Please consider using the same method from the MeshBuilder class instead.
  20457. */
  20458. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  20459. /**
  20460. * Creates an extruded shape mesh.
  20461. * 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.
  20462. * Please consider using the same method from the MeshBuilder class instead.
  20463. *
  20464. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20465. * 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
  20466. * extruded along the Z axis.
  20467. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  20468. * 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.
  20469. * The parameter `scale` (float, default 1) is the value to scale the shape.
  20470. * 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
  20471. * 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
  20472. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  20473. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20474. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20475. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20476. */
  20477. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20478. /**
  20479. * Creates an custom extruded shape mesh.
  20480. * 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.
  20481. * Please consider using the same method from the MeshBuilder class instead.
  20482. *
  20483. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20484. * 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
  20485. * extruded along the Z axis.
  20486. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  20487. * 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
  20488. * and the distance of this point from the begining of the path :
  20489. * ```javascript
  20490. * var rotationFunction = function(i, distance) {
  20491. * // do things
  20492. * return rotationValue; }
  20493. * ```
  20494. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  20495. * 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
  20496. * and the distance of this point from the begining of the path :
  20497. * ```javascript
  20498. * var scaleFunction = function(i, distance) {
  20499. * // do things
  20500. * return scaleValue;}
  20501. * ```
  20502. * It must returns a float value that will be the scale value applied to the shape on each path point.
  20503. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  20504. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  20505. * 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
  20506. * 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
  20507. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  20508. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20509. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20510. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20511. */
  20512. 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;
  20513. /**
  20514. * Creates lathe mesh.
  20515. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  20516. * Please consider using the same method from the MeshBuilder class instead.
  20517. * 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
  20518. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  20519. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  20520. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  20521. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20522. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20523. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20524. */
  20525. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20526. /**
  20527. * Creates a plane mesh.
  20528. * Please consider using the same method from the MeshBuilder class instead.
  20529. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  20530. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20531. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20532. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20533. */
  20534. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20535. /**
  20536. * Creates a ground mesh.
  20537. * Please consider using the same method from the MeshBuilder class instead.
  20538. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  20539. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  20540. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20541. */
  20542. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  20543. /**
  20544. * Creates a tiled ground mesh.
  20545. * Please consider using the same method from the MeshBuilder class instead.
  20546. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  20547. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  20548. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  20549. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  20550. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  20551. * numbers of subdivisions on the ground width and height of each tile.
  20552. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20553. */
  20554. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  20555. w: number;
  20556. h: number;
  20557. }, precision: {
  20558. w: number;
  20559. h: number;
  20560. }, scene: Scene, updatable?: boolean): Mesh;
  20561. /**
  20562. * Creates a ground mesh from a height map.
  20563. * tuto : http://doc.babylonjs.com/babylon101/height_map
  20564. * Please consider using the same method from the MeshBuilder class instead.
  20565. * The parameter `url` sets the URL of the height map image resource.
  20566. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  20567. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  20568. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  20569. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  20570. * 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).
  20571. * This function is passed the newly built mesh :
  20572. * ```javascript
  20573. * function(mesh) { // do things
  20574. * return; }
  20575. * ```
  20576. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20577. */
  20578. 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;
  20579. /**
  20580. * Creates a tube mesh.
  20581. * 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.
  20582. * Please consider using the same method from the MeshBuilder class instead.
  20583. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  20584. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  20585. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  20586. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  20587. * 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.
  20588. * It must return a radius value (positive float) :
  20589. * ```javascript
  20590. * var radiusFunction = function(i, distance) {
  20591. * // do things
  20592. * return radius; }
  20593. * ```
  20594. * 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
  20595. * 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
  20596. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20597. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20598. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20599. */
  20600. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  20601. (i: number, distance: number): number;
  20602. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20603. /**
  20604. * Creates a polyhedron mesh.
  20605. * Please consider using the same method from the MeshBuilder class instead.
  20606. * 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
  20607. * to choose the wanted type.
  20608. * The parameter `size` (positive float, default 1) sets the polygon size.
  20609. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  20610. * 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`.
  20611. * 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
  20612. * 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)`).
  20613. * 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
  20614. * 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.
  20615. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20616. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20617. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20618. */
  20619. static CreatePolyhedron(name: string, options: {
  20620. type?: number;
  20621. size?: number;
  20622. sizeX?: number;
  20623. sizeY?: number;
  20624. sizeZ?: number;
  20625. custom?: any;
  20626. faceUV?: Vector4[];
  20627. faceColors?: Color4[];
  20628. updatable?: boolean;
  20629. sideOrientation?: number;
  20630. }, scene: Scene): Mesh;
  20631. /**
  20632. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  20633. * Please consider using the same method from the MeshBuilder class instead.
  20634. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  20635. * 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`).
  20636. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  20637. * 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.
  20638. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20639. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20640. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20641. */
  20642. static CreateIcoSphere(name: string, options: {
  20643. radius?: number;
  20644. flat?: boolean;
  20645. subdivisions?: number;
  20646. sideOrientation?: number;
  20647. updatable?: boolean;
  20648. }, scene: Scene): Mesh;
  20649. /**
  20650. * Creates a decal mesh.
  20651. * Please consider using the same method from the MeshBuilder class instead.
  20652. * 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.
  20653. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  20654. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  20655. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  20656. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  20657. */
  20658. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  20659. /**
  20660. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20661. */
  20662. setPositionsForCPUSkinning(): Float32Array;
  20663. /**
  20664. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20665. */
  20666. setNormalsForCPUSkinning(): Float32Array;
  20667. /**
  20668. * Updates the vertex buffer by applying transformation from the bones.
  20669. * Returns the Mesh.
  20670. *
  20671. * @param {skeleton} skeleton to apply
  20672. */
  20673. applySkeleton(skeleton: Skeleton): Mesh;
  20674. /**
  20675. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  20676. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  20677. */
  20678. static MinMax(meshes: AbstractMesh[]): {
  20679. min: Vector3;
  20680. max: Vector3;
  20681. };
  20682. /**
  20683. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  20684. */
  20685. static Center(meshesOrMinMaxVector: {
  20686. min: Vector3;
  20687. max: Vector3;
  20688. } | AbstractMesh[]): Vector3;
  20689. /**
  20690. * Merge the array of meshes into a single mesh for performance reasons.
  20691. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  20692. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  20693. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  20694. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  20695. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  20696. */
  20697. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  20698. }
  20699. }
  20700. declare module BABYLON {
  20701. /**
  20702. * Define an interface for all classes that will get and set the data on vertices
  20703. */
  20704. interface IGetSetVerticesData {
  20705. isVerticesDataPresent(kind: string): boolean;
  20706. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20707. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  20708. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  20709. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  20710. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  20711. }
  20712. /**
  20713. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  20714. */
  20715. class VertexData {
  20716. /**
  20717. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  20718. */
  20719. positions: Nullable<FloatArray>;
  20720. /**
  20721. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  20722. */
  20723. normals: Nullable<FloatArray>;
  20724. /**
  20725. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  20726. */
  20727. tangents: Nullable<FloatArray>;
  20728. /**
  20729. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20730. */
  20731. uvs: Nullable<FloatArray>;
  20732. /**
  20733. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20734. */
  20735. uvs2: Nullable<FloatArray>;
  20736. /**
  20737. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20738. */
  20739. uvs3: Nullable<FloatArray>;
  20740. /**
  20741. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20742. */
  20743. uvs4: Nullable<FloatArray>;
  20744. /**
  20745. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20746. */
  20747. uvs5: Nullable<FloatArray>;
  20748. /**
  20749. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20750. */
  20751. uvs6: Nullable<FloatArray>;
  20752. /**
  20753. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  20754. */
  20755. colors: Nullable<FloatArray>;
  20756. /**
  20757. * 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).
  20758. */
  20759. matricesIndices: Nullable<FloatArray>;
  20760. /**
  20761. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  20762. */
  20763. matricesWeights: Nullable<FloatArray>;
  20764. /**
  20765. * An array extending the number of possible indices
  20766. */
  20767. matricesIndicesExtra: Nullable<FloatArray>;
  20768. /**
  20769. * An array extending the number of possible weights when the number of indices is extended
  20770. */
  20771. matricesWeightsExtra: Nullable<FloatArray>;
  20772. /**
  20773. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  20774. */
  20775. indices: Nullable<IndicesArray>;
  20776. /**
  20777. * Uses the passed data array to set the set the values for the specified kind of data
  20778. * @param data a linear array of floating numbers
  20779. * @param kind the type of data that is being set, eg positions, colors etc
  20780. */
  20781. set(data: FloatArray, kind: string): void;
  20782. /**
  20783. * Associates the vertexData to the passed Mesh.
  20784. * Sets it as updatable or not (default `false`)
  20785. * @param mesh the mesh the vertexData is applied to
  20786. * @param updatable when used and having the value true allows new data to update the vertexData
  20787. * @returns the VertexData
  20788. */
  20789. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  20790. /**
  20791. * Associates the vertexData to the passed Geometry.
  20792. * Sets it as updatable or not (default `false`)
  20793. * @param geometry the geometry the vertexData is applied to
  20794. * @param updatable when used and having the value true allows new data to update the vertexData
  20795. * @returns VertexData
  20796. */
  20797. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  20798. /**
  20799. * Updates the associated mesh
  20800. * @param mesh the mesh to be updated
  20801. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  20802. * @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
  20803. * @returns VertexData
  20804. */
  20805. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  20806. /**
  20807. * Updates the associated geometry
  20808. * @param geometry the geometry to be updated
  20809. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  20810. * @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
  20811. * @returns VertexData.
  20812. */
  20813. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  20814. private _applyTo(meshOrGeometry, updatable?);
  20815. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  20816. /**
  20817. * Transforms each position and each normal of the vertexData according to the passed Matrix
  20818. * @param matrix the transforming matrix
  20819. * @returns the VertexData
  20820. */
  20821. transform(matrix: Matrix): VertexData;
  20822. /**
  20823. * Merges the passed VertexData into the current one
  20824. * @param other the VertexData to be merged into the current one
  20825. * @returns the modified VertexData
  20826. */
  20827. merge(other: VertexData): VertexData;
  20828. private _mergeElement(source, other);
  20829. private _validate();
  20830. /**
  20831. * Serializes the VertexData
  20832. * @returns a serialized object
  20833. */
  20834. serialize(): any;
  20835. /**
  20836. * Extracts the vertexData from a mesh
  20837. * @param mesh the mesh from which to extract the VertexData
  20838. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  20839. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  20840. * @returns the object VertexData associated to the passed mesh
  20841. */
  20842. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  20843. /**
  20844. * Extracts the vertexData from the geometry
  20845. * @param geometry the geometry from which to extract the VertexData
  20846. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  20847. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  20848. * @returns the object VertexData associated to the passed mesh
  20849. */
  20850. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  20851. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  20852. /**
  20853. * Creates the VertexData for a Ribbon
  20854. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  20855. * * pathArray array of paths, each of which an array of successive Vector3
  20856. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  20857. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  20858. * * 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
  20859. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20860. * * 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)
  20861. * * 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)
  20862. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  20863. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  20864. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  20865. * @returns the VertexData of the ribbon
  20866. */
  20867. static CreateRibbon(options: {
  20868. pathArray: Vector3[][];
  20869. closeArray?: boolean;
  20870. closePath?: boolean;
  20871. offset?: number;
  20872. sideOrientation?: number;
  20873. frontUVs?: Vector4;
  20874. backUVs?: Vector4;
  20875. invertUV?: boolean;
  20876. uvs?: Vector2[];
  20877. colors?: Color4[];
  20878. }): VertexData;
  20879. /**
  20880. * Creates the VertexData for a box
  20881. * @param options an object used to set the following optional parameters for the box, required but can be empty
  20882. * * size sets the width, height and depth of the box to the value of size, optional default 1
  20883. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  20884. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  20885. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  20886. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  20887. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  20888. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20889. * * 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)
  20890. * * 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)
  20891. * @returns the VertexData of the box
  20892. */
  20893. static CreateBox(options: {
  20894. size?: number;
  20895. width?: number;
  20896. height?: number;
  20897. depth?: number;
  20898. faceUV?: Vector4[];
  20899. faceColors?: Color4[];
  20900. sideOrientation?: number;
  20901. frontUVs?: Vector4;
  20902. backUVs?: Vector4;
  20903. }): VertexData;
  20904. /**
  20905. * Creates the VertexData for an ellipsoid, defaults to a sphere
  20906. * @param options an object used to set the following optional parameters for the box, required but can be empty
  20907. * * segments sets the number of horizontal strips optional, default 32
  20908. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  20909. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  20910. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  20911. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  20912. * * 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
  20913. * * 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
  20914. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20915. * * 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)
  20916. * * 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)
  20917. * @returns the VertexData of the ellipsoid
  20918. */
  20919. static CreateSphere(options: {
  20920. segments?: number;
  20921. diameter?: number;
  20922. diameterX?: number;
  20923. diameterY?: number;
  20924. diameterZ?: number;
  20925. arc?: number;
  20926. slice?: number;
  20927. sideOrientation?: number;
  20928. frontUVs?: Vector4;
  20929. backUVs?: Vector4;
  20930. }): VertexData;
  20931. /**
  20932. * Creates the VertexData for a cylinder, cone or prism
  20933. * @param options an object used to set the following optional parameters for the box, required but can be empty
  20934. * * height sets the height (y direction) of the cylinder, optional, default 2
  20935. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  20936. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  20937. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  20938. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  20939. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  20940. * * 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
  20941. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  20942. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  20943. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  20944. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  20945. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20946. * * 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)
  20947. * * 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)
  20948. * @returns the VertexData of the cylinder, cone or prism
  20949. */
  20950. static CreateCylinder(options: {
  20951. height?: number;
  20952. diameterTop?: number;
  20953. diameterBottom?: number;
  20954. diameter?: number;
  20955. tessellation?: number;
  20956. subdivisions?: number;
  20957. arc?: number;
  20958. faceColors?: Color4[];
  20959. faceUV?: Vector4[];
  20960. hasRings?: boolean;
  20961. enclose?: boolean;
  20962. sideOrientation?: number;
  20963. frontUVs?: Vector4;
  20964. backUVs?: Vector4;
  20965. }): VertexData;
  20966. /**
  20967. * Creates the VertexData for a torus
  20968. * @param options an object used to set the following optional parameters for the box, required but can be empty
  20969. * * diameter the diameter of the torus, optional default 1
  20970. * * thickness the diameter of the tube forming the torus, optional default 0.5
  20971. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  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 torus
  20976. */
  20977. static CreateTorus(options: {
  20978. diameter?: number;
  20979. thickness?: number;
  20980. tessellation?: number;
  20981. sideOrientation?: number;
  20982. frontUVs?: Vector4;
  20983. backUVs?: Vector4;
  20984. }): VertexData;
  20985. /**
  20986. * Creates the VertexData of the LineSystem
  20987. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  20988. * - lines an array of lines, each line being an array of successive Vector3
  20989. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  20990. * @returns the VertexData of the LineSystem
  20991. */
  20992. static CreateLineSystem(options: {
  20993. lines: Vector3[][];
  20994. colors?: Nullable<Color4[][]>;
  20995. }): VertexData;
  20996. /**
  20997. * Create the VertexData for a DashedLines
  20998. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  20999. * - points an array successive Vector3
  21000. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21001. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21002. * - dashNb the intended total number of dashes, optional, default 200
  21003. * @returns the VertexData for the DashedLines
  21004. */
  21005. static CreateDashedLines(options: {
  21006. points: Vector3[];
  21007. dashSize?: number;
  21008. gapSize?: number;
  21009. dashNb?: number;
  21010. }): VertexData;
  21011. /**
  21012. * Creates the VertexData for a Ground
  21013. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21014. * - width the width (x direction) of the ground, optional, default 1
  21015. * - height the height (z direction) of the ground, optional, default 1
  21016. * - subdivisions the number of subdivisions per side, optional, default 1
  21017. * @returns the VertexData of the Ground
  21018. */
  21019. static CreateGround(options: {
  21020. width?: number;
  21021. height?: number;
  21022. subdivisions?: number;
  21023. subdivisionsX?: number;
  21024. subdivisionsY?: number;
  21025. }): VertexData;
  21026. /**
  21027. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21028. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21029. * * xmin the ground minimum X coordinate, optional, default -1
  21030. * * zmin the ground minimum Z coordinate, optional, default -1
  21031. * * xmax the ground maximum X coordinate, optional, default 1
  21032. * * zmax the ground maximum Z coordinate, optional, default 1
  21033. * * 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}
  21034. * * 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}
  21035. * @returns the VertexData of the TiledGround
  21036. */
  21037. static CreateTiledGround(options: {
  21038. xmin: number;
  21039. zmin: number;
  21040. xmax: number;
  21041. zmax: number;
  21042. subdivisions?: {
  21043. w: number;
  21044. h: number;
  21045. };
  21046. precision?: {
  21047. w: number;
  21048. h: number;
  21049. };
  21050. }): VertexData;
  21051. /**
  21052. * Creates the VertexData of the Ground designed from a heightmap
  21053. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21054. * * width the width (x direction) of the ground
  21055. * * height the height (z direction) of the ground
  21056. * * subdivisions the number of subdivisions per side
  21057. * * minHeight the minimum altitude on the ground, optional, default 0
  21058. * * maxHeight the maximum altitude on the ground, optional default 1
  21059. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21060. * * buffer the array holding the image color data
  21061. * * bufferWidth the width of image
  21062. * * bufferHeight the height of image
  21063. * @returns the VertexData of the Ground designed from a heightmap
  21064. */
  21065. static CreateGroundFromHeightMap(options: {
  21066. width: number;
  21067. height: number;
  21068. subdivisions: number;
  21069. minHeight: number;
  21070. maxHeight: number;
  21071. colorFilter: Color3;
  21072. buffer: Uint8Array;
  21073. bufferWidth: number;
  21074. bufferHeight: number;
  21075. }): VertexData;
  21076. /**
  21077. * Creates the VertexData for a Plane
  21078. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21079. * * size sets the width and height of the plane to the value of size, optional default 1
  21080. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21081. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21082. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21083. * * 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)
  21084. * * 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)
  21085. * @returns the VertexData of the box
  21086. */
  21087. static CreatePlane(options: {
  21088. size?: number;
  21089. width?: number;
  21090. height?: number;
  21091. sideOrientation?: number;
  21092. frontUVs?: Vector4;
  21093. backUVs?: Vector4;
  21094. }): VertexData;
  21095. /**
  21096. * Creates the VertexData of the Disc or regular Polygon
  21097. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21098. * * radius the radius of the disc, optional default 0.5
  21099. * * tessellation the number of polygon sides, optional, default 64
  21100. * * 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
  21101. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21102. * * 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)
  21103. * * 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)
  21104. * @returns the VertexData of the box
  21105. */
  21106. static CreateDisc(options: {
  21107. radius?: number;
  21108. tessellation?: number;
  21109. arc?: number;
  21110. sideOrientation?: number;
  21111. frontUVs?: Vector4;
  21112. backUVs?: Vector4;
  21113. }): VertexData;
  21114. /**
  21115. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21116. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21117. * @param polygon a mesh built from polygonTriangulation.build()
  21118. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21119. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21120. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21121. * @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)
  21122. * @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)
  21123. * @returns the VertexData of the Polygon
  21124. */
  21125. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21126. /**
  21127. * Creates the VertexData of the IcoSphere
  21128. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21129. * * radius the radius of the IcoSphere, optional default 1
  21130. * * radiusX allows stretching in the x direction, optional, default radius
  21131. * * radiusY allows stretching in the y direction, optional, default radius
  21132. * * radiusZ allows stretching in the z direction, optional, default radius
  21133. * * flat when true creates a flat shaded mesh, optional, default true
  21134. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21135. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21136. * * 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)
  21137. * * 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)
  21138. * @returns the VertexData of the IcoSphere
  21139. */
  21140. static CreateIcoSphere(options: {
  21141. radius?: number;
  21142. radiusX?: number;
  21143. radiusY?: number;
  21144. radiusZ?: number;
  21145. flat?: boolean;
  21146. subdivisions?: number;
  21147. sideOrientation?: number;
  21148. frontUVs?: Vector4;
  21149. backUVs?: Vector4;
  21150. }): VertexData;
  21151. /**
  21152. * Creates the VertexData for a Polyhedron
  21153. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21154. * * type provided types are:
  21155. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21156. * * 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)
  21157. * * size the size of the IcoSphere, optional default 1
  21158. * * sizeX allows stretching in the x direction, optional, default size
  21159. * * sizeY allows stretching in the y direction, optional, default size
  21160. * * sizeZ allows stretching in the z direction, optional, default size
  21161. * * 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
  21162. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21163. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21164. * * flat when true creates a flat shaded mesh, optional, default true
  21165. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21166. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21167. * * 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)
  21168. * * 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)
  21169. * @returns the VertexData of the Polyhedron
  21170. */
  21171. static CreatePolyhedron(options: {
  21172. type?: number;
  21173. size?: number;
  21174. sizeX?: number;
  21175. sizeY?: number;
  21176. sizeZ?: number;
  21177. custom?: any;
  21178. faceUV?: Vector4[];
  21179. faceColors?: Color4[];
  21180. flat?: boolean;
  21181. sideOrientation?: number;
  21182. frontUVs?: Vector4;
  21183. backUVs?: Vector4;
  21184. }): VertexData;
  21185. /**
  21186. * Creates the VertexData for a TorusKnot
  21187. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21188. * * radius the radius of the torus knot, optional, default 2
  21189. * * tube the thickness of the tube, optional, default 0.5
  21190. * * radialSegments the number of sides on each tube segments, optional, default 32
  21191. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21192. * * p the number of windings around the z axis, optional, default 2
  21193. * * q the number of windings around the x axis, optional, default 3
  21194. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21195. * * 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)
  21196. * * 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)
  21197. * @returns the VertexData of the Torus Knot
  21198. */
  21199. static CreateTorusKnot(options: {
  21200. radius?: number;
  21201. tube?: number;
  21202. radialSegments?: number;
  21203. tubularSegments?: number;
  21204. p?: number;
  21205. q?: number;
  21206. sideOrientation?: number;
  21207. frontUVs?: Vector4;
  21208. backUVs?: Vector4;
  21209. }): VertexData;
  21210. /**
  21211. * Compute normals for given positions and indices
  21212. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21213. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21214. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21215. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21216. * * facetNormals : optional array of facet normals (vector3)
  21217. * * facetPositions : optional array of facet positions (vector3)
  21218. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21219. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21220. * * bInfo : optional bounding info, required for facetPartitioning computation
  21221. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21222. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21223. * * useRightHandedSystem: optional boolean to for right handed system computation
  21224. * * depthSort : optional boolean to enable the facet depth sort computation
  21225. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21226. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21227. */
  21228. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21229. facetNormals?: any;
  21230. facetPositions?: any;
  21231. facetPartitioning?: any;
  21232. ratio?: number;
  21233. bInfo?: any;
  21234. bbSize?: Vector3;
  21235. subDiv?: any;
  21236. useRightHandedSystem?: boolean;
  21237. depthSort?: boolean;
  21238. distanceTo?: Vector3;
  21239. depthSortedFacets?: any;
  21240. }): void;
  21241. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  21242. /**
  21243. * Applies VertexData created from the imported parameters to the geometry
  21244. * @param parsedVertexData the parsed data from an imported file
  21245. * @param geometry the geometry to apply the VertexData to
  21246. */
  21247. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21248. }
  21249. }
  21250. declare module BABYLON {
  21251. /**
  21252. * Class containing static functions to help procedurally build meshes
  21253. */
  21254. class MeshBuilder {
  21255. private static updateSideOrientation(orientation?);
  21256. /**
  21257. * Creates a box mesh
  21258. * * The parameter `size` sets the size (float) of each box side (default 1)
  21259. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  21260. * * 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)
  21261. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  21262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21263. * * 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
  21264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21265. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  21266. * @param name defines the name of the mesh
  21267. * @param options defines the options used to create the mesh
  21268. * @param scene defines the hosting scene
  21269. * @returns the box mesh
  21270. */
  21271. static CreateBox(name: string, options: {
  21272. size?: number;
  21273. width?: number;
  21274. height?: number;
  21275. depth?: number;
  21276. faceUV?: Vector4[];
  21277. faceColors?: Color4[];
  21278. sideOrientation?: number;
  21279. frontUVs?: Vector4;
  21280. backUVs?: Vector4;
  21281. updatable?: boolean;
  21282. }, scene?: Nullable<Scene>): Mesh;
  21283. /**
  21284. * Creates a sphere mesh
  21285. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  21286. * * 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`)
  21287. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  21288. * * 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
  21289. * * 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)
  21290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21291. * * 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
  21292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21293. * @param name defines the name of the mesh
  21294. * @param options defines the options used to create the mesh
  21295. * @param scene defines the hosting scene
  21296. * @returns the sphere mesh
  21297. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  21298. */
  21299. static CreateSphere(name: string, options: {
  21300. segments?: number;
  21301. diameter?: number;
  21302. diameterX?: number;
  21303. diameterY?: number;
  21304. diameterZ?: number;
  21305. arc?: number;
  21306. slice?: number;
  21307. sideOrientation?: number;
  21308. frontUVs?: Vector4;
  21309. backUVs?: Vector4;
  21310. updatable?: boolean;
  21311. }, scene: any): Mesh;
  21312. /**
  21313. * Creates a plane polygonal mesh. By default, this is a disc
  21314. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  21315. * * 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
  21316. * * 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
  21317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21318. * * 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
  21319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21320. * @param name defines the name of the mesh
  21321. * @param options defines the options used to create the mesh
  21322. * @param scene defines the hosting scene
  21323. * @returns the plane polygonal mesh
  21324. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  21325. */
  21326. static CreateDisc(name: string, options: {
  21327. radius?: number;
  21328. tessellation?: number;
  21329. arc?: number;
  21330. updatable?: boolean;
  21331. sideOrientation?: number;
  21332. frontUVs?: Vector4;
  21333. backUVs?: Vector4;
  21334. }, scene?: Nullable<Scene>): Mesh;
  21335. /**
  21336. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21337. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21338. * * 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`)
  21339. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21340. * * 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
  21341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21342. * * 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
  21343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21344. * @param name defines the name of the mesh
  21345. * @param options defines the options used to create the mesh
  21346. * @param scene defines the hosting scene
  21347. * @returns the icosahedron mesh
  21348. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21349. */
  21350. static CreateIcoSphere(name: string, options: {
  21351. radius?: number;
  21352. radiusX?: number;
  21353. radiusY?: number;
  21354. radiusZ?: number;
  21355. flat?: boolean;
  21356. subdivisions?: number;
  21357. sideOrientation?: number;
  21358. frontUVs?: Vector4;
  21359. backUVs?: Vector4;
  21360. updatable?: boolean;
  21361. }, scene: Scene): Mesh;
  21362. /**
  21363. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  21364. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  21365. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  21366. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  21367. * * 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
  21368. * * 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
  21369. * * 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
  21370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21371. * * 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
  21372. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  21373. * * 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
  21374. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  21375. * * 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
  21376. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  21377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21378. * @param name defines the name of the mesh
  21379. * @param options defines the options used to create the mesh
  21380. * @param scene defines the hosting scene
  21381. * @returns the ribbon mesh
  21382. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21383. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  21384. */
  21385. static CreateRibbon(name: string, options: {
  21386. pathArray: Vector3[][];
  21387. closeArray?: boolean;
  21388. closePath?: boolean;
  21389. offset?: number;
  21390. updatable?: boolean;
  21391. sideOrientation?: number;
  21392. frontUVs?: Vector4;
  21393. backUVs?: Vector4;
  21394. instance?: Mesh;
  21395. invertUV?: boolean;
  21396. uvs?: Vector2[];
  21397. colors?: Color4[];
  21398. }, scene?: Nullable<Scene>): Mesh;
  21399. /**
  21400. * Creates a cylinder or a cone mesh
  21401. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21402. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21403. * * 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.
  21404. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21405. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21406. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  21407. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  21408. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  21409. * * 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).
  21410. * * 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
  21411. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  21412. * * 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
  21413. * * 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.
  21414. * * If `enclose` is false, a ring surface is one element.
  21415. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  21416. * * 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
  21417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21418. * * 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
  21419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21420. * @param name defines the name of the mesh
  21421. * @param options defines the options used to create the mesh
  21422. * @param scene defines the hosting scene
  21423. * @returns the cylinder mesh
  21424. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  21425. */
  21426. static CreateCylinder(name: string, options: {
  21427. height?: number;
  21428. diameterTop?: number;
  21429. diameterBottom?: number;
  21430. diameter?: number;
  21431. tessellation?: number;
  21432. subdivisions?: number;
  21433. arc?: number;
  21434. faceColors?: Color4[];
  21435. faceUV?: Vector4[];
  21436. updatable?: boolean;
  21437. hasRings?: boolean;
  21438. enclose?: boolean;
  21439. sideOrientation?: number;
  21440. frontUVs?: Vector4;
  21441. backUVs?: Vector4;
  21442. }, scene: any): Mesh;
  21443. /**
  21444. * Creates a torus mesh
  21445. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  21446. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  21447. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  21448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21449. * * 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
  21450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21451. * @param name defines the name of the mesh
  21452. * @param options defines the options used to create the mesh
  21453. * @param scene defines the hosting scene
  21454. * @returns the torus mesh
  21455. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  21456. */
  21457. static CreateTorus(name: string, options: {
  21458. diameter?: number;
  21459. thickness?: number;
  21460. tessellation?: number;
  21461. updatable?: boolean;
  21462. sideOrientation?: number;
  21463. frontUVs?: Vector4;
  21464. backUVs?: Vector4;
  21465. }, scene: any): Mesh;
  21466. /**
  21467. * Creates a torus knot mesh
  21468. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  21469. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  21470. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  21471. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  21472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21473. * * 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
  21474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21475. * @param name defines the name of the mesh
  21476. * @param options defines the options used to create the mesh
  21477. * @param scene defines the hosting scene
  21478. * @returns the torus knot mesh
  21479. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  21480. */
  21481. static CreateTorusKnot(name: string, options: {
  21482. radius?: number;
  21483. tube?: number;
  21484. radialSegments?: number;
  21485. tubularSegments?: number;
  21486. p?: number;
  21487. q?: number;
  21488. updatable?: boolean;
  21489. sideOrientation?: number;
  21490. frontUVs?: Vector4;
  21491. backUVs?: Vector4;
  21492. }, scene: any): Mesh;
  21493. /**
  21494. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  21495. * * 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
  21496. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  21497. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  21498. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  21499. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  21500. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  21501. * * 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
  21502. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  21503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21504. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  21505. * @param name defines the name of the new line system
  21506. * @param options defines the options used to create the line system
  21507. * @param scene defines the hosting scene
  21508. * @returns a new line system mesh
  21509. */
  21510. static CreateLineSystem(name: string, options: {
  21511. lines: Vector3[][];
  21512. updatable?: boolean;
  21513. instance?: Nullable<LinesMesh>;
  21514. colors?: Nullable<Color4[][]>;
  21515. useVertexAlpha?: boolean;
  21516. }, scene: Nullable<Scene>): LinesMesh;
  21517. /**
  21518. * Creates a line mesh
  21519. * 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
  21520. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  21521. * * The parameter `points` is an array successive Vector3
  21522. * * 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
  21523. * * The optional parameter `colors` is an array of successive Color4, one per line point
  21524. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  21525. * * When updating an instance, remember that only point positions can change, not the number of points
  21526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21527. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  21528. * @param name defines the name of the new line system
  21529. * @param options defines the options used to create the line system
  21530. * @param scene defines the hosting scene
  21531. * @returns a new line mesh
  21532. */
  21533. static CreateLines(name: string, options: {
  21534. points: Vector3[];
  21535. updatable?: boolean;
  21536. instance?: Nullable<LinesMesh>;
  21537. colors?: Color4[];
  21538. useVertexAlpha?: boolean;
  21539. }, scene?: Nullable<Scene>): LinesMesh;
  21540. /**
  21541. * Creates a dashed line mesh
  21542. * * 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
  21543. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  21544. * * The parameter `points` is an array successive Vector3
  21545. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  21546. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  21547. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21548. * * 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
  21549. * * When updating an instance, remember that only point positions can change, not the number of points
  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 dashed line mesh
  21555. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  21556. */
  21557. static CreateDashedLines(name: string, options: {
  21558. points: Vector3[];
  21559. dashSize?: number;
  21560. gapSize?: number;
  21561. dashNb?: number;
  21562. updatable?: boolean;
  21563. instance?: LinesMesh;
  21564. }, scene?: Nullable<Scene>): LinesMesh;
  21565. /**
  21566. * 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.
  21567. * * 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.
  21568. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21569. * * 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.
  21570. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  21571. * * 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
  21572. * * 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
  21573. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21575. * * 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
  21576. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  21577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21578. * @param name defines the name of the mesh
  21579. * @param options defines the options used to create the mesh
  21580. * @param scene defines the hosting scene
  21581. * @returns the extruded shape mesh
  21582. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  21583. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21584. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21585. */
  21586. static ExtrudeShape(name: string, options: {
  21587. shape: Vector3[];
  21588. path: Vector3[];
  21589. scale?: number;
  21590. rotation?: number;
  21591. cap?: number;
  21592. updatable?: boolean;
  21593. sideOrientation?: number;
  21594. frontUVs?: Vector4;
  21595. backUVs?: Vector4;
  21596. instance?: Mesh;
  21597. invertUV?: boolean;
  21598. }, scene?: Nullable<Scene>): Mesh;
  21599. /**
  21600. * Creates an custom extruded shape mesh.
  21601. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  21602. * * 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.
  21603. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21604. * * 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
  21605. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  21606. * * 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
  21607. * * It must returns a float value that will be the scale value applied to the shape on each path point
  21608. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21609. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  21610. * * 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
  21611. * * 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
  21612. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  21613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21614. * * 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
  21615. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  21616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21617. * @param name defines the name of the mesh
  21618. * @param options defines the options used to create the mesh
  21619. * @param scene defines the hosting scene
  21620. * @returns the custom extruded shape mesh
  21621. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  21622. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  21623. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21624. */
  21625. static ExtrudeShapeCustom(name: string, options: {
  21626. shape: Vector3[];
  21627. path: Vector3[];
  21628. scaleFunction?: any;
  21629. rotationFunction?: any;
  21630. ribbonCloseArray?: boolean;
  21631. ribbonClosePath?: boolean;
  21632. cap?: number;
  21633. updatable?: boolean;
  21634. sideOrientation?: number;
  21635. frontUVs?: Vector4;
  21636. backUVs?: Vector4;
  21637. instance?: Mesh;
  21638. invertUV?: boolean;
  21639. }, scene: Scene): Mesh;
  21640. /**
  21641. * Creates lathe mesh.
  21642. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  21643. * * 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
  21644. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  21645. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  21646. * * 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
  21647. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  21648. * * 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
  21649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21650. * * 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
  21651. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  21652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21653. * @param name defines the name of the mesh
  21654. * @param options defines the options used to create the mesh
  21655. * @param scene defines the hosting scene
  21656. * @returns the lathe mesh
  21657. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  21658. */
  21659. static CreateLathe(name: string, options: {
  21660. shape: Vector3[];
  21661. radius?: number;
  21662. tessellation?: number;
  21663. arc?: number;
  21664. closed?: boolean;
  21665. updatable?: boolean;
  21666. sideOrientation?: number;
  21667. frontUVs?: Vector4;
  21668. backUVs?: Vector4;
  21669. cap?: number;
  21670. invertUV?: boolean;
  21671. }, scene: Scene): Mesh;
  21672. /**
  21673. * Creates a plane mesh
  21674. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  21675. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  21676. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  21677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21678. * * 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
  21679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21680. * @param name defines the name of the mesh
  21681. * @param options defines the options used to create the mesh
  21682. * @param scene defines the hosting scene
  21683. * @returns the plane mesh
  21684. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  21685. */
  21686. static CreatePlane(name: string, options: {
  21687. size?: number;
  21688. width?: number;
  21689. height?: number;
  21690. sideOrientation?: number;
  21691. frontUVs?: Vector4;
  21692. backUVs?: Vector4;
  21693. updatable?: boolean;
  21694. sourcePlane?: Plane;
  21695. }, scene: Scene): Mesh;
  21696. /**
  21697. * Creates a ground mesh
  21698. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  21699. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  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 ground mesh
  21705. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  21706. */
  21707. static CreateGround(name: string, options: {
  21708. width?: number;
  21709. height?: number;
  21710. subdivisions?: number;
  21711. subdivisionsX?: number;
  21712. subdivisionsY?: number;
  21713. updatable?: boolean;
  21714. }, scene: any): Mesh;
  21715. /**
  21716. * Creates a tiled ground mesh
  21717. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  21718. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  21719. * * 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
  21720. * * 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
  21721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21722. * @param name defines the name of the mesh
  21723. * @param options defines the options used to create the mesh
  21724. * @param scene defines the hosting scene
  21725. * @returns the tiled ground mesh
  21726. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  21727. */
  21728. static CreateTiledGround(name: string, options: {
  21729. xmin: number;
  21730. zmin: number;
  21731. xmax: number;
  21732. zmax: number;
  21733. subdivisions?: {
  21734. w: number;
  21735. h: number;
  21736. };
  21737. precision?: {
  21738. w: number;
  21739. h: number;
  21740. };
  21741. updatable?: boolean;
  21742. }, scene: Scene): Mesh;
  21743. /**
  21744. * Creates a ground mesh from a height map
  21745. * * The parameter `url` sets the URL of the height map image resource.
  21746. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  21747. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  21748. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  21749. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  21750. * * 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.
  21751. * * 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).
  21752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21753. * @param name defines the name of the mesh
  21754. * @param url defines the url to the height map
  21755. * @param options defines the options used to create the mesh
  21756. * @param scene defines the hosting scene
  21757. * @returns the ground mesh
  21758. * @see http://doc.babylonjs.com/babylon101/height_map
  21759. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  21760. */
  21761. static CreateGroundFromHeightMap(name: string, url: string, options: {
  21762. width?: number;
  21763. height?: number;
  21764. subdivisions?: number;
  21765. minHeight?: number;
  21766. maxHeight?: number;
  21767. colorFilter?: Color3;
  21768. updatable?: boolean;
  21769. onReady?: (mesh: GroundMesh) => void;
  21770. }, scene: Scene): GroundMesh;
  21771. /**
  21772. * Creates a polygon mesh
  21773. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  21774. * * 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
  21775. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21777. * * 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)
  21778. * * Remember you can only change the shape positions, not their number when updating a polygon
  21779. * @param name defines the name of the mesh
  21780. * @param options defines the options used to create the mesh
  21781. * @param scene defines the hosting scene
  21782. * @returns the polygon mesh
  21783. */
  21784. static CreatePolygon(name: string, options: {
  21785. shape: Vector3[];
  21786. holes?: Vector3[][];
  21787. depth?: number;
  21788. faceUV?: Vector4[];
  21789. faceColors?: Color4[];
  21790. updatable?: boolean;
  21791. sideOrientation?: number;
  21792. frontUVs?: Vector4;
  21793. backUVs?: Vector4;
  21794. }, scene: Scene): Mesh;
  21795. /**
  21796. * Creates an extruded polygon mesh, with depth in the Y direction.
  21797. * * 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)
  21798. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  21799. * @param name defines the name of the mesh
  21800. * @param options defines the options used to create the mesh
  21801. * @param scene defines the hosting scene
  21802. * @returns the polygon mesh
  21803. */
  21804. static ExtrudePolygon(name: string, options: {
  21805. shape: Vector3[];
  21806. holes?: Vector3[][];
  21807. depth?: number;
  21808. faceUV?: Vector4[];
  21809. faceColors?: Color4[];
  21810. updatable?: boolean;
  21811. sideOrientation?: number;
  21812. frontUVs?: Vector4;
  21813. backUVs?: Vector4;
  21814. }, scene: Scene): Mesh;
  21815. /**
  21816. * Creates a tube mesh.
  21817. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  21818. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  21819. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  21820. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  21821. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  21822. * * 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)
  21823. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  21824. * * 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
  21825. * * 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
  21826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21827. * * 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
  21828. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  21829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21830. * @param name defines the name of the mesh
  21831. * @param options defines the options used to create the mesh
  21832. * @param scene defines the hosting scene
  21833. * @returns the tube mesh
  21834. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  21835. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  21836. */
  21837. static CreateTube(name: string, options: {
  21838. path: Vector3[];
  21839. radius?: number;
  21840. tessellation?: number;
  21841. radiusFunction?: {
  21842. (i: number, distance: number): number;
  21843. };
  21844. cap?: number;
  21845. arc?: number;
  21846. updatable?: boolean;
  21847. sideOrientation?: number;
  21848. frontUVs?: Vector4;
  21849. backUVs?: Vector4;
  21850. instance?: Mesh;
  21851. invertUV?: boolean;
  21852. }, scene: Scene): Mesh;
  21853. /**
  21854. * Creates a polyhedron mesh
  21855. * * 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
  21856. * * The parameter `size` (positive float, default 1) sets the polygon size
  21857. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21858. * * 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`
  21859. * * 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
  21860. * * 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)`)
  21861. * * 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
  21862. * * 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
  21863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21864. * * 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
  21865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21866. * @param name defines the name of the mesh
  21867. * @param options defines the options used to create the mesh
  21868. * @param scene defines the hosting scene
  21869. * @returns the polyhedron mesh
  21870. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  21871. */
  21872. static CreatePolyhedron(name: string, options: {
  21873. type?: number;
  21874. size?: number;
  21875. sizeX?: number;
  21876. sizeY?: number;
  21877. sizeZ?: number;
  21878. custom?: any;
  21879. faceUV?: Vector4[];
  21880. faceColors?: Color4[];
  21881. flat?: boolean;
  21882. updatable?: boolean;
  21883. sideOrientation?: number;
  21884. frontUVs?: Vector4;
  21885. backUVs?: Vector4;
  21886. }, scene: Scene): Mesh;
  21887. /**
  21888. * Creates a decal mesh.
  21889. * 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
  21890. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  21891. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  21892. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  21893. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  21894. * @param name defines the name of the mesh
  21895. * @param sourceMesh defines the mesh where the decal must be applied
  21896. * @param options defines the options used to create the mesh
  21897. * @param scene defines the hosting scene
  21898. * @returns the decal mesh
  21899. * @see http://doc.babylonjs.com/how_to/decals
  21900. */
  21901. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  21902. position?: Vector3;
  21903. normal?: Vector3;
  21904. size?: Vector3;
  21905. angle?: number;
  21906. }): Mesh;
  21907. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  21908. }
  21909. }
  21910. declare module BABYLON {
  21911. class MeshLODLevel {
  21912. distance: number;
  21913. mesh: Mesh;
  21914. constructor(distance: number, mesh: Mesh);
  21915. }
  21916. }
  21917. declare module BABYLON {
  21918. /**
  21919. * A simplifier interface for future simplification implementations.
  21920. */
  21921. interface ISimplifier {
  21922. /**
  21923. * Simplification of a given mesh according to the given settings.
  21924. * Since this requires computation, it is assumed that the function runs async.
  21925. * @param settings The settings of the simplification, including quality and distance
  21926. * @param successCallback A callback that will be called after the mesh was simplified.
  21927. * @param errorCallback in case of an error, this callback will be called. optional.
  21928. */
  21929. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  21930. }
  21931. /**
  21932. * Expected simplification settings.
  21933. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  21934. */
  21935. interface ISimplificationSettings {
  21936. quality: number;
  21937. distance: number;
  21938. optimizeMesh?: boolean;
  21939. }
  21940. class SimplificationSettings implements ISimplificationSettings {
  21941. quality: number;
  21942. distance: number;
  21943. optimizeMesh: boolean | undefined;
  21944. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  21945. }
  21946. interface ISimplificationTask {
  21947. settings: Array<ISimplificationSettings>;
  21948. simplificationType: SimplificationType;
  21949. mesh: Mesh;
  21950. successCallback?: () => void;
  21951. parallelProcessing: boolean;
  21952. }
  21953. class SimplificationQueue {
  21954. private _simplificationArray;
  21955. running: boolean;
  21956. constructor();
  21957. addTask(task: ISimplificationTask): void;
  21958. executeNext(): void;
  21959. runSimplification(task: ISimplificationTask): void;
  21960. private getSimplifier(task);
  21961. }
  21962. /**
  21963. * The implemented types of simplification
  21964. * At the moment only Quadratic Error Decimation is implemented
  21965. */
  21966. enum SimplificationType {
  21967. /** Quadratic error decimation */
  21968. QUADRATIC = 0,
  21969. }
  21970. class DecimationTriangle {
  21971. vertices: Array<DecimationVertex>;
  21972. normal: Vector3;
  21973. error: Array<number>;
  21974. deleted: boolean;
  21975. isDirty: boolean;
  21976. borderFactor: number;
  21977. deletePending: boolean;
  21978. originalOffset: number;
  21979. constructor(vertices: Array<DecimationVertex>);
  21980. }
  21981. class DecimationVertex {
  21982. position: Vector3;
  21983. id: number;
  21984. q: QuadraticMatrix;
  21985. isBorder: boolean;
  21986. triangleStart: number;
  21987. triangleCount: number;
  21988. originalOffsets: Array<number>;
  21989. constructor(position: Vector3, id: number);
  21990. updatePosition(newPosition: Vector3): void;
  21991. }
  21992. class QuadraticMatrix {
  21993. data: Array<number>;
  21994. constructor(data?: Array<number>);
  21995. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  21996. addInPlace(matrix: QuadraticMatrix): void;
  21997. addArrayInPlace(data: Array<number>): void;
  21998. add(matrix: QuadraticMatrix): QuadraticMatrix;
  21999. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  22000. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  22001. }
  22002. class Reference {
  22003. vertexId: number;
  22004. triangleId: number;
  22005. constructor(vertexId: number, triangleId: number);
  22006. }
  22007. /**
  22008. * An implementation of the Quadratic Error simplification algorithm.
  22009. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  22010. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  22011. * @author RaananW
  22012. */
  22013. class QuadraticErrorSimplification implements ISimplifier {
  22014. private _mesh;
  22015. private triangles;
  22016. private vertices;
  22017. private references;
  22018. private _reconstructedMesh;
  22019. syncIterations: number;
  22020. aggressiveness: number;
  22021. decimationIterations: number;
  22022. boundingBoxEpsilon: number;
  22023. constructor(_mesh: Mesh);
  22024. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  22025. private runDecimation(settings, submeshIndex, successCallback);
  22026. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  22027. private init(callback);
  22028. private reconstructMesh(submeshIndex);
  22029. private initDecimatedMesh();
  22030. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  22031. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  22032. private identifyBorder();
  22033. private updateMesh(identifyBorders?);
  22034. private vertexError(q, point);
  22035. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  22036. }
  22037. }
  22038. declare module BABYLON {
  22039. class Polygon {
  22040. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  22041. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  22042. static Parse(input: string): Vector2[];
  22043. static StartingAt(x: number, y: number): Path2;
  22044. }
  22045. class PolygonMeshBuilder {
  22046. private _points;
  22047. private _outlinepoints;
  22048. private _holes;
  22049. private _name;
  22050. private _scene;
  22051. private _epoints;
  22052. private _eholes;
  22053. private _addToepoint(points);
  22054. constructor(name: string, contours: Path2, scene: Scene);
  22055. constructor(name: string, contours: Vector2[], scene: Scene);
  22056. addHole(hole: Vector2[]): PolygonMeshBuilder;
  22057. build(updatable?: boolean, depth?: number): Mesh;
  22058. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  22059. }
  22060. }
  22061. declare module BABYLON {
  22062. class BaseSubMesh {
  22063. _materialDefines: Nullable<MaterialDefines>;
  22064. _materialEffect: Nullable<Effect>;
  22065. readonly effect: Nullable<Effect>;
  22066. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22067. }
  22068. class SubMesh extends BaseSubMesh implements ICullable {
  22069. materialIndex: number;
  22070. verticesStart: number;
  22071. verticesCount: number;
  22072. indexStart: number;
  22073. indexCount: number;
  22074. linesIndexCount: number;
  22075. private _mesh;
  22076. private _renderingMesh;
  22077. private _boundingInfo;
  22078. private _linesIndexBuffer;
  22079. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22080. _trianglePlanes: Plane[];
  22081. _lastColliderTransformMatrix: Matrix;
  22082. _renderId: number;
  22083. _alphaIndex: number;
  22084. _distanceToCamera: number;
  22085. _id: number;
  22086. private _currentMaterial;
  22087. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22088. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22089. readonly IsGlobal: boolean;
  22090. /**
  22091. * Returns the submesh BoudingInfo object.
  22092. */
  22093. getBoundingInfo(): BoundingInfo;
  22094. /**
  22095. * Sets the submesh BoundingInfo.
  22096. * Return the SubMesh.
  22097. */
  22098. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22099. /**
  22100. * Returns the mesh of the current submesh.
  22101. */
  22102. getMesh(): AbstractMesh;
  22103. /**
  22104. * Returns the rendering mesh of the submesh.
  22105. */
  22106. getRenderingMesh(): Mesh;
  22107. /**
  22108. * Returns the submesh material.
  22109. */
  22110. getMaterial(): Nullable<Material>;
  22111. /**
  22112. * Sets a new updated BoundingInfo object to the submesh.
  22113. * Returns the SubMesh.
  22114. */
  22115. refreshBoundingInfo(): SubMesh;
  22116. _checkCollision(collider: Collider): boolean;
  22117. /**
  22118. * Updates the submesh BoundingInfo.
  22119. * Returns the Submesh.
  22120. */
  22121. updateBoundingInfo(world: Matrix): SubMesh;
  22122. /**
  22123. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22124. * Boolean returned.
  22125. */
  22126. isInFrustum(frustumPlanes: Plane[]): boolean;
  22127. /**
  22128. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  22129. * Boolean returned.
  22130. */
  22131. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22132. /**
  22133. * Renders the submesh.
  22134. * Returns it.
  22135. */
  22136. render(enableAlphaMode: boolean): SubMesh;
  22137. /**
  22138. * Returns a new Index Buffer.
  22139. * Type returned : WebGLBuffer.
  22140. */
  22141. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22142. /**
  22143. * True is the passed Ray intersects the submesh bounding box.
  22144. * Boolean returned.
  22145. */
  22146. canIntersects(ray: Ray): boolean;
  22147. /**
  22148. * Returns an object IntersectionInfo.
  22149. */
  22150. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  22151. _rebuild(): void;
  22152. /**
  22153. * Creates a new Submesh from the passed Mesh.
  22154. */
  22155. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22156. /**
  22157. * Disposes the Submesh.
  22158. * Returns nothing.
  22159. */
  22160. dispose(): void;
  22161. /**
  22162. * Creates a new Submesh from the passed parameters :
  22163. * - materialIndex (integer) : the index of the main mesh material.
  22164. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  22165. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  22166. * - mesh (Mesh) : the main mesh to create the submesh from.
  22167. * - renderingMesh (optional Mesh) : rendering mesh.
  22168. */
  22169. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22170. }
  22171. }
  22172. declare module BABYLON {
  22173. class TransformNode extends Node {
  22174. static BILLBOARDMODE_NONE: number;
  22175. static BILLBOARDMODE_X: number;
  22176. static BILLBOARDMODE_Y: number;
  22177. static BILLBOARDMODE_Z: number;
  22178. static BILLBOARDMODE_ALL: number;
  22179. private _forward;
  22180. private _forwardInverted;
  22181. private _up;
  22182. private _right;
  22183. private _rightInverted;
  22184. private _rotation;
  22185. private _rotationQuaternion;
  22186. protected _scaling: Vector3;
  22187. protected _isDirty: boolean;
  22188. private _transformToBoneReferal;
  22189. billboardMode: number;
  22190. scalingDeterminant: number;
  22191. infiniteDistance: boolean;
  22192. position: Vector3;
  22193. _poseMatrix: Matrix;
  22194. private _localWorld;
  22195. _worldMatrix: Matrix;
  22196. _worldMatrixDeterminant: number;
  22197. private _absolutePosition;
  22198. private _pivotMatrix;
  22199. private _pivotMatrixInverse;
  22200. private _postMultiplyPivotMatrix;
  22201. protected _isWorldMatrixFrozen: boolean;
  22202. /**
  22203. * An event triggered after the world matrix is updated
  22204. */
  22205. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  22206. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  22207. /**
  22208. * Gets a string idenfifying the name of the class
  22209. * @returns "TransformNode" string
  22210. */
  22211. getClassName(): string;
  22212. /**
  22213. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  22214. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  22215. * Default : (0.0, 0.0, 0.0)
  22216. */
  22217. rotation: Vector3;
  22218. /**
  22219. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  22220. * Default : (1.0, 1.0, 1.0)
  22221. */
  22222. /**
  22223. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  22224. * Default : (1.0, 1.0, 1.0)
  22225. */
  22226. scaling: Vector3;
  22227. /**
  22228. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  22229. * It's null by default.
  22230. * 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)
  22231. */
  22232. rotationQuaternion: Nullable<Quaternion>;
  22233. /**
  22234. * The forward direction of that transform in world space.
  22235. */
  22236. readonly forward: Vector3;
  22237. /**
  22238. * The up direction of that transform in world space.
  22239. */
  22240. readonly up: Vector3;
  22241. /**
  22242. * The right direction of that transform in world space.
  22243. */
  22244. readonly right: Vector3;
  22245. /**
  22246. * Returns the latest update of the World matrix
  22247. * Returns a Matrix.
  22248. */
  22249. getWorldMatrix(): Matrix;
  22250. /** @hidden */
  22251. _getWorldMatrixDeterminant(): number;
  22252. /**
  22253. * Returns directly the latest state of the mesh World matrix.
  22254. * A Matrix is returned.
  22255. */
  22256. readonly worldMatrixFromCache: Matrix;
  22257. /**
  22258. * Copies the paramater passed Matrix into the mesh Pose matrix.
  22259. * Returns the TransformNode.
  22260. */
  22261. updatePoseMatrix(matrix: Matrix): TransformNode;
  22262. /**
  22263. * Returns the mesh Pose matrix.
  22264. * Returned object : Matrix
  22265. */
  22266. getPoseMatrix(): Matrix;
  22267. _isSynchronized(): boolean;
  22268. _initCache(): void;
  22269. markAsDirty(property: string): TransformNode;
  22270. /**
  22271. * Returns the current mesh absolute position.
  22272. * Retuns a Vector3.
  22273. */
  22274. readonly absolutePosition: Vector3;
  22275. /**
  22276. * Sets a new matrix to apply before all other transformation
  22277. * @param matrix defines the transform matrix
  22278. * @returns the current TransformNode
  22279. */
  22280. setPreTransformMatrix(matrix: Matrix): TransformNode;
  22281. /**
  22282. * Sets a new pivot matrix to the current node
  22283. * @param matrix defines the new pivot matrix to use
  22284. * @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
  22285. * @returns the current TransformNode
  22286. */
  22287. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  22288. /**
  22289. * Returns the mesh pivot matrix.
  22290. * Default : Identity.
  22291. * A Matrix is returned.
  22292. */
  22293. getPivotMatrix(): Matrix;
  22294. /**
  22295. * Prevents the World matrix to be computed any longer.
  22296. * Returns the TransformNode.
  22297. */
  22298. freezeWorldMatrix(): TransformNode;
  22299. /**
  22300. * Allows back the World matrix computation.
  22301. * Returns the TransformNode.
  22302. */
  22303. unfreezeWorldMatrix(): this;
  22304. /**
  22305. * True if the World matrix has been frozen.
  22306. * Returns a boolean.
  22307. */
  22308. readonly isWorldMatrixFrozen: boolean;
  22309. /**
  22310. * Retuns the mesh absolute position in the World.
  22311. * Returns a Vector3.
  22312. */
  22313. getAbsolutePosition(): Vector3;
  22314. /**
  22315. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  22316. * Returns the TransformNode.
  22317. */
  22318. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22319. /**
  22320. * Sets the mesh position in its local space.
  22321. * Returns the TransformNode.
  22322. */
  22323. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  22324. /**
  22325. * Returns the mesh position in the local space from the current World matrix values.
  22326. * Returns a new Vector3.
  22327. */
  22328. getPositionExpressedInLocalSpace(): Vector3;
  22329. /**
  22330. * Translates the mesh along the passed Vector3 in its local space.
  22331. * Returns the TransformNode.
  22332. */
  22333. locallyTranslate(vector3: Vector3): TransformNode;
  22334. private static _lookAtVectorCache;
  22335. /**
  22336. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  22337. * @param targetPoint the position (must be in same space as current mesh) to look at
  22338. * @param yawCor optional yaw (y-axis) correction in radians
  22339. * @param pitchCor optional pitch (x-axis) correction in radians
  22340. * @param rollCor optional roll (z-axis) correction in radians
  22341. * @param space the choosen space of the target
  22342. * @returns the TransformNode.
  22343. */
  22344. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  22345. /**
  22346. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  22347. * This Vector3 is expressed in the World space.
  22348. */
  22349. getDirection(localAxis: Vector3): Vector3;
  22350. /**
  22351. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  22352. * localAxis is expressed in the mesh local space.
  22353. * result is computed in the Wordl space from the mesh World matrix.
  22354. * Returns the TransformNode.
  22355. */
  22356. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  22357. /**
  22358. * Sets a new pivot point to the current node
  22359. * @param point defines the new pivot point to use
  22360. * @param space defines if the point is in world or local space (local by default)
  22361. * @returns the current TransformNode
  22362. */
  22363. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  22364. /**
  22365. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  22366. */
  22367. getPivotPoint(): Vector3;
  22368. /**
  22369. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  22370. * Returns the TransformNode.
  22371. */
  22372. getPivotPointToRef(result: Vector3): TransformNode;
  22373. /**
  22374. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  22375. */
  22376. getAbsolutePivotPoint(): Vector3;
  22377. /**
  22378. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  22379. * Returns the TransformNode.
  22380. */
  22381. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  22382. /**
  22383. * Defines the passed node as the parent of the current node.
  22384. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  22385. * Returns the TransformNode.
  22386. */
  22387. setParent(node: Nullable<Node>): TransformNode;
  22388. private _nonUniformScaling;
  22389. readonly nonUniformScaling: boolean;
  22390. _updateNonUniformScalingState(value: boolean): boolean;
  22391. /**
  22392. * Attach the current TransformNode to another TransformNode associated with a bone
  22393. * @param bone Bone affecting the TransformNode
  22394. * @param affectedTransformNode TransformNode associated with the bone
  22395. */
  22396. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  22397. detachFromBone(): TransformNode;
  22398. private static _rotationAxisCache;
  22399. /**
  22400. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  22401. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  22402. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  22403. * The passed axis is also normalized.
  22404. * Returns the TransformNode.
  22405. */
  22406. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22407. /**
  22408. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  22409. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  22410. * The passed axis is also normalized.
  22411. * Returns the TransformNode.
  22412. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  22413. */
  22414. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  22415. /**
  22416. * Translates the mesh along the axis vector for the passed distance in the given space.
  22417. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  22418. * Returns the TransformNode.
  22419. */
  22420. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22421. /**
  22422. * Adds a rotation step to the mesh current rotation.
  22423. * x, y, z are Euler angles expressed in radians.
  22424. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  22425. * This means this rotation is made in the mesh local space only.
  22426. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  22427. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  22428. * ```javascript
  22429. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  22430. * ```
  22431. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  22432. * 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.
  22433. * Returns the TransformNode.
  22434. */
  22435. addRotation(x: number, y: number, z: number): TransformNode;
  22436. /**
  22437. * Computes the mesh World matrix and returns it.
  22438. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  22439. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  22440. * If the parameter `force`is set to `true`, the actual computation is done.
  22441. * Returns the mesh World Matrix.
  22442. */
  22443. computeWorldMatrix(force?: boolean): Matrix;
  22444. protected _afterComputeWorldMatrix(): void;
  22445. /**
  22446. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  22447. * @param func: callback function to add
  22448. *
  22449. * Returns the TransformNode.
  22450. */
  22451. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  22452. /**
  22453. * Removes a registered callback function.
  22454. * Returns the TransformNode.
  22455. */
  22456. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  22457. /**
  22458. * Clone the current transform node
  22459. * Returns the new transform node
  22460. * @param name Name of the new clone
  22461. * @param newParent New parent for the clone
  22462. * @param doNotCloneChildren Do not clone children hierarchy
  22463. */
  22464. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  22465. serialize(currentSerializationObject?: any): any;
  22466. /**
  22467. * Returns a new TransformNode object parsed from the source provided.
  22468. * The parameter `parsedMesh` is the source.
  22469. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  22470. */
  22471. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  22472. /**
  22473. * Releases resources associated with this transform node.
  22474. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22475. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22476. */
  22477. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22478. }
  22479. }
  22480. declare module BABYLON {
  22481. class VertexBuffer {
  22482. private _buffer;
  22483. private _kind;
  22484. private _size;
  22485. private _ownsBuffer;
  22486. private _instanced;
  22487. private _instanceDivisor;
  22488. /**
  22489. * The byte type.
  22490. */
  22491. static readonly BYTE: number;
  22492. /**
  22493. * The unsigned byte type.
  22494. */
  22495. static readonly UNSIGNED_BYTE: number;
  22496. /**
  22497. * The short type.
  22498. */
  22499. static readonly SHORT: number;
  22500. /**
  22501. * The unsigned short type.
  22502. */
  22503. static readonly UNSIGNED_SHORT: number;
  22504. /**
  22505. * The integer type.
  22506. */
  22507. static readonly INT: number;
  22508. /**
  22509. * The unsigned integer type.
  22510. */
  22511. static readonly UNSIGNED_INT: number;
  22512. /**
  22513. * The float type.
  22514. */
  22515. static readonly FLOAT: number;
  22516. /**
  22517. * Gets or sets the instance divisor when in instanced mode
  22518. */
  22519. instanceDivisor: number;
  22520. /**
  22521. * Gets the byte stride.
  22522. */
  22523. readonly byteStride: number;
  22524. /**
  22525. * Gets the byte offset.
  22526. */
  22527. readonly byteOffset: number;
  22528. /**
  22529. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  22530. */
  22531. readonly normalized: boolean;
  22532. /**
  22533. * Gets the data type of each component in the array.
  22534. */
  22535. readonly type: number;
  22536. /**
  22537. * Constructor
  22538. * @param engine the engine
  22539. * @param data the data to use for this vertex buffer
  22540. * @param kind the vertex buffer kind
  22541. * @param updatable whether the data is updatable
  22542. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  22543. * @param stride the stride (optional)
  22544. * @param instanced whether the buffer is instanced (optional)
  22545. * @param offset the offset of the data (optional)
  22546. * @param size the number of components (optional)
  22547. * @param type the type of the component (optional)
  22548. * @param normalized whether the data contains normalized data (optional)
  22549. * @param useBytes set to true if stride and offset are in bytes (optional)
  22550. */
  22551. 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);
  22552. _rebuild(): void;
  22553. /**
  22554. * Returns the kind of the VertexBuffer (string).
  22555. */
  22556. getKind(): string;
  22557. /**
  22558. * Boolean : is the VertexBuffer updatable ?
  22559. */
  22560. isUpdatable(): boolean;
  22561. /**
  22562. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  22563. */
  22564. getData(): Nullable<DataArray>;
  22565. /**
  22566. * Returns the WebGLBuffer associated to the VertexBuffer.
  22567. */
  22568. getBuffer(): Nullable<WebGLBuffer>;
  22569. /**
  22570. * Returns the stride as a multiple of the type byte length.
  22571. * DEPRECATED. Use byteStride instead.
  22572. */
  22573. getStrideSize(): number;
  22574. /**
  22575. * Returns the offset as a multiple of the type byte length.
  22576. * DEPRECATED. Use byteOffset instead.
  22577. */
  22578. getOffset(): number;
  22579. /**
  22580. * Returns the number of components per vertex attribute (integer).
  22581. */
  22582. getSize(): number;
  22583. /**
  22584. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  22585. */
  22586. getIsInstanced(): boolean;
  22587. /**
  22588. * Returns the instancing divisor, zero for non-instanced (integer).
  22589. */
  22590. getInstanceDivisor(): number;
  22591. /**
  22592. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  22593. * Returns the created WebGLBuffer.
  22594. */
  22595. create(data?: DataArray): void;
  22596. /**
  22597. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  22598. * This function will create a new buffer if the current one is not updatable
  22599. * Returns the updated WebGLBuffer.
  22600. */
  22601. update(data: DataArray): void;
  22602. /**
  22603. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  22604. * Returns the directly updated WebGLBuffer.
  22605. * @param data the new data
  22606. * @param offset the new offset
  22607. * @param useBytes set to true if the offset is in bytes
  22608. */
  22609. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  22610. /**
  22611. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  22612. */
  22613. dispose(): void;
  22614. /**
  22615. * Enumerates each value of this vertex buffer as numbers.
  22616. * @param count the number of values to enumerate
  22617. * @param callback the callback function called for each value
  22618. */
  22619. forEach(count: number, callback: (value: number, index: number) => void): void;
  22620. private static _PositionKind;
  22621. private static _NormalKind;
  22622. private static _TangentKind;
  22623. private static _UVKind;
  22624. private static _UV2Kind;
  22625. private static _UV3Kind;
  22626. private static _UV4Kind;
  22627. private static _UV5Kind;
  22628. private static _UV6Kind;
  22629. private static _ColorKind;
  22630. private static _MatricesIndicesKind;
  22631. private static _MatricesWeightsKind;
  22632. private static _MatricesIndicesExtraKind;
  22633. private static _MatricesWeightsExtraKind;
  22634. static readonly PositionKind: string;
  22635. static readonly NormalKind: string;
  22636. static readonly TangentKind: string;
  22637. static readonly UVKind: string;
  22638. static readonly UV2Kind: string;
  22639. static readonly UV3Kind: string;
  22640. static readonly UV4Kind: string;
  22641. static readonly UV5Kind: string;
  22642. static readonly UV6Kind: string;
  22643. static readonly ColorKind: string;
  22644. static readonly MatricesIndicesKind: string;
  22645. static readonly MatricesWeightsKind: string;
  22646. static readonly MatricesIndicesExtraKind: string;
  22647. static readonly MatricesWeightsExtraKind: string;
  22648. /**
  22649. * Deduces the stride given a kind.
  22650. * @param kind The kind string to deduce
  22651. * @returns The deduced stride
  22652. */
  22653. static DeduceStride(kind: string): number;
  22654. /**
  22655. * Gets the byte length of the given type.
  22656. * @param type the type
  22657. * @returns the number of bytes
  22658. */
  22659. static GetTypeByteLength(type: number): number;
  22660. /**
  22661. * Enumerates each value of the given parameters as numbers.
  22662. * @param data the data to enumerate
  22663. * @param byteOffset the byte offset of the data
  22664. * @param byteStride the byte stride of the data
  22665. * @param componentCount the number of components per element
  22666. * @param componentType the type of the component
  22667. * @param count the total number of components
  22668. * @param normalized whether the data is normalized
  22669. * @param callback the callback function called for each value
  22670. */
  22671. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  22672. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  22673. }
  22674. }
  22675. declare module BABYLON {
  22676. /**
  22677. * This represents a GPU particle system in Babylon
  22678. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  22679. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  22680. */
  22681. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  22682. /**
  22683. * The id of the Particle system.
  22684. */
  22685. id: string;
  22686. /**
  22687. * The friendly name of the Particle system.
  22688. */
  22689. name: string;
  22690. /**
  22691. * The emitter represents the Mesh or position we are attaching the particle system to.
  22692. */
  22693. emitter: Nullable<AbstractMesh | Vector3>;
  22694. /**
  22695. * The rendering group used by the Particle system to chose when to render.
  22696. */
  22697. renderingGroupId: number;
  22698. /**
  22699. * The layer mask we are rendering the particles through.
  22700. */
  22701. layerMask: number;
  22702. private _capacity;
  22703. private _activeCount;
  22704. private _currentActiveCount;
  22705. private _renderEffect;
  22706. private _updateEffect;
  22707. private _buffer0;
  22708. private _buffer1;
  22709. private _spriteBuffer;
  22710. private _updateVAO;
  22711. private _renderVAO;
  22712. private _targetIndex;
  22713. private _sourceBuffer;
  22714. private _targetBuffer;
  22715. private _scene;
  22716. private _engine;
  22717. private _currentRenderId;
  22718. private _started;
  22719. private _stopped;
  22720. private _timeDelta;
  22721. private _randomTexture;
  22722. private readonly _attributesStrideSize;
  22723. private _updateEffectOptions;
  22724. private _randomTextureSize;
  22725. private _actualFrame;
  22726. /**
  22727. * List of animations used by the particle system.
  22728. */
  22729. animations: Animation[];
  22730. /**
  22731. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  22732. */
  22733. static readonly IsSupported: boolean;
  22734. /**
  22735. * An event triggered when the system is disposed.
  22736. */
  22737. onDisposeObservable: Observable<GPUParticleSystem>;
  22738. /**
  22739. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  22740. */
  22741. updateSpeed: number;
  22742. /**
  22743. * The amount of time the particle system is running (depends of the overall update speed).
  22744. */
  22745. targetStopDuration: number;
  22746. /**
  22747. * The texture used to render each particle. (this can be a spritesheet)
  22748. */
  22749. particleTexture: Nullable<Texture>;
  22750. /**
  22751. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  22752. */
  22753. blendMode: number;
  22754. /**
  22755. * Minimum life time of emitting particles.
  22756. */
  22757. minLifeTime: number;
  22758. /**
  22759. * Maximum life time of emitting particles.
  22760. */
  22761. maxLifeTime: number;
  22762. /**
  22763. * Minimum Size of emitting particles.
  22764. */
  22765. minSize: number;
  22766. /**
  22767. * Maximum Size of emitting particles.
  22768. */
  22769. maxSize: number;
  22770. /**
  22771. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  22772. */
  22773. color1: Color4;
  22774. /**
  22775. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  22776. */
  22777. color2: Color4;
  22778. /**
  22779. * Color the particle will have at the end of its lifetime.
  22780. */
  22781. colorDead: Color4;
  22782. /**
  22783. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  22784. */
  22785. emitRate: number;
  22786. /**
  22787. * You can use gravity if you want to give an orientation to your particles.
  22788. */
  22789. gravity: Vector3;
  22790. /**
  22791. * Minimum power of emitting particles.
  22792. */
  22793. minEmitPower: number;
  22794. /**
  22795. * Maximum power of emitting particles.
  22796. */
  22797. maxEmitPower: number;
  22798. /**
  22799. * The particle emitter type defines the emitter used by the particle system.
  22800. * It can be for example box, sphere, or cone...
  22801. */
  22802. particleEmitterType: Nullable<IParticleEmitterType>;
  22803. /**
  22804. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  22805. * This only works when particleEmitterTyps is a BoxParticleEmitter
  22806. */
  22807. direction1: Vector3;
  22808. /**
  22809. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  22810. * This only works when particleEmitterTyps is a BoxParticleEmitter
  22811. */
  22812. direction2: Vector3;
  22813. /**
  22814. * 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.
  22815. * This only works when particleEmitterTyps is a BoxParticleEmitter
  22816. */
  22817. minEmitBox: Vector3;
  22818. /**
  22819. * 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.
  22820. * This only works when particleEmitterTyps is a BoxParticleEmitter
  22821. */
  22822. maxEmitBox: Vector3;
  22823. /**
  22824. * Gets the maximum number of particles active at the same time.
  22825. * @returns The max number of active particles.
  22826. */
  22827. getCapacity(): number;
  22828. /**
  22829. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  22830. * to override the particles.
  22831. */
  22832. forceDepthWrite: boolean;
  22833. /**
  22834. * Gets or set the number of active particles
  22835. */
  22836. activeParticleCount: number;
  22837. /**
  22838. * Is this system ready to be used/rendered
  22839. * @return true if the system is ready
  22840. */
  22841. isReady(): boolean;
  22842. /**
  22843. * Gets Wether the system has been started.
  22844. * @returns True if it has been started, otherwise false.
  22845. */
  22846. isStarted(): boolean;
  22847. /**
  22848. * Starts the particle system and begins to emit.
  22849. */
  22850. start(): void;
  22851. /**
  22852. * Stops the particle system.
  22853. */
  22854. stop(): void;
  22855. /**
  22856. * Remove all active particles
  22857. */
  22858. reset(): void;
  22859. /**
  22860. * Returns the string "GPUParticleSystem"
  22861. * @returns a string containing the class name
  22862. */
  22863. getClassName(): string;
  22864. /**
  22865. * Instantiates a GPU particle system.
  22866. * 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.
  22867. * @param name The name of the particle system
  22868. * @param capacity The max number of particles alive at the same time
  22869. * @param scene The scene the particle system belongs to
  22870. */
  22871. constructor(name: string, options: Partial<{
  22872. capacity: number;
  22873. randomTextureSize: number;
  22874. }>, scene: Scene);
  22875. private _createUpdateVAO(source);
  22876. private _createRenderVAO(source, spriteSource);
  22877. private _initialize(force?);
  22878. /** @hidden */
  22879. _recreateUpdateEffect(): void;
  22880. /** @hidden */
  22881. _recreateRenderEffect(): void;
  22882. /**
  22883. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  22884. */
  22885. animate(): void;
  22886. /**
  22887. * Renders the particle system in its current state.
  22888. * @returns the current number of particles
  22889. */
  22890. render(): number;
  22891. /**
  22892. * Rebuilds the particle system
  22893. */
  22894. rebuild(): void;
  22895. private _releaseBuffers();
  22896. private _releaseVAOs();
  22897. /**
  22898. * Disposes the particle system and free the associated resources
  22899. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  22900. */
  22901. dispose(disposeTexture?: boolean): void;
  22902. /**
  22903. * Clones the particle system.
  22904. * @param name The name of the cloned object
  22905. * @param newEmitter The new emitter to use
  22906. * @returns the cloned particle system
  22907. */
  22908. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  22909. /**
  22910. * Serializes the particle system to a JSON object.
  22911. * @returns the JSON object
  22912. */
  22913. serialize(): any;
  22914. /**
  22915. * Parses a JSON object to create a GPU particle system.
  22916. * @param parsedParticleSystem The JSON object to parse
  22917. * @param scene The scene to create the particle system in
  22918. * @param rootUrl The root url to use to load external dependencies like texture
  22919. * @returns the parsed GPU particle system
  22920. */
  22921. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  22922. }
  22923. }
  22924. declare module BABYLON {
  22925. /**
  22926. * Interface representing a particle system in Babylon.
  22927. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  22928. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  22929. */
  22930. interface IParticleSystem {
  22931. /**
  22932. * The id of the Particle system.
  22933. */
  22934. id: string;
  22935. /**
  22936. * The name of the Particle system.
  22937. */
  22938. name: string;
  22939. /**
  22940. * The emitter represents the Mesh or position we are attaching the particle system to.
  22941. */
  22942. emitter: Nullable<AbstractMesh | Vector3>;
  22943. /**
  22944. * The rendering group used by the Particle system to chose when to render.
  22945. */
  22946. renderingGroupId: number;
  22947. /**
  22948. * The layer mask we are rendering the particles through.
  22949. */
  22950. layerMask: number;
  22951. /**
  22952. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  22953. */
  22954. updateSpeed: number;
  22955. /**
  22956. * The amount of time the particle system is running (depends of the overall update speed).
  22957. */
  22958. targetStopDuration: number;
  22959. /**
  22960. * The texture used to render each particle. (this can be a spritesheet)
  22961. */
  22962. particleTexture: Nullable<Texture>;
  22963. /**
  22964. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  22965. */
  22966. blendMode: number;
  22967. /**
  22968. * Minimum life time of emitting particles.
  22969. */
  22970. minLifeTime: number;
  22971. /**
  22972. * Maximum life time of emitting particles.
  22973. */
  22974. maxLifeTime: number;
  22975. /**
  22976. * Minimum Size of emitting particles.
  22977. */
  22978. minSize: number;
  22979. /**
  22980. * Maximum Size of emitting particles.
  22981. */
  22982. maxSize: number;
  22983. /**
  22984. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  22985. */
  22986. color1: Color4;
  22987. /**
  22988. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  22989. */
  22990. color2: Color4;
  22991. /**
  22992. * Color the particle will have at the end of its lifetime.
  22993. */
  22994. colorDead: Color4;
  22995. /**
  22996. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  22997. */
  22998. emitRate: number;
  22999. /**
  23000. * You can use gravity if you want to give an orientation to your particles.
  23001. */
  23002. gravity: Vector3;
  23003. /**
  23004. * Minimum power of emitting particles.
  23005. */
  23006. minEmitPower: number;
  23007. /**
  23008. * Maximum power of emitting particles.
  23009. */
  23010. maxEmitPower: number;
  23011. /**
  23012. * The particle emitter type defines the emitter used by the particle system.
  23013. * It can be for example box, sphere, or cone...
  23014. */
  23015. particleEmitterType: Nullable<IParticleEmitterType>;
  23016. /**
  23017. * Gets the maximum number of particles active at the same time.
  23018. * @returns The max number of active particles.
  23019. */
  23020. getCapacity(): number;
  23021. /**
  23022. * Gets Wether the system has been started.
  23023. * @returns True if it has been started, otherwise false.
  23024. */
  23025. isStarted(): boolean;
  23026. /**
  23027. * Gets if the particle system has been started.
  23028. * @return true if the system has been started, otherwise false.
  23029. */
  23030. isStarted(): boolean;
  23031. /**
  23032. * Animates the particle system for this frame.
  23033. */
  23034. animate(): void;
  23035. /**
  23036. * Renders the particle system in its current state.
  23037. * @returns the current number of particles
  23038. */
  23039. render(): number;
  23040. /**
  23041. * Dispose the particle system and frees its associated resources.
  23042. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  23043. */
  23044. dispose(disposeTexture?: boolean): void;
  23045. /**
  23046. * Clones the particle system.
  23047. * @param name The name of the cloned object
  23048. * @param newEmitter The new emitter to use
  23049. * @returns the cloned particle system
  23050. */
  23051. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  23052. /**
  23053. * Serializes the particle system to a JSON object.
  23054. * @returns the JSON object
  23055. */
  23056. serialize(): any;
  23057. /**
  23058. * Rebuild the particle system
  23059. */
  23060. rebuild(): void;
  23061. /**
  23062. * Starts the particle system and begins to emit.
  23063. */
  23064. start(): void;
  23065. /**
  23066. * Stops the particle system.
  23067. */
  23068. stop(): void;
  23069. /**
  23070. * Remove all active particles
  23071. */
  23072. reset(): void;
  23073. /**
  23074. * Is this system ready to be used/rendered
  23075. * @return true if the system is ready
  23076. */
  23077. isReady(): boolean;
  23078. }
  23079. }
  23080. declare module BABYLON {
  23081. /**
  23082. * A particle represents one of the element emitted by a particle system.
  23083. * This is mainly define by its coordinates, direction, velocity and age.
  23084. */
  23085. class Particle {
  23086. /**
  23087. * particleSystem the particle system the particle belongs to.
  23088. */
  23089. particleSystem: ParticleSystem;
  23090. /**
  23091. * The world position of the particle in the scene.
  23092. */
  23093. position: Vector3;
  23094. /**
  23095. * The world direction of the particle in the scene.
  23096. */
  23097. direction: Vector3;
  23098. /**
  23099. * The color of the particle.
  23100. */
  23101. color: Color4;
  23102. /**
  23103. * The color change of the particle per step.
  23104. */
  23105. colorStep: Color4;
  23106. /**
  23107. * Defines how long will the life of the particle be.
  23108. */
  23109. lifeTime: number;
  23110. /**
  23111. * The current age of the particle.
  23112. */
  23113. age: number;
  23114. /**
  23115. * The current size of the particle.
  23116. */
  23117. size: number;
  23118. /**
  23119. * The current angle of the particle.
  23120. */
  23121. angle: number;
  23122. /**
  23123. * Defines how fast is the angle changing.
  23124. */
  23125. angularSpeed: number;
  23126. /**
  23127. * Defines the cell index used by the particle to be rendered from a sprite.
  23128. */
  23129. cellIndex: number;
  23130. private _currentFrameCounter;
  23131. /**
  23132. * Creates a new instance Particle
  23133. * @param particleSystem the particle system the particle belongs to
  23134. */
  23135. constructor(
  23136. /**
  23137. * particleSystem the particle system the particle belongs to.
  23138. */
  23139. particleSystem: ParticleSystem);
  23140. private updateCellInfoFromSystem();
  23141. /**
  23142. * Defines how the sprite cell index is updated for the particle. This is
  23143. * defined as a callback.
  23144. */
  23145. updateCellIndex: (scaledUpdateSpeed: number) => void;
  23146. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  23147. private _updateCellIndexWithCustomSpeed();
  23148. /**
  23149. * Copy the properties of particle to another one.
  23150. * @param other the particle to copy the information to.
  23151. */
  23152. copyTo(other: Particle): void;
  23153. }
  23154. }
  23155. declare module BABYLON {
  23156. /**
  23157. * This represents a particle system in Babylon.
  23158. * 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.
  23159. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  23160. * @example https://doc.babylonjs.com/babylon101/particles
  23161. */
  23162. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  23163. /**
  23164. * Source color is added to the destination color without alpha affecting the result.
  23165. */
  23166. static BLENDMODE_ONEONE: number;
  23167. /**
  23168. * Blend current color and particle color using particle’s alpha.
  23169. */
  23170. static BLENDMODE_STANDARD: number;
  23171. /**
  23172. * List of animations used by the particle system.
  23173. */
  23174. animations: Animation[];
  23175. /**
  23176. * The id of the Particle system.
  23177. */
  23178. id: string;
  23179. /**
  23180. * The friendly name of the Particle system.
  23181. */
  23182. name: string;
  23183. /**
  23184. * The rendering group used by the Particle system to chose when to render.
  23185. */
  23186. renderingGroupId: number;
  23187. /**
  23188. * The emitter represents the Mesh or position we are attaching the particle system to.
  23189. */
  23190. emitter: Nullable<AbstractMesh | Vector3>;
  23191. /**
  23192. * The maximum number of particles to emit per frame
  23193. */
  23194. emitRate: number;
  23195. /**
  23196. * If you want to launch only a few particles at once, that can be done, as well.
  23197. */
  23198. manualEmitCount: number;
  23199. /**
  23200. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  23201. */
  23202. updateSpeed: number;
  23203. /**
  23204. * The amount of time the particle system is running (depends of the overall update speed).
  23205. */
  23206. targetStopDuration: number;
  23207. /**
  23208. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  23209. */
  23210. disposeOnStop: boolean;
  23211. /**
  23212. * Minimum power of emitting particles.
  23213. */
  23214. minEmitPower: number;
  23215. /**
  23216. * Maximum power of emitting particles.
  23217. */
  23218. maxEmitPower: number;
  23219. /**
  23220. * Minimum life time of emitting particles.
  23221. */
  23222. minLifeTime: number;
  23223. /**
  23224. * Maximum life time of emitting particles.
  23225. */
  23226. maxLifeTime: number;
  23227. /**
  23228. * Minimum Size of emitting particles.
  23229. */
  23230. minSize: number;
  23231. /**
  23232. * Maximum Size of emitting particles.
  23233. */
  23234. maxSize: number;
  23235. /**
  23236. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  23237. */
  23238. minAngularSpeed: number;
  23239. /**
  23240. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  23241. */
  23242. maxAngularSpeed: number;
  23243. /**
  23244. * The texture used to render each particle. (this can be a spritesheet)
  23245. */
  23246. particleTexture: Nullable<Texture>;
  23247. /**
  23248. * The layer mask we are rendering the particles through.
  23249. */
  23250. layerMask: number;
  23251. /**
  23252. * This can help using your own shader to render the particle system.
  23253. * The according effect will be created
  23254. */
  23255. customShader: any;
  23256. /**
  23257. * By default particle system starts as soon as they are created. This prevents the
  23258. * automatic start to happen and let you decide when to start emitting particles.
  23259. */
  23260. preventAutoStart: boolean;
  23261. /**
  23262. * This function can be defined to provide custom update for active particles.
  23263. * This function will be called instead of regular update (age, position, color, etc.).
  23264. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  23265. */
  23266. updateFunction: (particles: Particle[]) => void;
  23267. /**
  23268. * Callback triggered when the particle animation is ending.
  23269. */
  23270. onAnimationEnd: Nullable<() => void>;
  23271. /**
  23272. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  23273. */
  23274. blendMode: number;
  23275. /**
  23276. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  23277. * to override the particles.
  23278. */
  23279. forceDepthWrite: boolean;
  23280. /**
  23281. * You can use gravity if you want to give an orientation to your particles.
  23282. */
  23283. gravity: Vector3;
  23284. /**
  23285. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23286. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23287. */
  23288. direction1: Vector3;
  23289. /**
  23290. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23291. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23292. */
  23293. direction2: Vector3;
  23294. /**
  23295. * 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.
  23296. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23297. */
  23298. minEmitBox: Vector3;
  23299. /**
  23300. * 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.
  23301. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23302. */
  23303. maxEmitBox: Vector3;
  23304. /**
  23305. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23306. */
  23307. color1: Color4;
  23308. /**
  23309. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23310. */
  23311. color2: Color4;
  23312. /**
  23313. * Color the particle will have at the end of its lifetime.
  23314. */
  23315. colorDead: Color4;
  23316. /**
  23317. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  23318. */
  23319. textureMask: Color4;
  23320. /**
  23321. * The particle emitter type defines the emitter used by the particle system.
  23322. * It can be for example box, sphere, or cone...
  23323. */
  23324. particleEmitterType: IParticleEmitterType;
  23325. /**
  23326. * This function can be defined to specify initial direction for every new particle.
  23327. * It by default use the emitterType defined function.
  23328. */
  23329. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  23330. /**
  23331. * This function can be defined to specify initial position for every new particle.
  23332. * It by default use the emitterType defined function.
  23333. */
  23334. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  23335. /**
  23336. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  23337. */
  23338. spriteCellLoop: boolean;
  23339. /**
  23340. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  23341. */
  23342. spriteCellChangeSpeed: number;
  23343. /**
  23344. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  23345. */
  23346. startSpriteCellID: number;
  23347. /**
  23348. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  23349. */
  23350. endSpriteCellID: number;
  23351. /**
  23352. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  23353. */
  23354. spriteCellWidth: number;
  23355. /**
  23356. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  23357. */
  23358. spriteCellHeight: number;
  23359. /**
  23360. * An event triggered when the system is disposed.
  23361. */
  23362. onDisposeObservable: Observable<ParticleSystem>;
  23363. private _onDisposeObserver;
  23364. /**
  23365. * Sets a callback that will be triggered when the system is disposed.
  23366. */
  23367. onDispose: () => void;
  23368. /**
  23369. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  23370. */
  23371. readonly isAnimationSheetEnabled: Boolean;
  23372. private _particles;
  23373. private _epsilon;
  23374. private _capacity;
  23375. private _scene;
  23376. private _stockParticles;
  23377. private _newPartsExcess;
  23378. private _vertexData;
  23379. private _vertexBuffer;
  23380. private _vertexBuffers;
  23381. private _indexBuffer;
  23382. private _effect;
  23383. private _customEffect;
  23384. private _cachedDefines;
  23385. private _scaledColorStep;
  23386. private _colorDiff;
  23387. private _scaledDirection;
  23388. private _scaledGravity;
  23389. private _currentRenderId;
  23390. private _alive;
  23391. private _started;
  23392. private _stopped;
  23393. private _actualFrame;
  23394. private _scaledUpdateSpeed;
  23395. private _vertexBufferSize;
  23396. private _isAnimationSheetEnabled;
  23397. /**
  23398. * 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.
  23399. */
  23400. subEmitters: ParticleSystem[];
  23401. /**
  23402. * The current active Sub-systems, this property is used by the root particle system only.
  23403. */
  23404. activeSubSystems: Array<ParticleSystem>;
  23405. private _rootParticleSystem;
  23406. /**
  23407. * Gets the current list of active particles
  23408. */
  23409. readonly particles: Particle[];
  23410. /**
  23411. * Returns the string "ParticleSystem"
  23412. * @returns a string containing the class name
  23413. */
  23414. getClassName(): string;
  23415. /**
  23416. * Instantiates a particle system.
  23417. * 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.
  23418. * @param name The name of the particle system
  23419. * @param capacity The max number of particles alive at the same time
  23420. * @param scene The scene the particle system belongs to
  23421. * @param customEffect a custom effect used to change the way particles are rendered by default
  23422. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  23423. * @param epsilon Offset used to render the particles
  23424. */
  23425. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  23426. private _createIndexBuffer();
  23427. /**
  23428. * Gets the maximum number of particles active at the same time.
  23429. * @returns The max number of active particles.
  23430. */
  23431. getCapacity(): number;
  23432. /**
  23433. * Gets Wether there are still active particles in the system.
  23434. * @returns True if it is alive, otherwise false.
  23435. */
  23436. isAlive(): boolean;
  23437. /**
  23438. * Gets Wether the system has been started.
  23439. * @returns True if it has been started, otherwise false.
  23440. */
  23441. isStarted(): boolean;
  23442. /**
  23443. * Starts the particle system and begins to emit.
  23444. */
  23445. start(): void;
  23446. /**
  23447. * Stops the particle system.
  23448. * @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.
  23449. */
  23450. stop(stopSubEmitters?: boolean): void;
  23451. /**
  23452. * Remove all active particles
  23453. */
  23454. reset(): void;
  23455. /**
  23456. * @hidden (for internal use only)
  23457. */
  23458. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  23459. /**
  23460. * @hidden (for internal use only)
  23461. */
  23462. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  23463. /**
  23464. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  23465. * Its lifetime will start back at 0.
  23466. */
  23467. recycleParticle: (particle: Particle) => void;
  23468. private _stopSubEmitters();
  23469. private _createParticle;
  23470. private _removeFromRoot();
  23471. private _emitFromParticle;
  23472. private _update(newParticles);
  23473. private _getEffect();
  23474. /**
  23475. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  23476. */
  23477. animate(): void;
  23478. private _appendParticleVertexes;
  23479. private _appenedParticleVertexesWithSheet(offset, particle);
  23480. private _appenedParticleVertexesNoSheet(offset, particle);
  23481. /**
  23482. * Rebuilds the particle system.
  23483. */
  23484. rebuild(): void;
  23485. /**
  23486. * Is this system ready to be used/rendered
  23487. * @return true if the system is ready
  23488. */
  23489. isReady(): boolean;
  23490. /**
  23491. * Renders the particle system in its current state.
  23492. * @returns the current number of particles
  23493. */
  23494. render(): number;
  23495. /**
  23496. * Disposes the particle system and free the associated resources
  23497. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  23498. */
  23499. dispose(disposeTexture?: boolean): void;
  23500. /**
  23501. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  23502. * @param radius The radius of the sphere to emit from
  23503. * @returns the emitter
  23504. */
  23505. createSphereEmitter(radius?: number): SphereParticleEmitter;
  23506. /**
  23507. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  23508. * @param radius The radius of the sphere to emit from
  23509. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  23510. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  23511. * @returns the emitter
  23512. */
  23513. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  23514. /**
  23515. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  23516. * @param radius The radius of the cone to emit from
  23517. * @param angle The base angle of the cone
  23518. * @returns the emitter
  23519. */
  23520. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  23521. /**
  23522. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  23523. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  23524. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  23525. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  23526. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  23527. * @returns the emitter
  23528. */
  23529. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  23530. /**
  23531. * Clones the particle system.
  23532. * @param name The name of the cloned object
  23533. * @param newEmitter The new emitter to use
  23534. * @returns the cloned particle system
  23535. */
  23536. clone(name: string, newEmitter: any): ParticleSystem;
  23537. /**
  23538. * Serializes the particle system to a JSON object.
  23539. * @returns the JSON object
  23540. */
  23541. serialize(): any;
  23542. /**
  23543. * Parses a JSON object to create a particle system.
  23544. * @param parsedParticleSystem The JSON object to parse
  23545. * @param scene The scene to create the particle system in
  23546. * @param rootUrl The root url to use to load external dependencies like texture
  23547. * @returns the Parsed particle system
  23548. */
  23549. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  23550. }
  23551. }
  23552. declare module BABYLON {
  23553. /**
  23554. * Represents one particle of a solid particle system.
  23555. */
  23556. class SolidParticle {
  23557. /**
  23558. * particle global index
  23559. */
  23560. idx: number;
  23561. /**
  23562. * The color of the particle
  23563. */
  23564. color: Nullable<Color4>;
  23565. /**
  23566. * The world space position of the particle.
  23567. */
  23568. position: Vector3;
  23569. /**
  23570. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23571. */
  23572. rotation: Vector3;
  23573. /**
  23574. * The world space rotation quaternion of the particle.
  23575. */
  23576. rotationQuaternion: Nullable<Quaternion>;
  23577. /**
  23578. * The scaling of the particle.
  23579. */
  23580. scaling: Vector3;
  23581. /**
  23582. * The uvs of the particle.
  23583. */
  23584. uvs: Vector4;
  23585. /**
  23586. * The current speed of the particle.
  23587. */
  23588. velocity: Vector3;
  23589. /**
  23590. * The pivot point in the particle local space.
  23591. */
  23592. pivot: Vector3;
  23593. /**
  23594. * Must the particle be translated from its pivot point in its local space ?
  23595. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23596. * Default : false
  23597. */
  23598. translateFromPivot: boolean;
  23599. /**
  23600. * Is the particle active or not ?
  23601. */
  23602. alive: boolean;
  23603. /**
  23604. * Is the particle visible or not ?
  23605. */
  23606. isVisible: boolean;
  23607. /**
  23608. * Index of this particle in the global "positions" array (Internal use)
  23609. */
  23610. _pos: number;
  23611. /**
  23612. * Index of this particle in the global "indices" array (Internal use)
  23613. */
  23614. _ind: number;
  23615. /**
  23616. * ModelShape of this particle (Internal use)
  23617. */
  23618. _model: ModelShape;
  23619. /**
  23620. * ModelShape id of this particle
  23621. */
  23622. shapeId: number;
  23623. /**
  23624. * Index of the particle in its shape id (Internal use)
  23625. */
  23626. idxInShape: number;
  23627. /**
  23628. * Reference to the shape model BoundingInfo object (Internal use)
  23629. */
  23630. _modelBoundingInfo: BoundingInfo;
  23631. /**
  23632. * Particle BoundingInfo object (Internal use)
  23633. */
  23634. _boundingInfo: BoundingInfo;
  23635. /**
  23636. * Reference to the SPS what the particle belongs to (Internal use)
  23637. */
  23638. _sps: SolidParticleSystem;
  23639. /**
  23640. * Still set as invisible in order to skip useless computations (Internal use)
  23641. */
  23642. _stillInvisible: boolean;
  23643. /**
  23644. * Last computed particle rotation matrix
  23645. */
  23646. _rotationMatrix: number[];
  23647. /**
  23648. * Parent particle Id, if any.
  23649. * Default null.
  23650. */
  23651. parentId: Nullable<number>;
  23652. /**
  23653. * Internal global position in the SPS.
  23654. */
  23655. _globalPosition: Vector3;
  23656. /**
  23657. * Creates a Solid Particle object.
  23658. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23659. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23660. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23661. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23662. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23663. * @param shapeId (integer) is the model shape identifier in the SPS.
  23664. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23665. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23666. */
  23667. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23668. /**
  23669. * Legacy support, changed scale to scaling
  23670. */
  23671. /**
  23672. * Legacy support, changed scale to scaling
  23673. */
  23674. scale: Vector3;
  23675. /**
  23676. * Legacy support, changed quaternion to rotationQuaternion
  23677. */
  23678. /**
  23679. * Legacy support, changed quaternion to rotationQuaternion
  23680. */
  23681. quaternion: Nullable<Quaternion>;
  23682. /**
  23683. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23684. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23685. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23686. * @returns true if it intersects
  23687. */
  23688. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23689. }
  23690. /**
  23691. * Represents the shape of the model used by one particle of a solid particle system.
  23692. * SPS internal tool, don't use it manually.
  23693. */
  23694. class ModelShape {
  23695. /**
  23696. * The shape id.
  23697. */
  23698. shapeID: number;
  23699. /**
  23700. * flat array of model positions (internal use)
  23701. */
  23702. _shape: Vector3[];
  23703. /**
  23704. * flat array of model UVs (internal use)
  23705. */
  23706. _shapeUV: number[];
  23707. /**
  23708. * length of the shape in the model indices array (internal use)
  23709. */
  23710. _indicesLength: number;
  23711. /**
  23712. * Custom position function (internal use)
  23713. */
  23714. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23715. /**
  23716. * Custom vertex function (internal use)
  23717. */
  23718. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23719. /**
  23720. * 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.
  23721. * SPS internal tool, don't use it manually.
  23722. * @hidden
  23723. */
  23724. 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>);
  23725. }
  23726. /**
  23727. * Represents a Depth Sorted Particle in the solid particle system.
  23728. */
  23729. class DepthSortedParticle {
  23730. /**
  23731. * Index of the particle in the "indices" array
  23732. */
  23733. ind: number;
  23734. /**
  23735. * Length of the particle shape in the "indices" array
  23736. */
  23737. indicesLength: number;
  23738. /**
  23739. * Squared distance from the particle to the camera
  23740. */
  23741. sqDistance: number;
  23742. }
  23743. }
  23744. declare module BABYLON {
  23745. /**
  23746. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23747. *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.
  23748. * The SPS is also a particle system. It provides some methods to manage the particles.
  23749. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23750. *
  23751. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23752. */
  23753. class SolidParticleSystem implements IDisposable {
  23754. /**
  23755. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23756. * Example : var p = SPS.particles[i];
  23757. */
  23758. particles: SolidParticle[];
  23759. /**
  23760. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23761. */
  23762. nbParticles: number;
  23763. /**
  23764. * If the particles must ever face the camera (default false). Useful for planar particles.
  23765. */
  23766. billboard: boolean;
  23767. /**
  23768. * Recompute normals when adding a shape
  23769. */
  23770. recomputeNormals: boolean;
  23771. /**
  23772. * This a counter ofr your own usage. It's not set by any SPS functions.
  23773. */
  23774. counter: number;
  23775. /**
  23776. * The SPS name. This name is also given to the underlying mesh.
  23777. */
  23778. name: string;
  23779. /**
  23780. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23781. */
  23782. mesh: Mesh;
  23783. /**
  23784. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23785. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23786. */
  23787. vars: any;
  23788. /**
  23789. * This array is populated when the SPS is set as 'pickable'.
  23790. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23791. * Each element of this array is an object `{idx: int, faceId: int}`.
  23792. * `idx` is the picked particle index in the `SPS.particles` array
  23793. * `faceId` is the picked face index counted within this particle.
  23794. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23795. */
  23796. pickedParticles: {
  23797. idx: number;
  23798. faceId: number;
  23799. }[];
  23800. /**
  23801. * This array is populated when `enableDepthSort` is set to true.
  23802. * Each element of this array is an instance of the class DepthSortedParticle.
  23803. */
  23804. depthSortedParticles: DepthSortedParticle[];
  23805. /**
  23806. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23807. */
  23808. _bSphereOnly: boolean;
  23809. /**
  23810. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23811. */
  23812. _bSphereRadiusFactor: number;
  23813. private _scene;
  23814. private _positions;
  23815. private _indices;
  23816. private _normals;
  23817. private _colors;
  23818. private _uvs;
  23819. private _indices32;
  23820. private _positions32;
  23821. private _normals32;
  23822. private _fixedNormal32;
  23823. private _colors32;
  23824. private _uvs32;
  23825. private _index;
  23826. private _updatable;
  23827. private _pickable;
  23828. private _isVisibilityBoxLocked;
  23829. private _alwaysVisible;
  23830. private _depthSort;
  23831. private _shapeCounter;
  23832. private _copy;
  23833. private _shape;
  23834. private _shapeUV;
  23835. private _color;
  23836. private _computeParticleColor;
  23837. private _computeParticleTexture;
  23838. private _computeParticleRotation;
  23839. private _computeParticleVertex;
  23840. private _computeBoundingBox;
  23841. private _depthSortParticles;
  23842. private _cam_axisZ;
  23843. private _cam_axisY;
  23844. private _cam_axisX;
  23845. private _axisZ;
  23846. private _camera;
  23847. private _particle;
  23848. private _camDir;
  23849. private _camInvertedPosition;
  23850. private _rotMatrix;
  23851. private _invertMatrix;
  23852. private _rotated;
  23853. private _quaternion;
  23854. private _vertex;
  23855. private _normal;
  23856. private _yaw;
  23857. private _pitch;
  23858. private _roll;
  23859. private _halfroll;
  23860. private _halfpitch;
  23861. private _halfyaw;
  23862. private _sinRoll;
  23863. private _cosRoll;
  23864. private _sinPitch;
  23865. private _cosPitch;
  23866. private _sinYaw;
  23867. private _cosYaw;
  23868. private _mustUnrotateFixedNormals;
  23869. private _minimum;
  23870. private _maximum;
  23871. private _minBbox;
  23872. private _maxBbox;
  23873. private _particlesIntersect;
  23874. private _depthSortFunction;
  23875. private _needs32Bits;
  23876. private _pivotBackTranslation;
  23877. private _scaledPivot;
  23878. private _particleHasParent;
  23879. private _parent;
  23880. /**
  23881. * Creates a SPS (Solid Particle System) object.
  23882. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23883. * @param scene (Scene) is the scene in which the SPS is added.
  23884. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23885. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23886. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23887. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23888. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23889. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23890. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23891. */
  23892. constructor(name: string, scene: Scene, options?: {
  23893. updatable?: boolean;
  23894. isPickable?: boolean;
  23895. enableDepthSort?: boolean;
  23896. particleIntersection?: boolean;
  23897. boundingSphereOnly?: boolean;
  23898. bSphereRadiusFactor?: number;
  23899. });
  23900. /**
  23901. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23902. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23903. * @returns the created mesh
  23904. */
  23905. buildMesh(): Mesh;
  23906. /**
  23907. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23908. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23909. * Thus the particles generated from `digest()` have their property `position` set yet.
  23910. * @param mesh ( Mesh ) is the mesh to be digested
  23911. * @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
  23912. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23913. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23914. * @returns the current SPS
  23915. */
  23916. digest(mesh: Mesh, options?: {
  23917. facetNb?: number;
  23918. number?: number;
  23919. delta?: number;
  23920. }): SolidParticleSystem;
  23921. private _unrotateFixedNormals();
  23922. private _resetCopy();
  23923. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  23924. private _posToShape(positions);
  23925. private _uvsToShapeUV(uvs);
  23926. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  23927. /**
  23928. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23929. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23930. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23931. * @param nb (positive integer) the number of particles to be created from this model
  23932. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23933. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23934. * @returns the number of shapes in the system
  23935. */
  23936. addShape(mesh: Mesh, nb: number, options?: {
  23937. positionFunction?: any;
  23938. vertexFunction?: any;
  23939. }): number;
  23940. private _rebuildParticle(particle);
  23941. /**
  23942. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23943. * @returns the SPS.
  23944. */
  23945. rebuildMesh(): SolidParticleSystem;
  23946. /**
  23947. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23948. * This method calls `updateParticle()` for each particle of the SPS.
  23949. * For an animated SPS, it is usually called within the render loop.
  23950. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23951. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23952. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23953. * @returns the SPS.
  23954. */
  23955. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23956. private _quaternionRotationYPR();
  23957. private _quaternionToRotationMatrix();
  23958. /**
  23959. * Disposes the SPS.
  23960. */
  23961. dispose(): void;
  23962. /**
  23963. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23964. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23965. * @returns the SPS.
  23966. */
  23967. refreshVisibleSize(): SolidParticleSystem;
  23968. /**
  23969. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23970. * @param size the size (float) of the visibility box
  23971. * note : this doesn't lock the SPS mesh bounding box.
  23972. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23973. */
  23974. setVisibilityBox(size: number): void;
  23975. /**
  23976. * Gets whether the SPS as always visible or not
  23977. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23978. */
  23979. /**
  23980. * Sets the SPS as always visible or not
  23981. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23982. */
  23983. isAlwaysVisible: boolean;
  23984. /**
  23985. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23986. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23987. */
  23988. /**
  23989. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23990. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23991. */
  23992. isVisibilityBoxLocked: boolean;
  23993. /**
  23994. * Gets if `setParticles()` computes the particle rotations or not.
  23995. * Default value : true. The SPS is faster when it's set to false.
  23996. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23997. */
  23998. /**
  23999. * Tells to `setParticles()` to compute the particle rotations or not.
  24000. * Default value : true. The SPS is faster when it's set to false.
  24001. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24002. */
  24003. computeParticleRotation: boolean;
  24004. /**
  24005. * Gets if `setParticles()` computes the particle colors or not.
  24006. * Default value : true. The SPS is faster when it's set to false.
  24007. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24008. */
  24009. /**
  24010. * Tells to `setParticles()` to compute the particle colors or not.
  24011. * Default value : true. The SPS is faster when it's set to false.
  24012. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24013. */
  24014. computeParticleColor: boolean;
  24015. /**
  24016. * Gets if `setParticles()` computes the particle textures or not.
  24017. * Default value : true. The SPS is faster when it's set to false.
  24018. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24019. */
  24020. computeParticleTexture: boolean;
  24021. /**
  24022. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24023. * Default value : false. The SPS is faster when it's set to false.
  24024. * Note : the particle custom vertex positions aren't stored values.
  24025. */
  24026. /**
  24027. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24028. * Default value : false. The SPS is faster when it's set to false.
  24029. * Note : the particle custom vertex positions aren't stored values.
  24030. */
  24031. computeParticleVertex: boolean;
  24032. /**
  24033. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24034. */
  24035. /**
  24036. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24037. */
  24038. computeBoundingBox: boolean;
  24039. /**
  24040. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24041. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24042. * Default : `true`
  24043. */
  24044. /**
  24045. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24046. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24047. * Default : `true`
  24048. */
  24049. depthSortParticles: boolean;
  24050. /**
  24051. * This function does nothing. It may be overwritten to set all the particle first values.
  24052. * The SPS doesn't call this function, you may have to call it by your own.
  24053. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24054. */
  24055. initParticles(): void;
  24056. /**
  24057. * This function does nothing. It may be overwritten to recycle a particle.
  24058. * The SPS doesn't call this function, you may have to call it by your own.
  24059. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24060. * @param particle The particle to recycle
  24061. * @returns the recycled particle
  24062. */
  24063. recycleParticle(particle: SolidParticle): SolidParticle;
  24064. /**
  24065. * Updates a particle : this function should be overwritten by the user.
  24066. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24067. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24068. * @example : just set a particle position or velocity and recycle conditions
  24069. * @param particle The particle to update
  24070. * @returns the updated particle
  24071. */
  24072. updateParticle(particle: SolidParticle): SolidParticle;
  24073. /**
  24074. * Updates a vertex of a particle : it can be overwritten by the user.
  24075. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24076. * @param particle the current particle
  24077. * @param vertex the current index of the current particle
  24078. * @param pt the index of the current vertex in the particle shape
  24079. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24080. * @example : just set a vertex particle position
  24081. * @returns the updated vertex
  24082. */
  24083. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24084. /**
  24085. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24086. * This does nothing and may be overwritten by the user.
  24087. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24088. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24089. * @param update the boolean update value actually passed to setParticles()
  24090. */
  24091. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24092. /**
  24093. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24094. * This will be passed three parameters.
  24095. * This does nothing and may be overwritten by the user.
  24096. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24097. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24098. * @param update the boolean update value actually passed to setParticles()
  24099. */
  24100. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24101. }
  24102. }
  24103. declare module BABYLON {
  24104. interface PhysicsImpostorJoint {
  24105. mainImpostor: PhysicsImpostor;
  24106. connectedImpostor: PhysicsImpostor;
  24107. joint: PhysicsJoint;
  24108. }
  24109. class PhysicsEngine {
  24110. private _physicsPlugin;
  24111. gravity: Vector3;
  24112. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  24113. setGravity(gravity: Vector3): void;
  24114. /**
  24115. * Set the time step of the physics engine.
  24116. * default is 1/60.
  24117. * To slow it down, enter 1/600 for example.
  24118. * To speed it up, 1/30
  24119. * @param {number} newTimeStep the new timestep to apply to this world.
  24120. */
  24121. setTimeStep(newTimeStep?: number): void;
  24122. /**
  24123. * Get the time step of the physics engine.
  24124. */
  24125. getTimeStep(): number;
  24126. dispose(): void;
  24127. getPhysicsPluginName(): string;
  24128. static Epsilon: number;
  24129. private _impostors;
  24130. private _joints;
  24131. /**
  24132. * Adding a new impostor for the impostor tracking.
  24133. * This will be done by the impostor itself.
  24134. * @param {PhysicsImpostor} impostor the impostor to add
  24135. */
  24136. addImpostor(impostor: PhysicsImpostor): void;
  24137. /**
  24138. * Remove an impostor from the engine.
  24139. * This impostor and its mesh will not longer be updated by the physics engine.
  24140. * @param {PhysicsImpostor} impostor the impostor to remove
  24141. */
  24142. removeImpostor(impostor: PhysicsImpostor): void;
  24143. /**
  24144. * Add a joint to the physics engine
  24145. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  24146. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  24147. * @param {PhysicsJoint} the joint that will connect both impostors.
  24148. */
  24149. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24150. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24151. /**
  24152. * Called by the scene. no need to call it.
  24153. */
  24154. _step(delta: number): void;
  24155. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24156. getImpostors(): Array<PhysicsImpostor>;
  24157. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24158. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24159. }
  24160. interface IPhysicsEnginePlugin {
  24161. world: any;
  24162. name: string;
  24163. setGravity(gravity: Vector3): void;
  24164. setTimeStep(timeStep: number): void;
  24165. getTimeStep(): number;
  24166. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24167. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24168. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24169. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24170. removePhysicsBody(impostor: PhysicsImpostor): void;
  24171. generateJoint(joint: PhysicsImpostorJoint): void;
  24172. removeJoint(joint: PhysicsImpostorJoint): void;
  24173. isSupported(): boolean;
  24174. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24175. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24176. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24177. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24178. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24179. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24180. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24181. getBodyMass(impostor: PhysicsImpostor): number;
  24182. getBodyFriction(impostor: PhysicsImpostor): number;
  24183. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24184. getBodyRestitution(impostor: PhysicsImpostor): number;
  24185. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24186. sleepBody(impostor: PhysicsImpostor): void;
  24187. wakeUpBody(impostor: PhysicsImpostor): void;
  24188. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24189. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24190. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24191. getRadius(impostor: PhysicsImpostor): number;
  24192. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24193. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24194. dispose(): void;
  24195. }
  24196. }
  24197. declare module BABYLON {
  24198. class PhysicsHelper {
  24199. private _scene;
  24200. private _physicsEngine;
  24201. constructor(scene: Scene);
  24202. /**
  24203. * @param {Vector3} origin the origin of the explosion
  24204. * @param {number} radius the explosion radius
  24205. * @param {number} strength the explosion strength
  24206. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24207. */
  24208. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24209. /**
  24210. * @param {Vector3} origin the origin of the explosion
  24211. * @param {number} radius the explosion radius
  24212. * @param {number} strength the explosion strength
  24213. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24214. */
  24215. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24216. /**
  24217. * @param {Vector3} origin the origin of the explosion
  24218. * @param {number} radius the explosion radius
  24219. * @param {number} strength the explosion strength
  24220. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24221. */
  24222. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  24223. /**
  24224. * @param {Vector3} origin the origin of the updraft
  24225. * @param {number} radius the radius of the updraft
  24226. * @param {number} strength the strength of the updraft
  24227. * @param {number} height the height of the updraft
  24228. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  24229. */
  24230. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  24231. /**
  24232. * @param {Vector3} origin the of the vortex
  24233. * @param {number} radius the radius of the vortex
  24234. * @param {number} strength the strength of the vortex
  24235. * @param {number} height the height of the vortex
  24236. */
  24237. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  24238. }
  24239. /***** Radial explosion *****/
  24240. class PhysicsRadialExplosionEvent {
  24241. private _scene;
  24242. private _sphere;
  24243. private _sphereOptions;
  24244. private _rays;
  24245. private _dataFetched;
  24246. constructor(scene: Scene);
  24247. /**
  24248. * Returns the data related to the radial explosion event (sphere & rays).
  24249. * @returns {PhysicsRadialExplosionEventData}
  24250. */
  24251. getData(): PhysicsRadialExplosionEventData;
  24252. /**
  24253. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  24254. * @param impostor
  24255. * @param {Vector3} origin the origin of the explosion
  24256. * @param {number} radius the explosion radius
  24257. * @param {number} strength the explosion strength
  24258. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  24259. * @returns {Nullable<PhysicsForceAndContactPoint>}
  24260. */
  24261. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  24262. /**
  24263. * Disposes the sphere.
  24264. * @param {bolean} force
  24265. */
  24266. dispose(force?: boolean): void;
  24267. /*** Helpers ***/
  24268. private _prepareSphere();
  24269. private _intersectsWithSphere(impostor, origin, radius);
  24270. }
  24271. /***** Gravitational Field *****/
  24272. class PhysicsGravitationalFieldEvent {
  24273. private _physicsHelper;
  24274. private _scene;
  24275. private _origin;
  24276. private _radius;
  24277. private _strength;
  24278. private _falloff;
  24279. private _tickCallback;
  24280. private _sphere;
  24281. private _dataFetched;
  24282. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  24283. /**
  24284. * Returns the data related to the gravitational field event (sphere).
  24285. * @returns {PhysicsGravitationalFieldEventData}
  24286. */
  24287. getData(): PhysicsGravitationalFieldEventData;
  24288. /**
  24289. * Enables the gravitational field.
  24290. */
  24291. enable(): void;
  24292. /**
  24293. * Disables the gravitational field.
  24294. */
  24295. disable(): void;
  24296. /**
  24297. * Disposes the sphere.
  24298. * @param {bolean} force
  24299. */
  24300. dispose(force?: boolean): void;
  24301. private _tick();
  24302. }
  24303. /***** Updraft *****/
  24304. class PhysicsUpdraftEvent {
  24305. private _scene;
  24306. private _origin;
  24307. private _radius;
  24308. private _strength;
  24309. private _height;
  24310. private _updraftMode;
  24311. private _physicsEngine;
  24312. private _originTop;
  24313. private _originDirection;
  24314. private _tickCallback;
  24315. private _cylinder;
  24316. private _cylinderPosition;
  24317. private _dataFetched;
  24318. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  24319. /**
  24320. * Returns the data related to the updraft event (cylinder).
  24321. * @returns {PhysicsUpdraftEventData}
  24322. */
  24323. getData(): PhysicsUpdraftEventData;
  24324. /**
  24325. * Enables the updraft.
  24326. */
  24327. enable(): void;
  24328. /**
  24329. * Disables the cortex.
  24330. */
  24331. disable(): void;
  24332. /**
  24333. * Disposes the sphere.
  24334. * @param {bolean} force
  24335. */
  24336. dispose(force?: boolean): void;
  24337. private getImpostorForceAndContactPoint(impostor);
  24338. private _tick();
  24339. /*** Helpers ***/
  24340. private _prepareCylinder();
  24341. private _intersectsWithCylinder(impostor);
  24342. }
  24343. /***** Vortex *****/
  24344. class PhysicsVortexEvent {
  24345. private _scene;
  24346. private _origin;
  24347. private _radius;
  24348. private _strength;
  24349. private _height;
  24350. private _physicsEngine;
  24351. private _originTop;
  24352. private _centripetalForceThreshold;
  24353. private _updraftMultiplier;
  24354. private _tickCallback;
  24355. private _cylinder;
  24356. private _cylinderPosition;
  24357. private _dataFetched;
  24358. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  24359. /**
  24360. * Returns the data related to the vortex event (cylinder).
  24361. * @returns {PhysicsVortexEventData}
  24362. */
  24363. getData(): PhysicsVortexEventData;
  24364. /**
  24365. * Enables the vortex.
  24366. */
  24367. enable(): void;
  24368. /**
  24369. * Disables the cortex.
  24370. */
  24371. disable(): void;
  24372. /**
  24373. * Disposes the sphere.
  24374. * @param {bolean} force
  24375. */
  24376. dispose(force?: boolean): void;
  24377. private getImpostorForceAndContactPoint(impostor);
  24378. private _tick();
  24379. /*** Helpers ***/
  24380. private _prepareCylinder();
  24381. private _intersectsWithCylinder(impostor);
  24382. }
  24383. /***** Enums *****/
  24384. /**
  24385. * The strenght of the force in correspondence to the distance of the affected object
  24386. */
  24387. enum PhysicsRadialImpulseFalloff {
  24388. /** Defines that impulse is constant in strength across it's whole radius */
  24389. Constant = 0,
  24390. /** DEfines that impulse gets weaker if it's further from the origin */
  24391. Linear = 1,
  24392. }
  24393. /**
  24394. * The strenght of the force in correspondence to the distance of the affected object
  24395. */
  24396. enum PhysicsUpdraftMode {
  24397. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  24398. Center = 0,
  24399. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  24400. Perpendicular = 1,
  24401. }
  24402. /***** Data interfaces *****/
  24403. interface PhysicsForceAndContactPoint {
  24404. force: Vector3;
  24405. contactPoint: Vector3;
  24406. }
  24407. interface PhysicsRadialExplosionEventData {
  24408. sphere: Mesh;
  24409. rays: Array<Ray>;
  24410. }
  24411. interface PhysicsGravitationalFieldEventData {
  24412. sphere: Mesh;
  24413. }
  24414. interface PhysicsUpdraftEventData {
  24415. cylinder: Mesh;
  24416. }
  24417. interface PhysicsVortexEventData {
  24418. cylinder: Mesh;
  24419. }
  24420. }
  24421. declare module BABYLON {
  24422. interface PhysicsImpostorParameters {
  24423. mass: number;
  24424. friction?: number;
  24425. restitution?: number;
  24426. nativeOptions?: any;
  24427. ignoreParent?: boolean;
  24428. disableBidirectionalTransformation?: boolean;
  24429. }
  24430. interface IPhysicsEnabledObject {
  24431. position: Vector3;
  24432. rotationQuaternion: Nullable<Quaternion>;
  24433. scaling: Vector3;
  24434. rotation?: Vector3;
  24435. parent?: any;
  24436. getBoundingInfo(): BoundingInfo;
  24437. computeWorldMatrix(force: boolean): Matrix;
  24438. getWorldMatrix?(): Matrix;
  24439. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24440. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24441. getIndices?(): Nullable<IndicesArray>;
  24442. getScene?(): Scene;
  24443. getAbsolutePosition(): Vector3;
  24444. getAbsolutePivotPoint(): Vector3;
  24445. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24446. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24447. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24448. getClassName(): string;
  24449. }
  24450. class PhysicsImpostor {
  24451. object: IPhysicsEnabledObject;
  24452. type: number;
  24453. private _options;
  24454. private _scene;
  24455. static DEFAULT_OBJECT_SIZE: Vector3;
  24456. static IDENTITY_QUATERNION: Quaternion;
  24457. private _physicsEngine;
  24458. private _physicsBody;
  24459. private _bodyUpdateRequired;
  24460. private _onBeforePhysicsStepCallbacks;
  24461. private _onAfterPhysicsStepCallbacks;
  24462. private _onPhysicsCollideCallbacks;
  24463. private _deltaPosition;
  24464. private _deltaRotation;
  24465. private _deltaRotationConjugated;
  24466. private _parent;
  24467. private _isDisposed;
  24468. private static _tmpVecs;
  24469. private static _tmpQuat;
  24470. readonly isDisposed: boolean;
  24471. mass: number;
  24472. friction: number;
  24473. restitution: number;
  24474. uniqueId: number;
  24475. private _joints;
  24476. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24477. /**
  24478. * This function will completly initialize this impostor.
  24479. * It will create a new body - but only if this mesh has no parent.
  24480. * If it has, this impostor will not be used other than to define the impostor
  24481. * of the child mesh.
  24482. */
  24483. _init(): void;
  24484. private _getPhysicsParent();
  24485. /**
  24486. * Should a new body be generated.
  24487. */
  24488. isBodyInitRequired(): boolean;
  24489. setScalingUpdated(updated: boolean): void;
  24490. /**
  24491. * Force a regeneration of this or the parent's impostor's body.
  24492. * Use under cautious - This will remove all joints already implemented.
  24493. */
  24494. forceUpdate(): void;
  24495. /**
  24496. * Gets the body that holds this impostor. Either its own, or its parent.
  24497. */
  24498. /**
  24499. * Set the physics body. Used mainly by the physics engine/plugin
  24500. */
  24501. physicsBody: any;
  24502. parent: Nullable<PhysicsImpostor>;
  24503. resetUpdateFlags(): void;
  24504. getObjectExtendSize(): Vector3;
  24505. getObjectCenter(): Vector3;
  24506. /**
  24507. * Get a specific parametes from the options parameter.
  24508. */
  24509. getParam(paramName: string): any;
  24510. /**
  24511. * Sets a specific parameter in the options given to the physics plugin
  24512. */
  24513. setParam(paramName: string, value: number): void;
  24514. /**
  24515. * Specifically change the body's mass option. Won't recreate the physics body object
  24516. */
  24517. setMass(mass: number): void;
  24518. getLinearVelocity(): Nullable<Vector3>;
  24519. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24520. getAngularVelocity(): Nullable<Vector3>;
  24521. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24522. /**
  24523. * Execute a function with the physics plugin native code.
  24524. * Provide a function the will have two variables - the world object and the physics body object.
  24525. */
  24526. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24527. /**
  24528. * Register a function that will be executed before the physics world is stepping forward.
  24529. */
  24530. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24531. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24532. /**
  24533. * Register a function that will be executed after the physics step
  24534. */
  24535. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24536. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24537. /**
  24538. * register a function that will be executed when this impostor collides against a different body.
  24539. */
  24540. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24541. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24542. private _tmpQuat;
  24543. private _tmpQuat2;
  24544. getParentsRotation(): Quaternion;
  24545. /**
  24546. * this function is executed by the physics engine.
  24547. */
  24548. beforeStep: () => void;
  24549. /**
  24550. * this function is executed by the physics engine.
  24551. */
  24552. afterStep: () => void;
  24553. /**
  24554. * Legacy collision detection event support
  24555. */
  24556. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24557. onCollide: (e: {
  24558. body: any;
  24559. }) => void;
  24560. /**
  24561. * Apply a force
  24562. */
  24563. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24564. /**
  24565. * Apply an impulse
  24566. */
  24567. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24568. /**
  24569. * A help function to create a joint.
  24570. */
  24571. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24572. /**
  24573. * Add a joint to this impostor with a different impostor.
  24574. */
  24575. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24576. /**
  24577. * Will keep this body still, in a sleep mode.
  24578. */
  24579. sleep(): PhysicsImpostor;
  24580. /**
  24581. * Wake the body up.
  24582. */
  24583. wakeUp(): PhysicsImpostor;
  24584. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24585. dispose(): void;
  24586. setDeltaPosition(position: Vector3): void;
  24587. setDeltaRotation(rotation: Quaternion): void;
  24588. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24589. getRadius(): number;
  24590. /**
  24591. * Sync a bone with this impostor
  24592. * @param bone The bone to sync to the impostor.
  24593. * @param boneMesh The mesh that the bone is influencing.
  24594. * @param jointPivot The pivot of the joint / bone in local space.
  24595. * @param distToJoint Optional distance from the impostor to the joint.
  24596. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24597. */
  24598. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24599. /**
  24600. * Sync impostor to a bone
  24601. * @param bone The bone that the impostor will be synced to.
  24602. * @param boneMesh The mesh that the bone is influencing.
  24603. * @param jointPivot The pivot of the joint / bone in local space.
  24604. * @param distToJoint Optional distance from the impostor to the joint.
  24605. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24606. * @param boneAxis Optional vector3 axis the bone is aligned with
  24607. */
  24608. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24609. static NoImpostor: number;
  24610. static SphereImpostor: number;
  24611. static BoxImpostor: number;
  24612. static PlaneImpostor: number;
  24613. static MeshImpostor: number;
  24614. static CylinderImpostor: number;
  24615. static ParticleImpostor: number;
  24616. static HeightmapImpostor: number;
  24617. }
  24618. }
  24619. declare module BABYLON {
  24620. interface PhysicsJointData {
  24621. mainPivot?: Vector3;
  24622. connectedPivot?: Vector3;
  24623. mainAxis?: Vector3;
  24624. connectedAxis?: Vector3;
  24625. collision?: boolean;
  24626. nativeParams?: any;
  24627. }
  24628. /**
  24629. * This is a holder class for the physics joint created by the physics plugin.
  24630. * It holds a set of functions to control the underlying joint.
  24631. */
  24632. class PhysicsJoint {
  24633. type: number;
  24634. jointData: PhysicsJointData;
  24635. private _physicsJoint;
  24636. protected _physicsPlugin: IPhysicsEnginePlugin;
  24637. constructor(type: number, jointData: PhysicsJointData);
  24638. physicsJoint: any;
  24639. physicsPlugin: IPhysicsEnginePlugin;
  24640. /**
  24641. * Execute a function that is physics-plugin specific.
  24642. * @param {Function} func the function that will be executed.
  24643. * It accepts two parameters: the physics world and the physics joint.
  24644. */
  24645. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24646. static DistanceJoint: number;
  24647. static HingeJoint: number;
  24648. static BallAndSocketJoint: number;
  24649. static WheelJoint: number;
  24650. static SliderJoint: number;
  24651. static PrismaticJoint: number;
  24652. static UniversalJoint: number;
  24653. static Hinge2Joint: number;
  24654. static PointToPointJoint: number;
  24655. static SpringJoint: number;
  24656. static LockJoint: number;
  24657. }
  24658. /**
  24659. * A class representing a physics distance joint.
  24660. */
  24661. class DistanceJoint extends PhysicsJoint {
  24662. constructor(jointData: DistanceJointData);
  24663. /**
  24664. * Update the predefined distance.
  24665. */
  24666. updateDistance(maxDistance: number, minDistance?: number): void;
  24667. }
  24668. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24669. constructor(type: number, jointData: PhysicsJointData);
  24670. /**
  24671. * Set the motor values.
  24672. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24673. * @param {number} force the force to apply
  24674. * @param {number} maxForce max force for this motor.
  24675. */
  24676. setMotor(force?: number, maxForce?: number): void;
  24677. /**
  24678. * Set the motor's limits.
  24679. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24680. */
  24681. setLimit(upperLimit: number, lowerLimit?: number): void;
  24682. }
  24683. /**
  24684. * This class represents a single hinge physics joint
  24685. */
  24686. class HingeJoint extends MotorEnabledJoint {
  24687. constructor(jointData: PhysicsJointData);
  24688. /**
  24689. * Set the motor values.
  24690. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24691. * @param {number} force the force to apply
  24692. * @param {number} maxForce max force for this motor.
  24693. */
  24694. setMotor(force?: number, maxForce?: number): void;
  24695. /**
  24696. * Set the motor's limits.
  24697. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24698. */
  24699. setLimit(upperLimit: number, lowerLimit?: number): void;
  24700. }
  24701. /**
  24702. * This class represents a dual hinge physics joint (same as wheel joint)
  24703. */
  24704. class Hinge2Joint extends MotorEnabledJoint {
  24705. constructor(jointData: PhysicsJointData);
  24706. /**
  24707. * Set the motor values.
  24708. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24709. * @param {number} force the force to apply
  24710. * @param {number} maxForce max force for this motor.
  24711. * @param {motorIndex} the motor's index, 0 or 1.
  24712. */
  24713. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24714. /**
  24715. * Set the motor limits.
  24716. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24717. * @param {number} upperLimit the upper limit
  24718. * @param {number} lowerLimit lower limit
  24719. * @param {motorIndex} the motor's index, 0 or 1.
  24720. */
  24721. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24722. }
  24723. interface IMotorEnabledJoint {
  24724. physicsJoint: any;
  24725. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24726. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24727. }
  24728. interface DistanceJointData extends PhysicsJointData {
  24729. maxDistance: number;
  24730. }
  24731. interface SpringJointData extends PhysicsJointData {
  24732. length: number;
  24733. stiffness: number;
  24734. damping: number;
  24735. }
  24736. }
  24737. declare module BABYLON {
  24738. class ReflectionProbe {
  24739. name: string;
  24740. private _scene;
  24741. private _renderTargetTexture;
  24742. private _projectionMatrix;
  24743. private _viewMatrix;
  24744. private _target;
  24745. private _add;
  24746. private _attachedMesh;
  24747. private _invertYAxis;
  24748. position: Vector3;
  24749. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  24750. samples: number;
  24751. refreshRate: number;
  24752. getScene(): Scene;
  24753. readonly cubeTexture: RenderTargetTexture;
  24754. readonly renderList: Nullable<AbstractMesh[]>;
  24755. attachToMesh(mesh: AbstractMesh): void;
  24756. /**
  24757. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24758. *
  24759. * @param renderingGroupId The rendering group id corresponding to its index
  24760. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24761. */
  24762. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24763. dispose(): void;
  24764. }
  24765. }
  24766. declare module BABYLON {
  24767. class Sprite {
  24768. name: string;
  24769. position: Vector3;
  24770. color: Color4;
  24771. width: number;
  24772. height: number;
  24773. angle: number;
  24774. cellIndex: number;
  24775. invertU: number;
  24776. invertV: number;
  24777. disposeWhenFinishedAnimating: boolean;
  24778. animations: Animation[];
  24779. isPickable: boolean;
  24780. actionManager: ActionManager;
  24781. private _animationStarted;
  24782. private _loopAnimation;
  24783. private _fromIndex;
  24784. private _toIndex;
  24785. private _delay;
  24786. private _direction;
  24787. private _manager;
  24788. private _time;
  24789. private _onAnimationEnd;
  24790. size: number;
  24791. constructor(name: string, manager: SpriteManager);
  24792. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  24793. stopAnimation(): void;
  24794. _animate(deltaTime: number): void;
  24795. dispose(): void;
  24796. }
  24797. }
  24798. declare module BABYLON {
  24799. class SpriteManager {
  24800. name: string;
  24801. sprites: Sprite[];
  24802. renderingGroupId: number;
  24803. layerMask: number;
  24804. fogEnabled: boolean;
  24805. isPickable: boolean;
  24806. cellWidth: number;
  24807. cellHeight: number;
  24808. /**
  24809. * An event triggered when the manager is disposed.
  24810. */
  24811. onDisposeObservable: Observable<SpriteManager>;
  24812. private _onDisposeObserver;
  24813. onDispose: () => void;
  24814. private _capacity;
  24815. private _spriteTexture;
  24816. private _epsilon;
  24817. private _scene;
  24818. private _vertexData;
  24819. private _buffer;
  24820. private _vertexBuffers;
  24821. private _indexBuffer;
  24822. private _effectBase;
  24823. private _effectFog;
  24824. texture: Texture;
  24825. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  24826. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  24827. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24828. render(): void;
  24829. dispose(): void;
  24830. }
  24831. }
  24832. declare module BABYLON {
  24833. class BoundingBoxRenderer {
  24834. frontColor: Color3;
  24835. backColor: Color3;
  24836. showBackLines: boolean;
  24837. renderList: SmartArray<BoundingBox>;
  24838. private _scene;
  24839. private _colorShader;
  24840. private _vertexBuffers;
  24841. private _indexBuffer;
  24842. constructor(scene: Scene);
  24843. private _prepareRessources();
  24844. private _createIndexBuffer();
  24845. _rebuild(): void;
  24846. reset(): void;
  24847. render(): void;
  24848. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  24849. dispose(): void;
  24850. }
  24851. }
  24852. declare module BABYLON {
  24853. /**
  24854. * This represents a depth renderer in Babylon.
  24855. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  24856. */
  24857. class DepthRenderer {
  24858. private _scene;
  24859. private _depthMap;
  24860. private _effect;
  24861. private _cachedDefines;
  24862. private _camera;
  24863. /**
  24864. * Instantiates a depth renderer
  24865. * @param scene The scene the renderer belongs to
  24866. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  24867. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  24868. */
  24869. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  24870. /**
  24871. * Creates the depth rendering effect and checks if the effect is ready.
  24872. * @param subMesh The submesh to be used to render the depth map of
  24873. * @param useInstances If multiple world instances should be used
  24874. * @returns if the depth renderer is ready to render the depth map
  24875. */
  24876. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  24877. /**
  24878. * Gets the texture which the depth map will be written to.
  24879. * @returns The depth map texture
  24880. */
  24881. getDepthMap(): RenderTargetTexture;
  24882. /**
  24883. * Disposes of the depth renderer.
  24884. */
  24885. dispose(): void;
  24886. }
  24887. }
  24888. declare module BABYLON {
  24889. class EdgesRenderer {
  24890. edgesWidthScalerForOrthographic: number;
  24891. edgesWidthScalerForPerspective: number;
  24892. private _source;
  24893. private _linesPositions;
  24894. private _linesNormals;
  24895. private _linesIndices;
  24896. private _epsilon;
  24897. private _indicesCount;
  24898. private _lineShader;
  24899. private _ib;
  24900. private _buffers;
  24901. private _checkVerticesInsteadOfIndices;
  24902. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  24903. private _prepareRessources();
  24904. _rebuild(): void;
  24905. dispose(): void;
  24906. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  24907. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  24908. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  24909. _generateEdgesLines(): void;
  24910. render(): void;
  24911. }
  24912. }
  24913. declare module BABYLON {
  24914. /**
  24915. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  24916. */
  24917. class GeometryBufferRenderer {
  24918. private _scene;
  24919. private _multiRenderTarget;
  24920. private _ratio;
  24921. private _enablePosition;
  24922. protected _effect: Effect;
  24923. protected _cachedDefines: string;
  24924. /**
  24925. * Set the render list (meshes to be rendered) used in the G buffer.
  24926. */
  24927. renderList: Mesh[];
  24928. /**
  24929. * Gets wether or not G buffer are supported by the running hardware.
  24930. * This requires draw buffer supports
  24931. */
  24932. readonly isSupported: boolean;
  24933. /**
  24934. * Gets wether or not position are enabled for the G buffer.
  24935. */
  24936. /**
  24937. * Sets wether or not position are enabled for the G buffer.
  24938. */
  24939. enablePosition: boolean;
  24940. /**
  24941. * Gets the scene associated with the buffer.
  24942. */
  24943. readonly scene: Scene;
  24944. /**
  24945. * Gets the ratio used by the buffer during its creation.
  24946. * How big is the buffer related to the main canvas.
  24947. */
  24948. readonly ratio: number;
  24949. /**
  24950. * Creates a new G Buffer for the scene
  24951. * @param scene The scene the buffer belongs to
  24952. * @param ratio How big is the buffer related to the main canvas.
  24953. */
  24954. constructor(scene: Scene, ratio?: number);
  24955. /**
  24956. * Checks wether everything is ready to render a submesh to the G buffer.
  24957. * @param subMesh the submesh to check readiness for
  24958. * @param useInstances is the mesh drawn using instance or not
  24959. * @returns true if ready otherwise false
  24960. */
  24961. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  24962. /**
  24963. * Gets the current underlying G Buffer.
  24964. * @returns the buffer
  24965. */
  24966. getGBuffer(): MultiRenderTarget;
  24967. /**
  24968. * Gets the number of samples used to render the buffer (anti aliasing).
  24969. */
  24970. /**
  24971. * Sets the number of samples used to render the buffer (anti aliasing).
  24972. */
  24973. samples: number;
  24974. /**
  24975. * Disposes the renderer and frees up associated resources.
  24976. */
  24977. dispose(): void;
  24978. protected _createRenderTargets(): void;
  24979. }
  24980. }
  24981. declare module BABYLON {
  24982. class OutlineRenderer {
  24983. private _scene;
  24984. private _effect;
  24985. private _cachedDefines;
  24986. zOffset: number;
  24987. constructor(scene: Scene);
  24988. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  24989. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  24990. }
  24991. }
  24992. declare module BABYLON {
  24993. class RenderingGroup {
  24994. index: number;
  24995. private _scene;
  24996. private _opaqueSubMeshes;
  24997. private _transparentSubMeshes;
  24998. private _alphaTestSubMeshes;
  24999. private _depthOnlySubMeshes;
  25000. private _particleSystems;
  25001. private _spriteManagers;
  25002. private _opaqueSortCompareFn;
  25003. private _alphaTestSortCompareFn;
  25004. private _transparentSortCompareFn;
  25005. private _renderOpaque;
  25006. private _renderAlphaTest;
  25007. private _renderTransparent;
  25008. private _edgesRenderers;
  25009. onBeforeTransparentRendering: () => void;
  25010. /**
  25011. * Set the opaque sort comparison function.
  25012. * If null the sub meshes will be render in the order they were created
  25013. */
  25014. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  25015. /**
  25016. * Set the alpha test sort comparison function.
  25017. * If null the sub meshes will be render in the order they were created
  25018. */
  25019. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  25020. /**
  25021. * Set the transparent sort comparison function.
  25022. * If null the sub meshes will be render in the order they were created
  25023. */
  25024. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  25025. /**
  25026. * Creates a new rendering group.
  25027. * @param index The rendering group index
  25028. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  25029. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  25030. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  25031. */
  25032. 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>);
  25033. /**
  25034. * Render all the sub meshes contained in the group.
  25035. * @param customRenderFunction Used to override the default render behaviour of the group.
  25036. * @returns true if rendered some submeshes.
  25037. */
  25038. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  25039. /**
  25040. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  25041. * @param subMeshes The submeshes to render
  25042. */
  25043. private renderOpaqueSorted(subMeshes);
  25044. /**
  25045. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  25046. * @param subMeshes The submeshes to render
  25047. */
  25048. private renderAlphaTestSorted(subMeshes);
  25049. /**
  25050. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  25051. * @param subMeshes The submeshes to render
  25052. */
  25053. private renderTransparentSorted(subMeshes);
  25054. /**
  25055. * Renders the submeshes in a specified order.
  25056. * @param subMeshes The submeshes to sort before render
  25057. * @param sortCompareFn The comparison function use to sort
  25058. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  25059. * @param transparent Specifies to activate blending if true
  25060. */
  25061. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  25062. /**
  25063. * Renders the submeshes in the order they were dispatched (no sort applied).
  25064. * @param subMeshes The submeshes to render
  25065. */
  25066. private static renderUnsorted(subMeshes);
  25067. /**
  25068. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25069. * are rendered back to front if in the same alpha index.
  25070. *
  25071. * @param a The first submesh
  25072. * @param b The second submesh
  25073. * @returns The result of the comparison
  25074. */
  25075. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  25076. /**
  25077. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25078. * are rendered back to front.
  25079. *
  25080. * @param a The first submesh
  25081. * @param b The second submesh
  25082. * @returns The result of the comparison
  25083. */
  25084. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  25085. /**
  25086. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25087. * are rendered front to back (prevent overdraw).
  25088. *
  25089. * @param a The first submesh
  25090. * @param b The second submesh
  25091. * @returns The result of the comparison
  25092. */
  25093. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  25094. /**
  25095. * Resets the different lists of submeshes to prepare a new frame.
  25096. */
  25097. prepare(): void;
  25098. dispose(): void;
  25099. /**
  25100. * Inserts the submesh in its correct queue depending on its material.
  25101. * @param subMesh The submesh to dispatch
  25102. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  25103. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  25104. */
  25105. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  25106. dispatchSprites(spriteManager: SpriteManager): void;
  25107. dispatchParticles(particleSystem: IParticleSystem): void;
  25108. private _renderParticles(activeMeshes);
  25109. private _renderSprites();
  25110. }
  25111. }
  25112. declare module BABYLON {
  25113. class RenderingManager {
  25114. /**
  25115. * The max id used for rendering groups (not included)
  25116. */
  25117. static MAX_RENDERINGGROUPS: number;
  25118. /**
  25119. * The min id used for rendering groups (included)
  25120. */
  25121. static MIN_RENDERINGGROUPS: number;
  25122. /**
  25123. * Used to globally prevent autoclearing scenes.
  25124. */
  25125. static AUTOCLEAR: boolean;
  25126. private _scene;
  25127. private _renderingGroups;
  25128. private _depthStencilBufferAlreadyCleaned;
  25129. private _autoClearDepthStencil;
  25130. private _customOpaqueSortCompareFn;
  25131. private _customAlphaTestSortCompareFn;
  25132. private _customTransparentSortCompareFn;
  25133. private _renderinGroupInfo;
  25134. constructor(scene: Scene);
  25135. private _clearDepthStencilBuffer(depth?, stencil?);
  25136. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  25137. reset(): void;
  25138. dispose(): void;
  25139. /**
  25140. * Clear the info related to rendering groups preventing retention points during dispose.
  25141. */
  25142. freeRenderingGroups(): void;
  25143. private _prepareRenderingGroup(renderingGroupId);
  25144. dispatchSprites(spriteManager: SpriteManager): void;
  25145. dispatchParticles(particleSystem: IParticleSystem): void;
  25146. /**
  25147. * @param subMesh The submesh to dispatch
  25148. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  25149. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  25150. */
  25151. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  25152. /**
  25153. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  25154. * This allowed control for front to back rendering or reversly depending of the special needs.
  25155. *
  25156. * @param renderingGroupId The rendering group id corresponding to its index
  25157. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  25158. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  25159. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  25160. */
  25161. 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;
  25162. /**
  25163. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  25164. *
  25165. * @param renderingGroupId The rendering group id corresponding to its index
  25166. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  25167. * @param depth Automatically clears depth between groups if true and autoClear is true.
  25168. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  25169. */
  25170. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  25171. }
  25172. }
  25173. declare module BABYLON {
  25174. /**
  25175. * @hidden
  25176. **/
  25177. class _AlphaState {
  25178. private _isAlphaBlendDirty;
  25179. private _isBlendFunctionParametersDirty;
  25180. private _isBlendEquationParametersDirty;
  25181. private _isBlendConstantsDirty;
  25182. private _alphaBlend;
  25183. private _blendFunctionParameters;
  25184. private _blendEquationParameters;
  25185. private _blendConstants;
  25186. /**
  25187. * Initializes the state.
  25188. */
  25189. constructor();
  25190. readonly isDirty: boolean;
  25191. alphaBlend: boolean;
  25192. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  25193. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  25194. setAlphaEquationParameters(rgb: number, alpha: number): void;
  25195. reset(): void;
  25196. apply(gl: WebGLRenderingContext): void;
  25197. }
  25198. }
  25199. declare module BABYLON {
  25200. /**
  25201. * @hidden
  25202. **/
  25203. class _DepthCullingState {
  25204. private _isDepthTestDirty;
  25205. private _isDepthMaskDirty;
  25206. private _isDepthFuncDirty;
  25207. private _isCullFaceDirty;
  25208. private _isCullDirty;
  25209. private _isZOffsetDirty;
  25210. private _isFrontFaceDirty;
  25211. private _depthTest;
  25212. private _depthMask;
  25213. private _depthFunc;
  25214. private _cull;
  25215. private _cullFace;
  25216. private _zOffset;
  25217. private _frontFace;
  25218. /**
  25219. * Initializes the state.
  25220. */
  25221. constructor();
  25222. readonly isDirty: boolean;
  25223. zOffset: number;
  25224. cullFace: Nullable<number>;
  25225. cull: Nullable<boolean>;
  25226. depthFunc: Nullable<number>;
  25227. depthMask: boolean;
  25228. depthTest: boolean;
  25229. frontFace: Nullable<number>;
  25230. reset(): void;
  25231. apply(gl: WebGLRenderingContext): void;
  25232. }
  25233. }
  25234. declare module BABYLON {
  25235. /**
  25236. * @hidden
  25237. **/
  25238. class _StencilState {
  25239. private _isStencilTestDirty;
  25240. private _isStencilMaskDirty;
  25241. private _isStencilFuncDirty;
  25242. private _isStencilOpDirty;
  25243. private _stencilTest;
  25244. private _stencilMask;
  25245. private _stencilFunc;
  25246. private _stencilFuncRef;
  25247. private _stencilFuncMask;
  25248. private _stencilOpStencilFail;
  25249. private _stencilOpDepthFail;
  25250. private _stencilOpStencilDepthPass;
  25251. readonly isDirty: boolean;
  25252. stencilFunc: number;
  25253. stencilFuncRef: number;
  25254. stencilFuncMask: number;
  25255. stencilOpStencilFail: number;
  25256. stencilOpDepthFail: number;
  25257. stencilOpStencilDepthPass: number;
  25258. stencilMask: number;
  25259. stencilTest: boolean;
  25260. constructor();
  25261. reset(): void;
  25262. apply(gl: WebGLRenderingContext): void;
  25263. }
  25264. }
  25265. declare module BABYLON {
  25266. /**
  25267. * Postprocess used to generate anaglyphic rendering
  25268. */
  25269. class AnaglyphPostProcess extends PostProcess {
  25270. private _passedProcess;
  25271. /**
  25272. * Creates a new AnaglyphPostProcess
  25273. * @param name defines postprocess name
  25274. * @param options defines creation options or target ratio scale
  25275. * @param rigCameras defines cameras using this postprocess
  25276. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  25277. * @param engine defines hosting engine
  25278. * @param reusable defines if the postprocess will be reused multiple times per frame
  25279. */
  25280. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  25281. }
  25282. }
  25283. declare module BABYLON {
  25284. class BlackAndWhitePostProcess extends PostProcess {
  25285. degree: number;
  25286. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25287. }
  25288. }
  25289. declare module BABYLON {
  25290. /**
  25291. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  25292. */
  25293. class BloomEffect extends PostProcessRenderEffect {
  25294. private bloomScale;
  25295. /**
  25296. * Internal
  25297. */
  25298. _effects: Array<PostProcess>;
  25299. /**
  25300. * Internal
  25301. */
  25302. _downscale: ExtractHighlightsPostProcess;
  25303. private _blurX;
  25304. private _blurY;
  25305. private _merge;
  25306. /**
  25307. * The luminance threshold to find bright areas of the image to bloom.
  25308. */
  25309. threshold: number;
  25310. /**
  25311. * The strength of the bloom.
  25312. */
  25313. weight: number;
  25314. /**
  25315. * Specifies the size of the bloom blur kernel, relative to the final output size
  25316. */
  25317. kernel: number;
  25318. /**
  25319. * Creates a new instance of @see BloomEffect
  25320. * @param scene The scene the effect belongs to.
  25321. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  25322. * @param bloomKernel The size of the kernel to be used when applying the blur.
  25323. * @param bloomWeight The the strength of bloom.
  25324. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  25325. * @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)
  25326. */
  25327. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  25328. /**
  25329. * Disposes each of the internal effects for a given camera.
  25330. * @param camera The camera to dispose the effect on.
  25331. */
  25332. disposeEffects(camera: Camera): void;
  25333. /**
  25334. * Internal
  25335. */
  25336. _updateEffects(): void;
  25337. /**
  25338. * Internal
  25339. * @returns if all the contained post processes are ready.
  25340. */
  25341. _isReady(): boolean;
  25342. }
  25343. }
  25344. declare module BABYLON {
  25345. /**
  25346. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  25347. */
  25348. class BloomMergePostProcess extends PostProcess {
  25349. /** Weight of the bloom to be added to the original input. */ weight: number;
  25350. /**
  25351. * Creates a new instance of @see BloomMergePostProcess
  25352. * @param name The name of the effect.
  25353. * @param originalFromInput Post process which's input will be used for the merge.
  25354. * @param blurred Blurred highlights post process which's output will be used.
  25355. * @param weight Weight of the bloom to be added to the original input.
  25356. * @param options The required width/height ratio to downsize to before computing the render pass.
  25357. * @param camera The camera to apply the render pass to.
  25358. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25359. * @param engine The engine which the post process will be applied. (default: current engine)
  25360. * @param reusable If the post process can be reused on the same frame. (default: false)
  25361. * @param textureType Type of textures used when performing the post process. (default: 0)
  25362. * @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)
  25363. */
  25364. 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);
  25365. }
  25366. }
  25367. declare module BABYLON {
  25368. /**
  25369. * The Blur Post Process which blurs an image based on a kernel and direction.
  25370. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  25371. */
  25372. class BlurPostProcess extends PostProcess {
  25373. /** The direction in which to blur the image. */ direction: Vector2;
  25374. private blockCompilation;
  25375. protected _kernel: number;
  25376. protected _idealKernel: number;
  25377. protected _packedFloat: boolean;
  25378. private _staticDefines;
  25379. /**
  25380. * Gets the length in pixels of the blur sample region
  25381. */
  25382. /**
  25383. * Sets the length in pixels of the blur sample region
  25384. */
  25385. kernel: number;
  25386. /**
  25387. * Gets wether or not the blur is unpacking/repacking floats
  25388. */
  25389. /**
  25390. * Sets wether or not the blur needs to unpack/repack floats
  25391. */
  25392. packedFloat: boolean;
  25393. /**
  25394. * Creates a new instance BlurPostProcess
  25395. * @param name The name of the effect.
  25396. * @param direction The direction in which to blur the image.
  25397. * @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.
  25398. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  25399. * @param camera The camera to apply the render pass to.
  25400. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25401. * @param engine The engine which the post process will be applied. (default: current engine)
  25402. * @param reusable If the post process can be reused on the same frame. (default: false)
  25403. * @param textureType Type of textures used when performing the post process. (default: 0)
  25404. * @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)
  25405. */
  25406. 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);
  25407. /**
  25408. * Updates the effect with the current post process compile time values and recompiles the shader.
  25409. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25410. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25411. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25412. * @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
  25413. * @param onCompiled Called when the shader has been compiled.
  25414. * @param onError Called if there is an error when compiling a shader.
  25415. */
  25416. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25417. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25418. /**
  25419. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  25420. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  25421. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  25422. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  25423. * The gaps between physical kernels are compensated for in the weighting of the samples
  25424. * @param idealKernel Ideal blur kernel.
  25425. * @return Nearest best kernel.
  25426. */
  25427. protected _nearestBestKernel(idealKernel: number): number;
  25428. /**
  25429. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  25430. * @param x The point on the Gaussian distribution to sample.
  25431. * @return the value of the Gaussian function at x.
  25432. */
  25433. protected _gaussianWeight(x: number): number;
  25434. /**
  25435. * Generates a string that can be used as a floating point number in GLSL.
  25436. * @param x Value to print.
  25437. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  25438. * @return GLSL float string.
  25439. */
  25440. protected _glslFloat(x: number, decimalFigures?: number): string;
  25441. }
  25442. }
  25443. declare module BABYLON {
  25444. /**
  25445. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  25446. */
  25447. class ChromaticAberrationPostProcess extends PostProcess {
  25448. /**
  25449. * The amount of seperation of rgb channels (default: 30)
  25450. */
  25451. aberrationAmount: number;
  25452. /**
  25453. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  25454. */
  25455. radialIntensity: number;
  25456. /**
  25457. * 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))
  25458. */
  25459. direction: Vector2;
  25460. /**
  25461. * 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))
  25462. */
  25463. centerPosition: Vector2;
  25464. /**
  25465. * Creates a new instance ChromaticAberrationPostProcess
  25466. * @param name The name of the effect.
  25467. * @param screenWidth The width of the screen to apply the effect on.
  25468. * @param screenHeight The height of the screen to apply the effect on.
  25469. * @param options The required width/height ratio to downsize to before computing the render pass.
  25470. * @param camera The camera to apply the render pass to.
  25471. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25472. * @param engine The engine which the post process will be applied. (default: current engine)
  25473. * @param reusable If the post process can be reused on the same frame. (default: false)
  25474. * @param textureType Type of textures used when performing the post process. (default: 0)
  25475. * @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)
  25476. */
  25477. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25478. }
  25479. }
  25480. declare module BABYLON {
  25481. /**
  25482. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  25483. */
  25484. class CircleOfConfusionPostProcess extends PostProcess {
  25485. /**
  25486. * 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.
  25487. */
  25488. lensSize: number;
  25489. /**
  25490. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25491. */
  25492. fStop: number;
  25493. /**
  25494. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25495. */
  25496. focusDistance: number;
  25497. /**
  25498. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  25499. */
  25500. focalLength: number;
  25501. private _depthTexture;
  25502. /**
  25503. * Creates a new instance CircleOfConfusionPostProcess
  25504. * @param name The name of the effect.
  25505. * @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.
  25506. * @param options The required width/height ratio to downsize to before computing the render pass.
  25507. * @param camera The camera to apply the render pass to.
  25508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25509. * @param engine The engine which the post process will be applied. (default: current engine)
  25510. * @param reusable If the post process can be reused on the same frame. (default: false)
  25511. * @param textureType Type of textures used when performing the post process. (default: 0)
  25512. * @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)
  25513. */
  25514. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25515. /**
  25516. * 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.
  25517. */
  25518. depthTexture: RenderTargetTexture;
  25519. }
  25520. }
  25521. declare module BABYLON {
  25522. class ColorCorrectionPostProcess extends PostProcess {
  25523. private _colorTableTexture;
  25524. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25525. }
  25526. }
  25527. declare module BABYLON {
  25528. /**
  25529. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  25530. * input texture to perform effects such as edge detection or sharpening
  25531. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  25532. */
  25533. class ConvolutionPostProcess extends PostProcess {
  25534. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  25535. /**
  25536. * Creates a new instance ConvolutionPostProcess
  25537. * @param name The name of the effect.
  25538. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  25539. * @param options The required width/height ratio to downsize to before computing the render pass.
  25540. * @param camera The camera to apply the render pass to.
  25541. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25542. * @param engine The engine which the post process will be applied. (default: current engine)
  25543. * @param reusable If the post process can be reused on the same frame. (default: false)
  25544. * @param textureType Type of textures used when performing the post process. (default: 0)
  25545. */
  25546. 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);
  25547. /**
  25548. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25549. */
  25550. static EdgeDetect0Kernel: number[];
  25551. /**
  25552. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25553. */
  25554. static EdgeDetect1Kernel: number[];
  25555. /**
  25556. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25557. */
  25558. static EdgeDetect2Kernel: number[];
  25559. /**
  25560. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25561. */
  25562. static SharpenKernel: number[];
  25563. /**
  25564. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25565. */
  25566. static EmbossKernel: number[];
  25567. /**
  25568. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25569. */
  25570. static GaussianKernel: number[];
  25571. }
  25572. }
  25573. declare module BABYLON {
  25574. /**
  25575. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  25576. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  25577. * based on samples that have a large difference in distance than the center pixel.
  25578. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  25579. */
  25580. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  25581. direction: Vector2;
  25582. /**
  25583. * Creates a new instance CircleOfConfusionPostProcess
  25584. * @param name The name of the effect.
  25585. * @param scene The scene the effect belongs to.
  25586. * @param direction The direction the blur should be applied.
  25587. * @param kernel The size of the kernel used to blur.
  25588. * @param options The required width/height ratio to downsize to before computing the render pass.
  25589. * @param camera The camera to apply the render pass to.
  25590. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  25591. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  25592. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25593. * @param engine The engine which the post process will be applied. (default: current engine)
  25594. * @param reusable If the post process can be reused on the same frame. (default: false)
  25595. * @param textureType Type of textures used when performing the post process. (default: 0)
  25596. * @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)
  25597. */
  25598. 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);
  25599. }
  25600. }
  25601. declare module BABYLON {
  25602. /**
  25603. * Specifies the level of max blur that should be applied when using the depth of field effect
  25604. */
  25605. enum DepthOfFieldEffectBlurLevel {
  25606. /**
  25607. * Subtle blur
  25608. */
  25609. Low = 0,
  25610. /**
  25611. * Medium blur
  25612. */
  25613. Medium = 1,
  25614. /**
  25615. * Large blur
  25616. */
  25617. High = 2,
  25618. }
  25619. /**
  25620. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  25621. */
  25622. class DepthOfFieldEffect extends PostProcessRenderEffect {
  25623. private _circleOfConfusion;
  25624. /**
  25625. * Internal, blurs from high to low
  25626. */
  25627. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  25628. private _depthOfFieldBlurY;
  25629. private _dofMerge;
  25630. /**
  25631. * Internal post processes in depth of field effect
  25632. */
  25633. _effects: Array<PostProcess>;
  25634. /**
  25635. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  25636. */
  25637. focalLength: number;
  25638. /**
  25639. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25640. */
  25641. fStop: number;
  25642. /**
  25643. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25644. */
  25645. focusDistance: number;
  25646. /**
  25647. * 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.
  25648. */
  25649. lensSize: number;
  25650. /**
  25651. * Creates a new instance DepthOfFieldEffect
  25652. * @param scene The scene the effect belongs to.
  25653. * @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.
  25654. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  25655. * @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)
  25656. */
  25657. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  25658. /**
  25659. * 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.
  25660. */
  25661. depthTexture: RenderTargetTexture;
  25662. /**
  25663. * Disposes each of the internal effects for a given camera.
  25664. * @param camera The camera to dispose the effect on.
  25665. */
  25666. disposeEffects(camera: Camera): void;
  25667. /**
  25668. * Internal
  25669. */
  25670. _updateEffects(): void;
  25671. /**
  25672. * Internal
  25673. * @returns if all the contained post processes are ready.
  25674. */
  25675. _isReady(): boolean;
  25676. }
  25677. }
  25678. declare module BABYLON {
  25679. /**
  25680. * Options to be set when merging outputs from the default pipeline.
  25681. */
  25682. class DepthOfFieldMergePostProcessOptions {
  25683. /**
  25684. * The original image to merge on top of
  25685. */
  25686. originalFromInput: PostProcess;
  25687. /**
  25688. * Parameters to perform the merge of the depth of field effect
  25689. */
  25690. depthOfField?: {
  25691. circleOfConfusion: PostProcess;
  25692. blurSteps: Array<PostProcess>;
  25693. };
  25694. /**
  25695. * Parameters to perform the merge of bloom effect
  25696. */
  25697. bloom?: {
  25698. blurred: PostProcess;
  25699. weight: number;
  25700. };
  25701. }
  25702. /**
  25703. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  25704. */
  25705. class DepthOfFieldMergePostProcess extends PostProcess {
  25706. private blurSteps;
  25707. /**
  25708. * Creates a new instance of DepthOfFieldMergePostProcess
  25709. * @param name The name of the effect.
  25710. * @param originalFromInput Post process which's input will be used for the merge.
  25711. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  25712. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  25713. * @param options The required width/height ratio to downsize to before computing the render pass.
  25714. * @param camera The camera to apply the render pass to.
  25715. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25716. * @param engine The engine which the post process will be applied. (default: current engine)
  25717. * @param reusable If the post process can be reused on the same frame. (default: false)
  25718. * @param textureType Type of textures used when performing the post process. (default: 0)
  25719. * @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)
  25720. */
  25721. 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);
  25722. /**
  25723. * Updates the effect with the current post process compile time values and recompiles the shader.
  25724. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25725. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25726. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25727. * @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
  25728. * @param onCompiled Called when the shader has been compiled.
  25729. * @param onError Called if there is an error when compiling a shader.
  25730. */
  25731. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25732. }
  25733. }
  25734. declare module BABYLON {
  25735. class DisplayPassPostProcess extends PostProcess {
  25736. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25737. }
  25738. }
  25739. declare module BABYLON {
  25740. /**
  25741. * 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.
  25742. */
  25743. class ExtractHighlightsPostProcess extends PostProcess {
  25744. /**
  25745. * The luminance threshold, pixels below this value will be set to black.
  25746. */
  25747. threshold: number;
  25748. /**
  25749. * Internal
  25750. */
  25751. _exposure: number;
  25752. /**
  25753. * Post process which has the input texture to be used when performing highlight extraction
  25754. */
  25755. _inputPostProcess: Nullable<PostProcess>;
  25756. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25757. }
  25758. }
  25759. declare module BABYLON {
  25760. class FilterPostProcess extends PostProcess {
  25761. kernelMatrix: Matrix;
  25762. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25763. }
  25764. }
  25765. declare module BABYLON {
  25766. class FxaaPostProcess extends PostProcess {
  25767. texelWidth: number;
  25768. texelHeight: number;
  25769. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25770. private _getDefines();
  25771. }
  25772. }
  25773. declare module BABYLON {
  25774. /**
  25775. * The GrainPostProcess adds noise to the image at mid luminance levels
  25776. */
  25777. class GrainPostProcess extends PostProcess {
  25778. /**
  25779. * The intensity of the grain added (default: 30)
  25780. */
  25781. intensity: number;
  25782. /**
  25783. * If the grain should be randomized on every frame
  25784. */
  25785. animated: boolean;
  25786. /**
  25787. * Creates a new instance of @see GrainPostProcess
  25788. * @param name The name of the effect.
  25789. * @param options The required width/height ratio to downsize to before computing the render pass.
  25790. * @param camera The camera to apply the render pass to.
  25791. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25792. * @param engine The engine which the post process will be applied. (default: current engine)
  25793. * @param reusable If the post process can be reused on the same frame. (default: false)
  25794. * @param textureType Type of textures used when performing the post process. (default: 0)
  25795. * @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)
  25796. */
  25797. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25798. }
  25799. }
  25800. declare module BABYLON {
  25801. class HighlightsPostProcess extends PostProcess {
  25802. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25803. }
  25804. }
  25805. declare module BABYLON {
  25806. class ImageProcessingPostProcess extends PostProcess {
  25807. /**
  25808. * Default configuration related to image processing available in the PBR Material.
  25809. */
  25810. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25811. /**
  25812. * Gets the image processing configuration used either in this material.
  25813. */
  25814. /**
  25815. * Sets the Default image processing configuration used either in the this material.
  25816. *
  25817. * If sets to null, the scene one is in use.
  25818. */
  25819. imageProcessingConfiguration: ImageProcessingConfiguration;
  25820. /**
  25821. * Keep track of the image processing observer to allow dispose and replace.
  25822. */
  25823. private _imageProcessingObserver;
  25824. /**
  25825. * Attaches a new image processing configuration to the PBR Material.
  25826. * @param configuration
  25827. */
  25828. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  25829. /**
  25830. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25831. */
  25832. /**
  25833. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25834. */
  25835. colorCurves: Nullable<ColorCurves>;
  25836. /**
  25837. * Gets wether the color curves effect is enabled.
  25838. */
  25839. /**
  25840. * Sets wether the color curves effect is enabled.
  25841. */
  25842. colorCurvesEnabled: boolean;
  25843. /**
  25844. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25845. */
  25846. /**
  25847. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25848. */
  25849. colorGradingTexture: Nullable<BaseTexture>;
  25850. /**
  25851. * Gets wether the color grading effect is enabled.
  25852. */
  25853. /**
  25854. * Gets wether the color grading effect is enabled.
  25855. */
  25856. colorGradingEnabled: boolean;
  25857. /**
  25858. * Gets exposure used in the effect.
  25859. */
  25860. /**
  25861. * Sets exposure used in the effect.
  25862. */
  25863. exposure: number;
  25864. /**
  25865. * Gets wether tonemapping is enabled or not.
  25866. */
  25867. /**
  25868. * Sets wether tonemapping is enabled or not
  25869. */
  25870. toneMappingEnabled: boolean;
  25871. /**
  25872. * Gets contrast used in the effect.
  25873. */
  25874. /**
  25875. * Sets contrast used in the effect.
  25876. */
  25877. contrast: number;
  25878. /**
  25879. * Gets Vignette stretch size.
  25880. */
  25881. /**
  25882. * Sets Vignette stretch size.
  25883. */
  25884. vignetteStretch: number;
  25885. /**
  25886. * Gets Vignette centre X Offset.
  25887. */
  25888. /**
  25889. * Sets Vignette centre X Offset.
  25890. */
  25891. vignetteCentreX: number;
  25892. /**
  25893. * Gets Vignette centre Y Offset.
  25894. */
  25895. /**
  25896. * Sets Vignette centre Y Offset.
  25897. */
  25898. vignetteCentreY: number;
  25899. /**
  25900. * Gets Vignette weight or intensity of the vignette effect.
  25901. */
  25902. /**
  25903. * Sets Vignette weight or intensity of the vignette effect.
  25904. */
  25905. vignetteWeight: number;
  25906. /**
  25907. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25908. * if vignetteEnabled is set to true.
  25909. */
  25910. /**
  25911. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25912. * if vignetteEnabled is set to true.
  25913. */
  25914. vignetteColor: Color4;
  25915. /**
  25916. * Gets Camera field of view used by the Vignette effect.
  25917. */
  25918. /**
  25919. * Sets Camera field of view used by the Vignette effect.
  25920. */
  25921. vignetteCameraFov: number;
  25922. /**
  25923. * Gets the vignette blend mode allowing different kind of effect.
  25924. */
  25925. /**
  25926. * Sets the vignette blend mode allowing different kind of effect.
  25927. */
  25928. vignetteBlendMode: number;
  25929. /**
  25930. * Gets wether the vignette effect is enabled.
  25931. */
  25932. /**
  25933. * Sets wether the vignette effect is enabled.
  25934. */
  25935. vignetteEnabled: boolean;
  25936. private _fromLinearSpace;
  25937. /**
  25938. * Gets wether the input of the processing is in Gamma or Linear Space.
  25939. */
  25940. /**
  25941. * Sets wether the input of the processing is in Gamma or Linear Space.
  25942. */
  25943. fromLinearSpace: boolean;
  25944. /**
  25945. * Defines cache preventing GC.
  25946. */
  25947. private _defines;
  25948. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25949. getClassName(): string;
  25950. protected _updateParameters(): void;
  25951. dispose(camera?: Camera): void;
  25952. }
  25953. }
  25954. declare module BABYLON {
  25955. class PassPostProcess extends PostProcess {
  25956. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25957. }
  25958. }
  25959. declare module BABYLON {
  25960. type PostProcessOptions = {
  25961. width: number;
  25962. height: number;
  25963. };
  25964. /**
  25965. * PostProcess can be used to apply a shader to a texture after it has been rendered
  25966. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  25967. */
  25968. class PostProcess {
  25969. /** Name of the PostProcess. */ name: string;
  25970. /**
  25971. * Width of the texture to apply the post process on
  25972. */
  25973. width: number;
  25974. /**
  25975. * Height of the texture to apply the post process on
  25976. */
  25977. height: number;
  25978. /**
  25979. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  25980. */
  25981. _outputTexture: Nullable<InternalTexture>;
  25982. /**
  25983. * Sampling mode used by the shader
  25984. * See https://doc.babylonjs.com/classes/3.1/texture
  25985. */
  25986. renderTargetSamplingMode: number;
  25987. /**
  25988. * Clear color to use when screen clearing
  25989. */
  25990. clearColor: Color4;
  25991. /**
  25992. * If the buffer needs to be cleared before applying the post process. (default: true)
  25993. * Should be set to false if shader will overwrite all previous pixels.
  25994. */
  25995. autoClear: boolean;
  25996. /**
  25997. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  25998. */
  25999. alphaMode: number;
  26000. /**
  26001. * Sets the setAlphaBlendConstants of the babylon engine
  26002. */
  26003. alphaConstants: Color4;
  26004. /**
  26005. * Animations to be used for the post processing
  26006. */
  26007. animations: Animation[];
  26008. /**
  26009. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  26010. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  26011. */
  26012. enablePixelPerfectMode: boolean;
  26013. /**
  26014. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  26015. */
  26016. scaleMode: number;
  26017. /**
  26018. * Force textures to be a power of two (default: false)
  26019. */
  26020. alwaysForcePOT: boolean;
  26021. /**
  26022. * Number of sample textures (default: 1)
  26023. */
  26024. samples: number;
  26025. /**
  26026. * Modify the scale of the post process to be the same as the viewport (default: false)
  26027. */
  26028. adaptScaleToCurrentViewport: boolean;
  26029. private _camera;
  26030. private _scene;
  26031. private _engine;
  26032. private _options;
  26033. private _reusable;
  26034. private _textureType;
  26035. /**
  26036. * Smart array of input and output textures for the post process.
  26037. */
  26038. _textures: SmartArray<InternalTexture>;
  26039. /**
  26040. * The index in _textures that corresponds to the output texture.
  26041. */
  26042. _currentRenderTextureInd: number;
  26043. private _effect;
  26044. private _samplers;
  26045. private _fragmentUrl;
  26046. private _vertexUrl;
  26047. private _parameters;
  26048. private _scaleRatio;
  26049. protected _indexParameters: any;
  26050. private _shareOutputWithPostProcess;
  26051. private _texelSize;
  26052. private _forcedOutputTexture;
  26053. /**
  26054. * An event triggered when the postprocess is activated.
  26055. */
  26056. onActivateObservable: Observable<Camera>;
  26057. private _onActivateObserver;
  26058. /**
  26059. * A function that is added to the onActivateObservable
  26060. */
  26061. onActivate: Nullable<(camera: Camera) => void>;
  26062. /**
  26063. * An event triggered when the postprocess changes its size.
  26064. */
  26065. onSizeChangedObservable: Observable<PostProcess>;
  26066. private _onSizeChangedObserver;
  26067. /**
  26068. * A function that is added to the onSizeChangedObservable
  26069. */
  26070. onSizeChanged: (postProcess: PostProcess) => void;
  26071. /**
  26072. * An event triggered when the postprocess applies its effect.
  26073. */
  26074. onApplyObservable: Observable<Effect>;
  26075. private _onApplyObserver;
  26076. /**
  26077. * A function that is added to the onApplyObservable
  26078. */
  26079. onApply: (effect: Effect) => void;
  26080. /**
  26081. * An event triggered before rendering the postprocess
  26082. */
  26083. onBeforeRenderObservable: Observable<Effect>;
  26084. private _onBeforeRenderObserver;
  26085. /**
  26086. * A function that is added to the onBeforeRenderObservable
  26087. */
  26088. onBeforeRender: (effect: Effect) => void;
  26089. /**
  26090. * An event triggered after rendering the postprocess
  26091. */
  26092. onAfterRenderObservable: Observable<Effect>;
  26093. private _onAfterRenderObserver;
  26094. /**
  26095. * A function that is added to the onAfterRenderObservable
  26096. */
  26097. onAfterRender: (efect: Effect) => void;
  26098. /**
  26099. * 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
  26100. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  26101. */
  26102. inputTexture: InternalTexture;
  26103. /**
  26104. * Gets the camera which post process is applied to.
  26105. * @returns The camera the post process is applied to.
  26106. */
  26107. getCamera(): Camera;
  26108. /**
  26109. * Gets the texel size of the postprocess.
  26110. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  26111. */
  26112. readonly texelSize: Vector2;
  26113. /**
  26114. * Creates a new instance PostProcess
  26115. * @param name The name of the PostProcess.
  26116. * @param fragmentUrl The url of the fragment shader to be used.
  26117. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  26118. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  26119. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  26120. * @param camera The camera to apply the render pass to.
  26121. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26122. * @param engine The engine which the post process will be applied. (default: current engine)
  26123. * @param reusable If the post process can be reused on the same frame. (default: false)
  26124. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  26125. * @param textureType Type of textures used when performing the post process. (default: 0)
  26126. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  26127. * @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
  26128. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  26129. */
  26130. 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);
  26131. /**
  26132. * Gets the engine which this post process belongs to.
  26133. * @returns The engine the post process was enabled with.
  26134. */
  26135. getEngine(): Engine;
  26136. /**
  26137. * The effect that is created when initializing the post process.
  26138. * @returns The created effect corrisponding the the postprocess.
  26139. */
  26140. getEffect(): Effect;
  26141. /**
  26142. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  26143. * @param postProcess The post process to share the output with.
  26144. * @returns This post process.
  26145. */
  26146. shareOutputWith(postProcess: PostProcess): PostProcess;
  26147. /**
  26148. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  26149. * This should be called if the post process that shares output with this post process is disabled/disposed.
  26150. */
  26151. useOwnOutput(): void;
  26152. /**
  26153. * Updates the effect with the current post process compile time values and recompiles the shader.
  26154. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26155. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26156. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26157. * @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
  26158. * @param onCompiled Called when the shader has been compiled.
  26159. * @param onError Called if there is an error when compiling a shader.
  26160. */
  26161. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26162. /**
  26163. * The post process is reusable if it can be used multiple times within one frame.
  26164. * @returns If the post process is reusable
  26165. */
  26166. isReusable(): boolean;
  26167. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  26168. markTextureDirty(): void;
  26169. /**
  26170. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  26171. * 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.
  26172. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  26173. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  26174. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  26175. * @returns The target texture that was bound to be written to.
  26176. */
  26177. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  26178. /**
  26179. * If the post process is supported.
  26180. */
  26181. readonly isSupported: boolean;
  26182. /**
  26183. * The aspect ratio of the output texture.
  26184. */
  26185. readonly aspectRatio: number;
  26186. /**
  26187. * Get a value indicating if the post-process is ready to be used
  26188. * @returns true if the post-process is ready (shader is compiled)
  26189. */
  26190. isReady(): boolean;
  26191. /**
  26192. * Binds all textures and uniforms to the shader, this will be run on every pass.
  26193. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  26194. */
  26195. apply(): Nullable<Effect>;
  26196. private _disposeTextures();
  26197. /**
  26198. * Disposes the post process.
  26199. * @param camera The camera to dispose the post process on.
  26200. */
  26201. dispose(camera?: Camera): void;
  26202. }
  26203. }
  26204. declare module BABYLON {
  26205. /**
  26206. * PostProcessManager is used to manage one or more post processes or post process pipelines
  26207. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  26208. */
  26209. class PostProcessManager {
  26210. private _scene;
  26211. private _indexBuffer;
  26212. private _vertexBuffers;
  26213. /**
  26214. * Creates a new instance PostProcess
  26215. * @param scene The scene that the post process is associated with.
  26216. */
  26217. constructor(scene: Scene);
  26218. private _prepareBuffers();
  26219. private _buildIndexBuffer();
  26220. /**
  26221. * Rebuilds the vertex buffers of the manager.
  26222. */
  26223. _rebuild(): void;
  26224. /**
  26225. * Prepares a frame to be run through a post process.
  26226. * @param sourceTexture The input texture to the post procesess. (default: null)
  26227. * @param postProcesses An array of post processes to be run. (default: null)
  26228. * @returns True if the post processes were able to be run.
  26229. */
  26230. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  26231. /**
  26232. * Manually render a set of post processes to a texture.
  26233. * @param postProcesses An array of post processes to be run.
  26234. * @param targetTexture The target texture to render to.
  26235. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  26236. */
  26237. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  26238. /**
  26239. * Finalize the result of the output of the postprocesses.
  26240. * @param doNotPresent If true the result will not be displayed to the screen.
  26241. * @param targetTexture The target texture to render to.
  26242. * @param faceIndex The index of the face to bind the target texture to.
  26243. * @param postProcesses The array of post processes to render.
  26244. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  26245. */
  26246. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  26247. /**
  26248. * Disposes of the post process manager.
  26249. */
  26250. dispose(): void;
  26251. }
  26252. }
  26253. declare module BABYLON {
  26254. class RefractionPostProcess extends PostProcess {
  26255. color: Color3;
  26256. depth: number;
  26257. colorLevel: number;
  26258. private _refTexture;
  26259. private _ownRefractionTexture;
  26260. /**
  26261. * Gets or sets the refraction texture
  26262. * Please note that you are responsible for disposing the texture if you set it manually
  26263. */
  26264. refractionTexture: Texture;
  26265. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26266. dispose(camera: Camera): void;
  26267. }
  26268. }
  26269. declare module BABYLON {
  26270. /**
  26271. * The SharpenPostProcess applies a sharpen kernel to every pixel
  26272. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  26273. */
  26274. class SharpenPostProcess extends PostProcess {
  26275. /**
  26276. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  26277. */
  26278. colorAmount: number;
  26279. /**
  26280. * How much sharpness should be applied (default: 0.3)
  26281. */
  26282. edgeAmount: number;
  26283. /**
  26284. * Creates a new instance ConvolutionPostProcess
  26285. * @param name The name of the effect.
  26286. * @param options The required width/height ratio to downsize to before computing the render pass.
  26287. * @param camera The camera to apply the render pass to.
  26288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26289. * @param engine The engine which the post process will be applied. (default: current engine)
  26290. * @param reusable If the post process can be reused on the same frame. (default: false)
  26291. * @param textureType Type of textures used when performing the post process. (default: 0)
  26292. * @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)
  26293. */
  26294. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26295. }
  26296. }
  26297. declare module BABYLON {
  26298. class StereoscopicInterlacePostProcess extends PostProcess {
  26299. private _stepSize;
  26300. private _passedProcess;
  26301. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26302. }
  26303. }
  26304. declare module BABYLON {
  26305. /** Defines operator used for tonemapping */
  26306. enum TonemappingOperator {
  26307. /** Hable */
  26308. Hable = 0,
  26309. /** Reinhard */
  26310. Reinhard = 1,
  26311. /** HejiDawson */
  26312. HejiDawson = 2,
  26313. /** Photographic */
  26314. Photographic = 3,
  26315. }
  26316. /**
  26317. * Defines a post process to apply tone mapping
  26318. */
  26319. class TonemapPostProcess extends PostProcess {
  26320. private _operator;
  26321. /** Defines the required exposure adjustement */
  26322. exposureAdjustment: number;
  26323. /**
  26324. * Creates a new TonemapPostProcess
  26325. * @param name defines the name of the postprocess
  26326. * @param _operator defines the operator to use
  26327. * @param exposureAdjustment defines the required exposure adjustement
  26328. * @param camera defines the camera to use (can be null)
  26329. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  26330. * @param engine defines the hosting engine (can be ignore if camera is set)
  26331. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  26332. */
  26333. constructor(name: string, _operator: TonemappingOperator,
  26334. /** Defines the required exposure adjustement */
  26335. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  26336. }
  26337. }
  26338. declare module BABYLON {
  26339. class VolumetricLightScatteringPostProcess extends PostProcess {
  26340. private _volumetricLightScatteringPass;
  26341. private _volumetricLightScatteringRTT;
  26342. private _viewPort;
  26343. private _screenCoordinates;
  26344. private _cachedDefines;
  26345. /**
  26346. * If not undefined, the mesh position is computed from the attached node position
  26347. */
  26348. attachedNode: {
  26349. position: Vector3;
  26350. };
  26351. /**
  26352. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  26353. */
  26354. customMeshPosition: Vector3;
  26355. /**
  26356. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  26357. */
  26358. useCustomMeshPosition: boolean;
  26359. /**
  26360. * If the post-process should inverse the light scattering direction
  26361. */
  26362. invert: boolean;
  26363. /**
  26364. * The internal mesh used by the post-process
  26365. */
  26366. mesh: Mesh;
  26367. useDiffuseColor: boolean;
  26368. /**
  26369. * Array containing the excluded meshes not rendered in the internal pass
  26370. */
  26371. excludedMeshes: AbstractMesh[];
  26372. /**
  26373. * Controls the overall intensity of the post-process
  26374. */
  26375. exposure: number;
  26376. /**
  26377. * Dissipates each sample's contribution in range [0, 1]
  26378. */
  26379. decay: number;
  26380. /**
  26381. * Controls the overall intensity of each sample
  26382. */
  26383. weight: number;
  26384. /**
  26385. * Controls the density of each sample
  26386. */
  26387. density: number;
  26388. /**
  26389. * @constructor
  26390. * @param {string} name - The post-process name
  26391. * @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)
  26392. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  26393. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  26394. * @param {number} samples - The post-process quality, default 100
  26395. * @param {number} samplingMode - The post-process filtering mode
  26396. * @param {BABYLON.Engine} engine - The babylon engine
  26397. * @param {boolean} reusable - If the post-process is reusable
  26398. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  26399. */
  26400. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  26401. getClassName(): string;
  26402. private _isReady(subMesh, useInstances);
  26403. /**
  26404. * Sets the new light position for light scattering effect
  26405. * @param {BABYLON.Vector3} The new custom light position
  26406. */
  26407. setCustomMeshPosition(position: Vector3): void;
  26408. /**
  26409. * Returns the light position for light scattering effect
  26410. * @return {BABYLON.Vector3} The custom light position
  26411. */
  26412. getCustomMeshPosition(): Vector3;
  26413. /**
  26414. * Disposes the internal assets and detaches the post-process from the camera
  26415. */
  26416. dispose(camera: Camera): void;
  26417. /**
  26418. * Returns the render target texture used by the post-process
  26419. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  26420. */
  26421. getPass(): RenderTargetTexture;
  26422. private _meshExcluded(mesh);
  26423. private _createPass(scene, ratio);
  26424. private _updateMeshScreenCoordinates(scene);
  26425. /**
  26426. * Creates a default mesh for the Volumeric Light Scattering post-process
  26427. * @param {string} The mesh name
  26428. * @param {BABYLON.Scene} The scene where to create the mesh
  26429. * @return {BABYLON.Mesh} the default mesh
  26430. */
  26431. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  26432. }
  26433. }
  26434. declare module BABYLON {
  26435. class VRDistortionCorrectionPostProcess extends PostProcess {
  26436. private _isRightEye;
  26437. private _distortionFactors;
  26438. private _postProcessScaleFactor;
  26439. private _lensCenterOffset;
  26440. private _scaleIn;
  26441. private _scaleFactor;
  26442. private _lensCenter;
  26443. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  26444. }
  26445. }
  26446. declare module BABYLON {
  26447. /**
  26448. * Class used to evalaute queries containing `and` and `or` operators
  26449. */
  26450. class AndOrNotEvaluator {
  26451. /**
  26452. * Evaluate a query
  26453. * @param query defines the query to evaluate
  26454. * @param evaluateCallback defines the callback used to filter result
  26455. * @returns true if the query matches
  26456. */
  26457. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  26458. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  26459. private static _SimplifyNegation(booleanString);
  26460. }
  26461. }
  26462. declare module BABYLON {
  26463. /**
  26464. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  26465. */
  26466. enum AssetTaskState {
  26467. /**
  26468. * Initialization
  26469. */
  26470. INIT = 0,
  26471. /**
  26472. * Running
  26473. */
  26474. RUNNING = 1,
  26475. /**
  26476. * Done
  26477. */
  26478. DONE = 2,
  26479. /**
  26480. * Error
  26481. */
  26482. ERROR = 3,
  26483. }
  26484. /**
  26485. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  26486. */
  26487. abstract class AbstractAssetTask {
  26488. /**
  26489. * Task name
  26490. */ name: string;
  26491. /**
  26492. * Callback called when the task is successful
  26493. */
  26494. onSuccess: (task: any) => void;
  26495. /**
  26496. * Callback called when the task is not successful
  26497. */
  26498. onError: (task: any, message?: string, exception?: any) => void;
  26499. /**
  26500. * Creates a new {BABYLON.AssetsManager}
  26501. * @param name defines the name of the task
  26502. */
  26503. constructor(
  26504. /**
  26505. * Task name
  26506. */ name: string);
  26507. private _isCompleted;
  26508. private _taskState;
  26509. private _errorObject;
  26510. /**
  26511. * Get if the task is completed
  26512. */
  26513. readonly isCompleted: boolean;
  26514. /**
  26515. * Gets the current state of the task
  26516. */
  26517. readonly taskState: AssetTaskState;
  26518. /**
  26519. * Gets the current error object (if task is in error)
  26520. */
  26521. readonly errorObject: {
  26522. message?: string;
  26523. exception?: any;
  26524. };
  26525. /**
  26526. * Internal only
  26527. * @hidden
  26528. */
  26529. _setErrorObject(message?: string, exception?: any): void;
  26530. /**
  26531. * Execute the current task
  26532. * @param scene defines the scene where you want your assets to be loaded
  26533. * @param onSuccess is a callback called when the task is successfully executed
  26534. * @param onError is a callback called if an error occurs
  26535. */
  26536. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26537. /**
  26538. * Execute the current task
  26539. * @param scene defines the scene where you want your assets to be loaded
  26540. * @param onSuccess is a callback called when the task is successfully executed
  26541. * @param onError is a callback called if an error occurs
  26542. */
  26543. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26544. private onErrorCallback(onError, message?, exception?);
  26545. private onDoneCallback(onSuccess, onError);
  26546. }
  26547. /**
  26548. * Define the interface used by progress events raised during assets loading
  26549. */
  26550. interface IAssetsProgressEvent {
  26551. /**
  26552. * Defines the number of remaining tasks to process
  26553. */
  26554. remainingCount: number;
  26555. /**
  26556. * Defines the total number of tasks
  26557. */
  26558. totalCount: number;
  26559. /**
  26560. * Defines the task that was just processed
  26561. */
  26562. task: AbstractAssetTask;
  26563. }
  26564. /**
  26565. * Class used to share progress information about assets loading
  26566. */
  26567. class AssetsProgressEvent implements IAssetsProgressEvent {
  26568. /**
  26569. * Defines the number of remaining tasks to process
  26570. */
  26571. remainingCount: number;
  26572. /**
  26573. * Defines the total number of tasks
  26574. */
  26575. totalCount: number;
  26576. /**
  26577. * Defines the task that was just processed
  26578. */
  26579. task: AbstractAssetTask;
  26580. /**
  26581. * Creates a {BABYLON.AssetsProgressEvent}
  26582. * @param remainingCount defines the number of remaining tasks to process
  26583. * @param totalCount defines the total number of tasks
  26584. * @param task defines the task that was just processed
  26585. */
  26586. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  26587. }
  26588. /**
  26589. * Define a task used by {BABYLON.AssetsManager} to load meshes
  26590. */
  26591. class MeshAssetTask extends AbstractAssetTask {
  26592. /**
  26593. * Defines the name of the task
  26594. */
  26595. name: string;
  26596. /**
  26597. * Defines the list of mesh's names you want to load
  26598. */
  26599. meshesNames: any;
  26600. /**
  26601. * Defines the root url to use as a base to load your meshes and associated resources
  26602. */
  26603. rootUrl: string;
  26604. /**
  26605. * Defines the filename of the scene to load from
  26606. */
  26607. sceneFilename: string;
  26608. /**
  26609. * Gets the list of loaded meshes
  26610. */
  26611. loadedMeshes: Array<AbstractMesh>;
  26612. /**
  26613. * Gets the list of loaded particle systems
  26614. */
  26615. loadedParticleSystems: Array<ParticleSystem>;
  26616. /**
  26617. * Gets the list of loaded skeletons
  26618. */
  26619. loadedSkeletons: Array<Skeleton>;
  26620. /**
  26621. * Callback called when the task is successful
  26622. */
  26623. onSuccess: (task: MeshAssetTask) => void;
  26624. /**
  26625. * Callback called when the task is successful
  26626. */
  26627. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  26628. /**
  26629. * Creates a new {BABYLON.MeshAssetTask}
  26630. * @param name defines the name of the task
  26631. * @param meshesNames defines the list of mesh's names you want to load
  26632. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  26633. * @param sceneFilename defines the filename of the scene to load from
  26634. */
  26635. constructor(
  26636. /**
  26637. * Defines the name of the task
  26638. */
  26639. name: string,
  26640. /**
  26641. * Defines the list of mesh's names you want to load
  26642. */
  26643. meshesNames: any,
  26644. /**
  26645. * Defines the root url to use as a base to load your meshes and associated resources
  26646. */
  26647. rootUrl: string,
  26648. /**
  26649. * Defines the filename of the scene to load from
  26650. */
  26651. sceneFilename: string);
  26652. /**
  26653. * Execute the current task
  26654. * @param scene defines the scene where you want your assets to be loaded
  26655. * @param onSuccess is a callback called when the task is successfully executed
  26656. * @param onError is a callback called if an error occurs
  26657. */
  26658. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26659. }
  26660. /**
  26661. * Define a task used by {BABYLON.AssetsManager} to load text content
  26662. */
  26663. class TextFileAssetTask extends AbstractAssetTask {
  26664. /**
  26665. * Defines the name of the task
  26666. */
  26667. name: string;
  26668. /**
  26669. * Defines the location of the file to load
  26670. */
  26671. url: string;
  26672. /**
  26673. * Gets the loaded text string
  26674. */
  26675. text: string;
  26676. /**
  26677. * Callback called when the task is successful
  26678. */
  26679. onSuccess: (task: TextFileAssetTask) => void;
  26680. /**
  26681. * Callback called when the task is successful
  26682. */
  26683. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  26684. /**
  26685. * Creates a new TextFileAssetTask object
  26686. * @param name defines the name of the task
  26687. * @param url defines the location of the file to load
  26688. */
  26689. constructor(
  26690. /**
  26691. * Defines the name of the task
  26692. */
  26693. name: string,
  26694. /**
  26695. * Defines the location of the file to load
  26696. */
  26697. url: string);
  26698. /**
  26699. * Execute the current task
  26700. * @param scene defines the scene where you want your assets to be loaded
  26701. * @param onSuccess is a callback called when the task is successfully executed
  26702. * @param onError is a callback called if an error occurs
  26703. */
  26704. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26705. }
  26706. /**
  26707. * Define a task used by {BABYLON.AssetsManager} to load binary data
  26708. */
  26709. class BinaryFileAssetTask extends AbstractAssetTask {
  26710. /**
  26711. * Defines the name of the task
  26712. */
  26713. name: string;
  26714. /**
  26715. * Defines the location of the file to load
  26716. */
  26717. url: string;
  26718. /**
  26719. * Gets the lodaded data (as an array buffer)
  26720. */
  26721. data: ArrayBuffer;
  26722. /**
  26723. * Callback called when the task is successful
  26724. */
  26725. onSuccess: (task: BinaryFileAssetTask) => void;
  26726. /**
  26727. * Callback called when the task is successful
  26728. */
  26729. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  26730. /**
  26731. * Creates a new BinaryFileAssetTask object
  26732. * @param name defines the name of the new task
  26733. * @param url defines the location of the file to load
  26734. */
  26735. constructor(
  26736. /**
  26737. * Defines the name of the task
  26738. */
  26739. name: string,
  26740. /**
  26741. * Defines the location of the file to load
  26742. */
  26743. url: string);
  26744. /**
  26745. * Execute the current task
  26746. * @param scene defines the scene where you want your assets to be loaded
  26747. * @param onSuccess is a callback called when the task is successfully executed
  26748. * @param onError is a callback called if an error occurs
  26749. */
  26750. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26751. }
  26752. /**
  26753. * Define a task used by {BABYLON.AssetsManager} to load images
  26754. */
  26755. class ImageAssetTask extends AbstractAssetTask {
  26756. /**
  26757. * Defines the name of the task
  26758. */
  26759. name: string;
  26760. /**
  26761. * Defines the location of the image to load
  26762. */
  26763. url: string;
  26764. /**
  26765. * Gets the loaded images
  26766. */
  26767. image: HTMLImageElement;
  26768. /**
  26769. * Callback called when the task is successful
  26770. */
  26771. onSuccess: (task: ImageAssetTask) => void;
  26772. /**
  26773. * Callback called when the task is successful
  26774. */
  26775. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  26776. /**
  26777. * Creates a new ImageAssetTask
  26778. * @param name defines the name of the task
  26779. * @param url defines the location of the image to load
  26780. */
  26781. constructor(
  26782. /**
  26783. * Defines the name of the task
  26784. */
  26785. name: string,
  26786. /**
  26787. * Defines the location of the image to load
  26788. */
  26789. url: string);
  26790. /**
  26791. * Execute the current task
  26792. * @param scene defines the scene where you want your assets to be loaded
  26793. * @param onSuccess is a callback called when the task is successfully executed
  26794. * @param onError is a callback called if an error occurs
  26795. */
  26796. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26797. }
  26798. /**
  26799. * Defines the interface used by texture loading tasks
  26800. */
  26801. interface ITextureAssetTask<TEX extends BaseTexture> {
  26802. /**
  26803. * Gets the loaded texture
  26804. */
  26805. texture: TEX;
  26806. }
  26807. /**
  26808. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  26809. */
  26810. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  26811. /**
  26812. * Defines the name of the task
  26813. */
  26814. name: string;
  26815. /**
  26816. * Defines the location of the file to load
  26817. */
  26818. url: string;
  26819. /**
  26820. * Defines if mipmap should not be generated (default is false)
  26821. */
  26822. noMipmap: boolean | undefined;
  26823. /**
  26824. * Defines if texture must be inverted on Y axis (default is false)
  26825. */
  26826. invertY: boolean | undefined;
  26827. /**
  26828. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  26829. */
  26830. samplingMode: number;
  26831. /**
  26832. * Gets the loaded texture
  26833. */
  26834. texture: Texture;
  26835. /**
  26836. * Callback called when the task is successful
  26837. */
  26838. onSuccess: (task: TextureAssetTask) => void;
  26839. /**
  26840. * Callback called when the task is successful
  26841. */
  26842. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  26843. /**
  26844. * Creates a new TextureAssetTask object
  26845. * @param name defines the name of the task
  26846. * @param url defines the location of the file to load
  26847. * @param noMipmap defines if mipmap should not be generated (default is false)
  26848. * @param invertY defines if texture must be inverted on Y axis (default is false)
  26849. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  26850. */
  26851. constructor(
  26852. /**
  26853. * Defines the name of the task
  26854. */
  26855. name: string,
  26856. /**
  26857. * Defines the location of the file to load
  26858. */
  26859. url: string,
  26860. /**
  26861. * Defines if mipmap should not be generated (default is false)
  26862. */
  26863. noMipmap?: boolean | undefined,
  26864. /**
  26865. * Defines if texture must be inverted on Y axis (default is false)
  26866. */
  26867. invertY?: boolean | undefined,
  26868. /**
  26869. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  26870. */
  26871. samplingMode?: number);
  26872. /**
  26873. * Execute the current task
  26874. * @param scene defines the scene where you want your assets to be loaded
  26875. * @param onSuccess is a callback called when the task is successfully executed
  26876. * @param onError is a callback called if an error occurs
  26877. */
  26878. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26879. }
  26880. /**
  26881. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  26882. */
  26883. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  26884. /**
  26885. * Defines the name of the task
  26886. */
  26887. name: string;
  26888. /**
  26889. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  26890. */
  26891. url: string;
  26892. /**
  26893. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  26894. */
  26895. extensions: string[] | undefined;
  26896. /**
  26897. * Defines if mipmaps should not be generated (default is false)
  26898. */
  26899. noMipmap: boolean | undefined;
  26900. /**
  26901. * Defines the explicit list of files (undefined by default)
  26902. */
  26903. files: string[] | undefined;
  26904. /**
  26905. * Gets the loaded texture
  26906. */
  26907. texture: CubeTexture;
  26908. /**
  26909. * Callback called when the task is successful
  26910. */
  26911. onSuccess: (task: CubeTextureAssetTask) => void;
  26912. /**
  26913. * Callback called when the task is successful
  26914. */
  26915. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  26916. /**
  26917. * Creates a new CubeTextureAssetTask
  26918. * @param name defines the name of the task
  26919. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  26920. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  26921. * @param noMipmap defines if mipmaps should not be generated (default is false)
  26922. * @param files defines the explicit list of files (undefined by default)
  26923. */
  26924. constructor(
  26925. /**
  26926. * Defines the name of the task
  26927. */
  26928. name: string,
  26929. /**
  26930. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  26931. */
  26932. url: string,
  26933. /**
  26934. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  26935. */
  26936. extensions?: string[] | undefined,
  26937. /**
  26938. * Defines if mipmaps should not be generated (default is false)
  26939. */
  26940. noMipmap?: boolean | undefined,
  26941. /**
  26942. * Defines the explicit list of files (undefined by default)
  26943. */
  26944. files?: string[] | undefined);
  26945. /**
  26946. * Execute the current task
  26947. * @param scene defines the scene where you want your assets to be loaded
  26948. * @param onSuccess is a callback called when the task is successfully executed
  26949. * @param onError is a callback called if an error occurs
  26950. */
  26951. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  26952. }
  26953. /**
  26954. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  26955. */
  26956. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  26957. /**
  26958. * Defines the name of the task
  26959. */
  26960. name: string;
  26961. /**
  26962. * Defines the location of the file to load
  26963. */
  26964. url: string;
  26965. /**
  26966. * Defines the desired size (the more it increases the longer the generation will be)
  26967. */
  26968. size: number;
  26969. /**
  26970. * Defines if mipmaps should not be generated (default is false)
  26971. */
  26972. noMipmap: boolean;
  26973. /**
  26974. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  26975. */
  26976. generateHarmonics: boolean;
  26977. /**
  26978. * 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)
  26979. */
  26980. gammaSpace: boolean;
  26981. /**
  26982. * Internal Use Only
  26983. */
  26984. reserved: boolean;
  26985. /**
  26986. * Gets the loaded texture
  26987. */
  26988. texture: HDRCubeTexture;
  26989. /**
  26990. * Callback called when the task is successful
  26991. */
  26992. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  26993. /**
  26994. * Callback called when the task is successful
  26995. */
  26996. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  26997. /**
  26998. * Creates a new HDRCubeTextureAssetTask object
  26999. * @param name defines the name of the task
  27000. * @param url defines the location of the file to load
  27001. * @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.
  27002. * @param noMipmap defines if mipmaps should not be generated (default is false)
  27003. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27004. * @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)
  27005. * @param reserved Internal use only
  27006. */
  27007. constructor(
  27008. /**
  27009. * Defines the name of the task
  27010. */
  27011. name: string,
  27012. /**
  27013. * Defines the location of the file to load
  27014. */
  27015. url: string,
  27016. /**
  27017. * Defines the desired size (the more it increases the longer the generation will be)
  27018. */
  27019. size: number,
  27020. /**
  27021. * Defines if mipmaps should not be generated (default is false)
  27022. */
  27023. noMipmap?: boolean,
  27024. /**
  27025. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27026. */
  27027. generateHarmonics?: boolean,
  27028. /**
  27029. * 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)
  27030. */
  27031. gammaSpace?: boolean,
  27032. /**
  27033. * Internal Use Only
  27034. */
  27035. reserved?: boolean);
  27036. /**
  27037. * Execute the current task
  27038. * @param scene defines the scene where you want your assets to be loaded
  27039. * @param onSuccess is a callback called when the task is successfully executed
  27040. * @param onError is a callback called if an error occurs
  27041. */
  27042. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27043. }
  27044. /**
  27045. * This class can be used to easily import assets into a scene
  27046. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  27047. */
  27048. class AssetsManager {
  27049. private _scene;
  27050. private _isLoading;
  27051. protected _tasks: AbstractAssetTask[];
  27052. protected _waitingTasksCount: number;
  27053. protected _totalTasksCount: number;
  27054. /**
  27055. * Callback called when all tasks are processed
  27056. */
  27057. onFinish: (tasks: AbstractAssetTask[]) => void;
  27058. /**
  27059. * Callback called when a task is successful
  27060. */
  27061. onTaskSuccess: (task: AbstractAssetTask) => void;
  27062. /**
  27063. * Callback called when a task had an error
  27064. */
  27065. onTaskError: (task: AbstractAssetTask) => void;
  27066. /**
  27067. * Callback called when a task is done (whatever the result is)
  27068. */
  27069. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  27070. /**
  27071. * Observable called when all tasks are processed
  27072. */
  27073. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  27074. /**
  27075. * Observable called when a task had an error
  27076. */
  27077. onTaskErrorObservable: Observable<AbstractAssetTask>;
  27078. /**
  27079. * Observable called when a task is successful
  27080. */
  27081. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  27082. /**
  27083. * Observable called when a task is done (whatever the result is)
  27084. */
  27085. onProgressObservable: Observable<IAssetsProgressEvent>;
  27086. /**
  27087. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  27088. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27089. */
  27090. useDefaultLoadingScreen: boolean;
  27091. /**
  27092. * Creates a new AssetsManager
  27093. * @param scene defines the scene to work on
  27094. */
  27095. constructor(scene: Scene);
  27096. /**
  27097. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  27098. * @param taskName defines the name of the new task
  27099. * @param meshesNames defines the name of meshes to load
  27100. * @param rootUrl defines the root url to use to locate files
  27101. * @param sceneFilename defines the filename of the scene file
  27102. * @returns a new {BABYLON.MeshAssetTask} object
  27103. */
  27104. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  27105. /**
  27106. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  27107. * @param taskName defines the name of the new task
  27108. * @param url defines the url of the file to load
  27109. * @returns a new {BABYLON.TextFileAssetTask} object
  27110. */
  27111. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  27112. /**
  27113. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  27114. * @param taskName defines the name of the new task
  27115. * @param url defines the url of the file to load
  27116. * @returns a new {BABYLON.BinaryFileAssetTask} object
  27117. */
  27118. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  27119. /**
  27120. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  27121. * @param taskName defines the name of the new task
  27122. * @param url defines the url of the file to load
  27123. * @returns a new {BABYLON.ImageAssetTask} object
  27124. */
  27125. addImageTask(taskName: string, url: string): ImageAssetTask;
  27126. /**
  27127. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  27128. * @param taskName defines the name of the new task
  27129. * @param url defines the url of the file to load
  27130. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27131. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  27132. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  27133. * @returns a new {BABYLON.TextureAssetTask} object
  27134. */
  27135. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  27136. /**
  27137. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  27138. * @param taskName defines the name of the new task
  27139. * @param url defines the url of the file to load
  27140. * @param extensions defines the extension to use to load the cube map (can be null)
  27141. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27142. * @param files defines the list of files to load (can be null)
  27143. * @returns a new {BABYLON.CubeTextureAssetTask} object
  27144. */
  27145. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  27146. /**
  27147. *
  27148. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  27149. * @param taskName defines the name of the new task
  27150. * @param url defines the url of the file to load
  27151. * @param size defines the size you want for the cubemap (can be null)
  27152. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27153. * @param generateHarmonics defines if you want to automatically generate (true by default)
  27154. * @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)
  27155. * @param reserved Internal use only
  27156. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  27157. */
  27158. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  27159. private _decreaseWaitingTasksCount(task);
  27160. private _runTask(task);
  27161. /**
  27162. * Reset the {BABYLON.AssetsManager} and remove all tasks
  27163. * @return the current instance of the {BABYLON.AssetsManager}
  27164. */
  27165. reset(): AssetsManager;
  27166. /**
  27167. * Start the loading process
  27168. * @return the current instance of the {BABYLON.AssetsManager}
  27169. */
  27170. load(): AssetsManager;
  27171. }
  27172. }
  27173. declare module BABYLON {
  27174. /**
  27175. * Class used to enable access to IndexedDB
  27176. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  27177. */
  27178. class Database {
  27179. private callbackManifestChecked;
  27180. private currentSceneUrl;
  27181. private db;
  27182. private _enableSceneOffline;
  27183. private _enableTexturesOffline;
  27184. private manifestVersionFound;
  27185. private mustUpdateRessources;
  27186. private hasReachedQuota;
  27187. private isSupported;
  27188. private idbFactory;
  27189. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  27190. static IsUASupportingBlobStorage: boolean;
  27191. /** Gets a boolean indicating if Database storate is enabled */
  27192. static IDBStorageEnabled: boolean;
  27193. /**
  27194. * Gets a boolean indicating if scene must be saved in the database
  27195. */
  27196. readonly enableSceneOffline: boolean;
  27197. /**
  27198. * Gets a boolean indicating if textures must be saved in the database
  27199. */
  27200. readonly enableTexturesOffline: boolean;
  27201. /**
  27202. * Creates a new Database
  27203. * @param urlToScene defines the url to load the scene
  27204. * @param callbackManifestChecked defines the callback to use when manifest is checked
  27205. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  27206. */
  27207. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  27208. private static _ParseURL;
  27209. private static _ReturnFullUrlLocation;
  27210. private _checkManifestFile();
  27211. /**
  27212. * Open the database and make it available
  27213. * @param successCallback defines the callback to call on success
  27214. * @param errorCallback defines the callback to call on error
  27215. */
  27216. openAsync(successCallback: () => void, errorCallback: () => void): void;
  27217. /**
  27218. * Loads an image from the database
  27219. * @param url defines the url to load from
  27220. * @param image defines the target DOM image
  27221. */
  27222. loadImageFromDB(url: string, image: HTMLImageElement): void;
  27223. private _loadImageFromDBAsync(url, image, notInDBCallback);
  27224. private _saveImageIntoDBAsync(url, image);
  27225. private _checkVersionFromDB(url, versionLoaded);
  27226. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  27227. private _saveVersionIntoDBAsync(url, callback);
  27228. /**
  27229. * Loads a file from database
  27230. * @param url defines the URL to load from
  27231. * @param sceneLoaded defines a callback to call on success
  27232. * @param progressCallBack defines a callback to call when progress changed
  27233. * @param errorCallback defines a callback to call on error
  27234. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  27235. */
  27236. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  27237. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  27238. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  27239. }
  27240. }
  27241. declare module BABYLON {
  27242. interface DDSInfo {
  27243. width: number;
  27244. height: number;
  27245. mipmapCount: number;
  27246. isFourCC: boolean;
  27247. isRGB: boolean;
  27248. isLuminance: boolean;
  27249. isCube: boolean;
  27250. isCompressed: boolean;
  27251. dxgiFormat: number;
  27252. textureType: number;
  27253. /** Sphericle polynomial created for the dds texture */
  27254. sphericalPolynomial?: SphericalPolynomial;
  27255. }
  27256. class DDSTools {
  27257. static StoreLODInAlphaChannel: boolean;
  27258. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  27259. private static _FloatView;
  27260. private static _Int32View;
  27261. private static _ToHalfFloat(value);
  27262. private static _FromHalfFloat(value);
  27263. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27264. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27265. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27266. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27267. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27268. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  27269. private static _ExtractLongWordOrder(value);
  27270. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  27271. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  27272. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  27273. }
  27274. }
  27275. declare module BABYLON {
  27276. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27277. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27278. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27279. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27280. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27281. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27282. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27283. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27284. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27285. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27286. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27287. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27288. /**
  27289. * Decorator used to define property that can be serialized as reference to a camera
  27290. * @param sourceName defines the name of the property to decorate
  27291. */
  27292. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27293. class SerializationHelper {
  27294. static Serialize<T>(entity: T, serializationObject?: any): any;
  27295. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27296. static Clone<T>(creationFunction: () => T, source: T): T;
  27297. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27298. }
  27299. }
  27300. declare module BABYLON {
  27301. /**
  27302. * Wrapper class for promise with external resolve and reject.
  27303. */
  27304. class Deferred<T> {
  27305. /**
  27306. * The promise associated with this deferred object.
  27307. */
  27308. readonly promise: Promise<T>;
  27309. private _resolve;
  27310. private _reject;
  27311. /**
  27312. * The resolve method of the promise associated with this deferred object.
  27313. */
  27314. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  27315. /**
  27316. * The reject method of the promise associated with this deferred object.
  27317. */
  27318. readonly reject: (reason?: any) => void;
  27319. /**
  27320. * Constructor for this deferred object.
  27321. */
  27322. constructor();
  27323. }
  27324. }
  27325. declare module BABYLON {
  27326. class FilesInput {
  27327. static FilesToLoad: {
  27328. [key: string]: File;
  27329. };
  27330. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  27331. private _engine;
  27332. private _currentScene;
  27333. private _sceneLoadedCallback;
  27334. private _progressCallback;
  27335. private _additionalRenderLoopLogicCallback;
  27336. private _textureLoadingCallback;
  27337. private _startingProcessingFilesCallback;
  27338. private _onReloadCallback;
  27339. private _errorCallback;
  27340. private _elementToMonitor;
  27341. private _sceneFileToLoad;
  27342. private _filesToLoad;
  27343. 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);
  27344. private _dragEnterHandler;
  27345. private _dragOverHandler;
  27346. private _dropHandler;
  27347. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  27348. dispose(): void;
  27349. private renderFunction();
  27350. private drag(e);
  27351. private drop(eventDrop);
  27352. private _traverseFolder(folder, files, remaining, callback);
  27353. private _processFiles(files);
  27354. loadFiles(event: any): void;
  27355. private _processReload();
  27356. reload(): void;
  27357. }
  27358. }
  27359. declare module BABYLON {
  27360. /**
  27361. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  27362. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  27363. */
  27364. class KhronosTextureContainer {
  27365. arrayBuffer: any;
  27366. static HEADER_LEN: number;
  27367. static COMPRESSED_2D: number;
  27368. static COMPRESSED_3D: number;
  27369. static TEX_2D: number;
  27370. static TEX_3D: number;
  27371. glType: number;
  27372. glTypeSize: number;
  27373. glFormat: number;
  27374. glInternalFormat: number;
  27375. glBaseInternalFormat: number;
  27376. pixelWidth: number;
  27377. pixelHeight: number;
  27378. pixelDepth: number;
  27379. numberOfArrayElements: number;
  27380. numberOfFaces: number;
  27381. numberOfMipmapLevels: number;
  27382. bytesOfKeyValueData: number;
  27383. loadType: number;
  27384. /**
  27385. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  27386. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  27387. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  27388. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  27389. */
  27390. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  27391. switchEndainness(val: number): number;
  27392. /**
  27393. * It is assumed that the texture has already been created & is currently bound
  27394. */
  27395. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  27396. private _upload2DCompressedLevels(gl, loadMipmaps);
  27397. }
  27398. }
  27399. declare module BABYLON {
  27400. /**
  27401. * A class serves as a medium between the observable and its observers
  27402. */
  27403. class EventState {
  27404. /**
  27405. * Create a new EventState
  27406. * @param mask defines the mask associated with this state
  27407. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  27408. * @param target defines the original target of the state
  27409. * @param currentTarget defines the current target of the state
  27410. */
  27411. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  27412. /**
  27413. * Initialize the current event state
  27414. * @param mask defines the mask associated with this state
  27415. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  27416. * @param target defines the original target of the state
  27417. * @param currentTarget defines the current target of the state
  27418. * @returns the current event state
  27419. */
  27420. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  27421. /**
  27422. * An Observer can set this property to true to prevent subsequent observers of being notified
  27423. */
  27424. skipNextObservers: boolean;
  27425. /**
  27426. * Get the mask value that were used to trigger the event corresponding to this EventState object
  27427. */
  27428. mask: number;
  27429. /**
  27430. * The object that originally notified the event
  27431. */
  27432. target?: any;
  27433. /**
  27434. * The current object in the bubbling phase
  27435. */
  27436. currentTarget?: any;
  27437. /**
  27438. * This will be populated with the return value of the last function that was executed.
  27439. * If it is the first function in the callback chain it will be the event data.
  27440. */
  27441. lastReturnValue?: any;
  27442. }
  27443. /**
  27444. * Represent an Observer registered to a given Observable object.
  27445. */
  27446. class Observer<T> {
  27447. /**
  27448. * Defines the callback to call when the observer is notified
  27449. */
  27450. callback: (eventData: T, eventState: EventState) => void;
  27451. /**
  27452. * Defines the mask of the observer (used to filter notifications)
  27453. */
  27454. mask: number;
  27455. /**
  27456. * Defines the current scope used to restore the JS context
  27457. */
  27458. scope: any;
  27459. /** @hidden */
  27460. _willBeUnregistered: boolean;
  27461. /**
  27462. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  27463. */
  27464. unregisterOnNextCall: boolean;
  27465. /**
  27466. * Creates a new observer
  27467. * @param callback defines the callback to call when the observer is notified
  27468. * @param mask defines the mask of the observer (used to filter notifications)
  27469. * @param scope defines the current scope used to restore the JS context
  27470. */
  27471. constructor(
  27472. /**
  27473. * Defines the callback to call when the observer is notified
  27474. */
  27475. callback: (eventData: T, eventState: EventState) => void,
  27476. /**
  27477. * Defines the mask of the observer (used to filter notifications)
  27478. */
  27479. mask: number,
  27480. /**
  27481. * Defines the current scope used to restore the JS context
  27482. */
  27483. scope?: any);
  27484. }
  27485. /**
  27486. * Represent a list of observers registered to multiple Observables object.
  27487. */
  27488. class MultiObserver<T> {
  27489. private _observers;
  27490. private _observables;
  27491. /**
  27492. * Release associated resources
  27493. */
  27494. dispose(): void;
  27495. /**
  27496. * Raise a callback when one of the observable will notify
  27497. * @param observables defines a list of observables to watch
  27498. * @param callback defines the callback to call on notification
  27499. * @param mask defines the mask used to filter notifications
  27500. * @param scope defines the current scope used to restore the JS context
  27501. * @returns the new MultiObserver
  27502. */
  27503. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  27504. }
  27505. /**
  27506. * The Observable class is a simple implementation of the Observable pattern.
  27507. *
  27508. * 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.
  27509. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  27510. * 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).
  27511. * 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.
  27512. */
  27513. class Observable<T> {
  27514. private _observers;
  27515. private _eventState;
  27516. private _onObserverAdded;
  27517. /**
  27518. * Creates a new observable
  27519. * @param onObserverAdded defines a callback to call when a new observer is added
  27520. */
  27521. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  27522. /**
  27523. * Create a new Observer with the specified callback
  27524. * @param callback the callback that will be executed for that Observer
  27525. * @param mask the mask used to filter observers
  27526. * @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.
  27527. * @param scope optional scope for the callback to be called from
  27528. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  27529. * @returns the new observer created for the callback
  27530. */
  27531. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  27532. /**
  27533. * Remove an Observer from the Observable object
  27534. * @param observer the instance of the Observer to remove
  27535. * @returns false if it doesn't belong to this Observable
  27536. */
  27537. remove(observer: Nullable<Observer<T>>): boolean;
  27538. /**
  27539. * Remove a callback from the Observable object
  27540. * @param callback the callback to remove
  27541. * @param scope optional scope. If used only the callbacks with this scope will be removed
  27542. * @returns false if it doesn't belong to this Observable
  27543. */
  27544. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  27545. private _deferUnregister(observer);
  27546. /**
  27547. * Notify all Observers by calling their respective callback with the given data
  27548. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  27549. * @param eventData defines the data to send to all observers
  27550. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  27551. * @param target defines the original target of the state
  27552. * @param currentTarget defines the current target of the state
  27553. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  27554. */
  27555. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  27556. /**
  27557. * Calling this will execute each callback, expecting it to be a promise or return a value.
  27558. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  27559. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  27560. * and it is crucial that all callbacks will be executed.
  27561. * The order of the callbacks is kept, callbacks are not executed parallel.
  27562. *
  27563. * @param eventData The data to be sent to each callback
  27564. * @param mask is used to filter observers defaults to -1
  27565. * @param target defines the callback target (see EventState)
  27566. * @param currentTarget defines he current object in the bubbling phase
  27567. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  27568. */
  27569. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  27570. /**
  27571. * Notify a specific observer
  27572. * @param observer defines the observer to notify
  27573. * @param eventData defines the data to be sent to each callback
  27574. * @param mask is used to filter observers defaults to -1
  27575. */
  27576. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  27577. /**
  27578. * Gets a boolean indicating if the observable has at least one observer
  27579. * @returns true is the Observable has at least one Observer registered
  27580. */
  27581. hasObservers(): boolean;
  27582. /**
  27583. * Clear the list of observers
  27584. */
  27585. clear(): void;
  27586. /**
  27587. * Clone the current observable
  27588. * @returns a new observable
  27589. */
  27590. clone(): Observable<T>;
  27591. /**
  27592. * Does this observable handles observer registered with a given mask
  27593. * @param mask defines the mask to be tested
  27594. * @return whether or not one observer registered with the given mask is handeled
  27595. **/
  27596. hasSpecificMask(mask?: number): boolean;
  27597. }
  27598. }
  27599. declare module BABYLON {
  27600. /**
  27601. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  27602. */
  27603. class PerformanceMonitor {
  27604. private _enabled;
  27605. private _rollingFrameTime;
  27606. private _lastFrameTimeMs;
  27607. /**
  27608. * constructor
  27609. * @param frameSampleSize The number of samples required to saturate the sliding window
  27610. */
  27611. constructor(frameSampleSize?: number);
  27612. /**
  27613. * Samples current frame
  27614. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  27615. */
  27616. sampleFrame(timeMs?: number): void;
  27617. /**
  27618. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  27619. * @return Average frame time in milliseconds
  27620. */
  27621. readonly averageFrameTime: number;
  27622. /**
  27623. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  27624. * @return Frame time variance in milliseconds squared
  27625. */
  27626. readonly averageFrameTimeVariance: number;
  27627. /**
  27628. * Returns the frame time of the most recent frame
  27629. * @return Frame time in milliseconds
  27630. */
  27631. readonly instantaneousFrameTime: number;
  27632. /**
  27633. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  27634. * @return Framerate in frames per second
  27635. */
  27636. readonly averageFPS: number;
  27637. /**
  27638. * Returns the average framerate in frames per second using the most recent frame time
  27639. * @return Framerate in frames per second
  27640. */
  27641. readonly instantaneousFPS: number;
  27642. /**
  27643. * Returns true if enough samples have been taken to completely fill the sliding window
  27644. * @return true if saturated
  27645. */
  27646. readonly isSaturated: boolean;
  27647. /**
  27648. * Enables contributions to the sliding window sample set
  27649. */
  27650. enable(): void;
  27651. /**
  27652. * Disables contributions to the sliding window sample set
  27653. * Samples will not be interpolated over the disabled period
  27654. */
  27655. disable(): void;
  27656. /**
  27657. * Returns true if sampling is enabled
  27658. * @return true if enabled
  27659. */
  27660. readonly isEnabled: boolean;
  27661. /**
  27662. * Resets performance monitor
  27663. */
  27664. reset(): void;
  27665. }
  27666. /**
  27667. * RollingAverage
  27668. *
  27669. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  27670. */
  27671. class RollingAverage {
  27672. /**
  27673. * Current average
  27674. */
  27675. average: number;
  27676. /**
  27677. * Current variance
  27678. */
  27679. variance: number;
  27680. protected _samples: Array<number>;
  27681. protected _sampleCount: number;
  27682. protected _pos: number;
  27683. protected _m2: number;
  27684. /**
  27685. * constructor
  27686. * @param length The number of samples required to saturate the sliding window
  27687. */
  27688. constructor(length: number);
  27689. /**
  27690. * Adds a sample to the sample set
  27691. * @param v The sample value
  27692. */
  27693. add(v: number): void;
  27694. /**
  27695. * Returns previously added values or null if outside of history or outside the sliding window domain
  27696. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  27697. * @return Value previously recorded with add() or null if outside of range
  27698. */
  27699. history(i: number): number;
  27700. /**
  27701. * Returns true if enough samples have been taken to completely fill the sliding window
  27702. * @return true if sample-set saturated
  27703. */
  27704. isSaturated(): boolean;
  27705. /**
  27706. * Resets the rolling average (equivalent to 0 samples taken so far)
  27707. */
  27708. reset(): void;
  27709. /**
  27710. * Wraps a value around the sample range boundaries
  27711. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  27712. * @return Wrapped position in sample range
  27713. */
  27714. protected _wrapPosition(i: number): number;
  27715. }
  27716. }
  27717. declare module BABYLON {
  27718. /**
  27719. * Helper class that provides a small promise polyfill
  27720. */
  27721. class PromisePolyfill {
  27722. /**
  27723. * Static function used to check if the polyfill is required
  27724. * If this is the case then the function will inject the polyfill to window.Promise
  27725. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  27726. */
  27727. static Apply(force?: boolean): void;
  27728. }
  27729. }
  27730. declare module BABYLON {
  27731. /**
  27732. * Defines the root class used to create scene optimization to use with SceneOptimizer
  27733. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27734. */
  27735. class SceneOptimization {
  27736. /**
  27737. * Defines the priority of this optimization (0 by default which means first in the list)
  27738. */
  27739. priority: number;
  27740. /**
  27741. * Gets a string describing the action executed by the current optimization
  27742. * @returns description string
  27743. */
  27744. getDescription(): string;
  27745. /**
  27746. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27747. * @param scene defines the current scene where to apply this optimization
  27748. * @param optimizer defines the current optimizer
  27749. * @returns true if everything that can be done was applied
  27750. */
  27751. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27752. /**
  27753. * Creates the SceneOptimization object
  27754. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  27755. * @param desc defines the description associated with the optimization
  27756. */
  27757. constructor(
  27758. /**
  27759. * Defines the priority of this optimization (0 by default which means first in the list)
  27760. */
  27761. priority?: number);
  27762. }
  27763. /**
  27764. * Defines an optimization used to reduce the size of render target textures
  27765. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27766. */
  27767. class TextureOptimization extends SceneOptimization {
  27768. /**
  27769. * Defines the priority of this optimization (0 by default which means first in the list)
  27770. */
  27771. priority: number;
  27772. /**
  27773. * 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
  27774. */
  27775. maximumSize: number;
  27776. /**
  27777. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  27778. */
  27779. step: number;
  27780. /**
  27781. * Gets a string describing the action executed by the current optimization
  27782. * @returns description string
  27783. */
  27784. getDescription(): string;
  27785. /**
  27786. * Creates the TextureOptimization object
  27787. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  27788. * @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
  27789. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  27790. */
  27791. constructor(
  27792. /**
  27793. * Defines the priority of this optimization (0 by default which means first in the list)
  27794. */
  27795. priority?: number,
  27796. /**
  27797. * 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
  27798. */
  27799. maximumSize?: number,
  27800. /**
  27801. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  27802. */
  27803. step?: number);
  27804. /**
  27805. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27806. * @param scene defines the current scene where to apply this optimization
  27807. * @param optimizer defines the current optimizer
  27808. * @returns true if everything that can be done was applied
  27809. */
  27810. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27811. }
  27812. /**
  27813. * Defines an optimization used to increase or decrease the rendering resolution
  27814. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27815. */
  27816. class HardwareScalingOptimization extends SceneOptimization {
  27817. /**
  27818. * Defines the priority of this optimization (0 by default which means first in the list)
  27819. */
  27820. priority: number;
  27821. /**
  27822. * Defines the maximum scale to use (2 by default)
  27823. */
  27824. maximumScale: number;
  27825. /**
  27826. * Defines the step to use between two passes (0.5 by default)
  27827. */
  27828. step: number;
  27829. private _currentScale;
  27830. private _directionOffset;
  27831. /**
  27832. * Gets a string describing the action executed by the current optimization
  27833. * @return description string
  27834. */
  27835. getDescription(): string;
  27836. /**
  27837. * Creates the HardwareScalingOptimization object
  27838. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  27839. * @param maximumScale defines the maximum scale to use (2 by default)
  27840. * @param step defines the step to use between two passes (0.5 by default)
  27841. */
  27842. constructor(
  27843. /**
  27844. * Defines the priority of this optimization (0 by default which means first in the list)
  27845. */
  27846. priority?: number,
  27847. /**
  27848. * Defines the maximum scale to use (2 by default)
  27849. */
  27850. maximumScale?: number,
  27851. /**
  27852. * Defines the step to use between two passes (0.5 by default)
  27853. */
  27854. step?: number);
  27855. /**
  27856. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27857. * @param scene defines the current scene where to apply this optimization
  27858. * @param optimizer defines the current optimizer
  27859. * @returns true if everything that can be done was applied
  27860. */
  27861. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27862. }
  27863. /**
  27864. * Defines an optimization used to remove shadows
  27865. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27866. */
  27867. class ShadowsOptimization extends SceneOptimization {
  27868. /**
  27869. * Gets a string describing the action executed by the current optimization
  27870. * @return description string
  27871. */
  27872. getDescription(): string;
  27873. /**
  27874. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27875. * @param scene defines the current scene where to apply this optimization
  27876. * @param optimizer defines the current optimizer
  27877. * @returns true if everything that can be done was applied
  27878. */
  27879. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27880. }
  27881. /**
  27882. * Defines an optimization used to turn post-processes off
  27883. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27884. */
  27885. class PostProcessesOptimization extends SceneOptimization {
  27886. /**
  27887. * Gets a string describing the action executed by the current optimization
  27888. * @return description string
  27889. */
  27890. getDescription(): string;
  27891. /**
  27892. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27893. * @param scene defines the current scene where to apply this optimization
  27894. * @param optimizer defines the current optimizer
  27895. * @returns true if everything that can be done was applied
  27896. */
  27897. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27898. }
  27899. /**
  27900. * Defines an optimization used to turn lens flares off
  27901. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27902. */
  27903. class LensFlaresOptimization extends SceneOptimization {
  27904. /**
  27905. * Gets a string describing the action executed by the current optimization
  27906. * @return description string
  27907. */
  27908. getDescription(): string;
  27909. /**
  27910. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27911. * @param scene defines the current scene where to apply this optimization
  27912. * @param optimizer defines the current optimizer
  27913. * @returns true if everything that can be done was applied
  27914. */
  27915. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27916. }
  27917. /**
  27918. * Defines an optimization based on user defined callback.
  27919. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27920. */
  27921. class CustomOptimization extends SceneOptimization {
  27922. /**
  27923. * Callback called to apply the custom optimization.
  27924. */
  27925. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  27926. /**
  27927. * Callback called to get custom description
  27928. */
  27929. onGetDescription: () => string;
  27930. /**
  27931. * Gets a string describing the action executed by the current optimization
  27932. * @returns description string
  27933. */
  27934. getDescription(): string;
  27935. /**
  27936. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27937. * @param scene defines the current scene where to apply this optimization
  27938. * @param optimizer defines the current optimizer
  27939. * @returns true if everything that can be done was applied
  27940. */
  27941. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27942. }
  27943. /**
  27944. * Defines an optimization used to turn particles off
  27945. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27946. */
  27947. class ParticlesOptimization extends SceneOptimization {
  27948. /**
  27949. * Gets a string describing the action executed by the current optimization
  27950. * @return description string
  27951. */
  27952. getDescription(): string;
  27953. /**
  27954. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27955. * @param scene defines the current scene where to apply this optimization
  27956. * @param optimizer defines the current optimizer
  27957. * @returns true if everything that can be done was applied
  27958. */
  27959. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27960. }
  27961. /**
  27962. * Defines an optimization used to turn render targets off
  27963. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27964. */
  27965. class RenderTargetsOptimization extends SceneOptimization {
  27966. /**
  27967. * Gets a string describing the action executed by the current optimization
  27968. * @return description string
  27969. */
  27970. getDescription(): string;
  27971. /**
  27972. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  27973. * @param scene defines the current scene where to apply this optimization
  27974. * @param optimizer defines the current optimizer
  27975. * @returns true if everything that can be done was applied
  27976. */
  27977. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  27978. }
  27979. /**
  27980. * Defines an optimization used to merge meshes with compatible materials
  27981. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  27982. */
  27983. class MergeMeshesOptimization extends SceneOptimization {
  27984. private static _UpdateSelectionTree;
  27985. /**
  27986. * Gets or sets a boolean which defines if optimization octree has to be updated
  27987. */
  27988. /**
  27989. * Gets or sets a boolean which defines if optimization octree has to be updated
  27990. */
  27991. static UpdateSelectionTree: boolean;
  27992. /**
  27993. * Gets a string describing the action executed by the current optimization
  27994. * @return description string
  27995. */
  27996. getDescription(): string;
  27997. private _canBeMerged;
  27998. /**
  27999. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28000. * @param scene defines the current scene where to apply this optimization
  28001. * @param optimizer defines the current optimizer
  28002. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  28003. * @returns true if everything that can be done was applied
  28004. */
  28005. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  28006. }
  28007. /**
  28008. * Defines a list of options used by SceneOptimizer
  28009. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28010. */
  28011. class SceneOptimizerOptions {
  28012. /**
  28013. * Defines the target frame rate to reach (60 by default)
  28014. */
  28015. targetFrameRate: number;
  28016. /**
  28017. * Defines the interval between two checkes (2000ms by default)
  28018. */
  28019. trackerDuration: number;
  28020. /**
  28021. * Gets the list of optimizations to apply
  28022. */
  28023. optimizations: SceneOptimization[];
  28024. /**
  28025. * Creates a new list of options used by SceneOptimizer
  28026. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  28027. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  28028. */
  28029. constructor(
  28030. /**
  28031. * Defines the target frame rate to reach (60 by default)
  28032. */
  28033. targetFrameRate?: number,
  28034. /**
  28035. * Defines the interval between two checkes (2000ms by default)
  28036. */
  28037. trackerDuration?: number);
  28038. /**
  28039. * Add a new optimization
  28040. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  28041. * @returns the current SceneOptimizerOptions
  28042. */
  28043. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  28044. /**
  28045. * Add a new custom optimization
  28046. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  28047. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  28048. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28049. * @returns the current SceneOptimizerOptions
  28050. */
  28051. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  28052. /**
  28053. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  28054. * @param targetFrameRate defines the target frame rate (60 by default)
  28055. * @returns a SceneOptimizerOptions object
  28056. */
  28057. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28058. /**
  28059. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  28060. * @param targetFrameRate defines the target frame rate (60 by default)
  28061. * @returns a SceneOptimizerOptions object
  28062. */
  28063. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28064. /**
  28065. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  28066. * @param targetFrameRate defines the target frame rate (60 by default)
  28067. * @returns a SceneOptimizerOptions object
  28068. */
  28069. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28070. }
  28071. /**
  28072. * Class used to run optimizations in order to reach a target frame rate
  28073. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28074. */
  28075. class SceneOptimizer implements IDisposable {
  28076. private _isRunning;
  28077. private _options;
  28078. private _scene;
  28079. private _currentPriorityLevel;
  28080. private _targetFrameRate;
  28081. private _trackerDuration;
  28082. private _currentFrameRate;
  28083. private _sceneDisposeObserver;
  28084. private _improvementMode;
  28085. /**
  28086. * Defines an observable called when the optimizer reaches the target frame rate
  28087. */
  28088. onSuccessObservable: Observable<SceneOptimizer>;
  28089. /**
  28090. * Defines an observable called when the optimizer enables an optimization
  28091. */
  28092. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  28093. /**
  28094. * Defines an observable called when the optimizer is not able to reach the target frame rate
  28095. */
  28096. onFailureObservable: Observable<SceneOptimizer>;
  28097. /**
  28098. * Gets a boolean indicating if the optimizer is in improvement mode
  28099. */
  28100. readonly isInImprovementMode: boolean;
  28101. /**
  28102. * Gets the current priority level (0 at start)
  28103. */
  28104. readonly currentPriorityLevel: number;
  28105. /**
  28106. * Gets the current frame rate checked by the SceneOptimizer
  28107. */
  28108. readonly currentFrameRate: number;
  28109. /**
  28110. * Gets or sets the current target frame rate (60 by default)
  28111. */
  28112. /**
  28113. * Gets or sets the current target frame rate (60 by default)
  28114. */
  28115. targetFrameRate: number;
  28116. /**
  28117. * Gets or sets the current interval between two checks (every 2000ms by default)
  28118. */
  28119. /**
  28120. * Gets or sets the current interval between two checks (every 2000ms by default)
  28121. */
  28122. trackerDuration: number;
  28123. /**
  28124. * Gets the list of active optimizations
  28125. */
  28126. readonly optimizations: SceneOptimization[];
  28127. /**
  28128. * Creates a new SceneOptimizer
  28129. * @param scene defines the scene to work on
  28130. * @param options defines the options to use with the SceneOptimizer
  28131. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  28132. * @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)
  28133. */
  28134. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  28135. /**
  28136. * Stops the current optimizer
  28137. */
  28138. stop(): void;
  28139. /**
  28140. * Reset the optimizer to initial step (current priority level = 0)
  28141. */
  28142. reset(): void;
  28143. /**
  28144. * Start the optimizer. By default it will try to reach a specific framerate
  28145. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  28146. */
  28147. start(): void;
  28148. private _checkCurrentState();
  28149. /**
  28150. * Release all resources
  28151. */
  28152. dispose(): void;
  28153. /**
  28154. * Helper function to create a SceneOptimizer with one single line of code
  28155. * @param scene defines the scene to work on
  28156. * @param options defines the options to use with the SceneOptimizer
  28157. * @param onSuccess defines a callback to call on success
  28158. * @param onFailure defines a callback to call on failure
  28159. * @returns the new SceneOptimizer object
  28160. */
  28161. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  28162. }
  28163. }
  28164. declare module BABYLON {
  28165. class SceneSerializer {
  28166. static ClearCache(): void;
  28167. static Serialize(scene: Scene): any;
  28168. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  28169. }
  28170. }
  28171. declare module BABYLON {
  28172. class SmartArray<T> {
  28173. data: Array<T>;
  28174. length: number;
  28175. protected _id: number;
  28176. [index: number]: T;
  28177. constructor(capacity: number);
  28178. push(value: T): void;
  28179. forEach(func: (content: T) => void): void;
  28180. sort(compareFn: (a: T, b: T) => number): void;
  28181. reset(): void;
  28182. dispose(): void;
  28183. concat(array: any): void;
  28184. indexOf(value: T): number;
  28185. contains(value: T): boolean;
  28186. private static _GlobalId;
  28187. }
  28188. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  28189. private _duplicateId;
  28190. [index: number]: T;
  28191. push(value: T): void;
  28192. pushNoDuplicate(value: T): boolean;
  28193. reset(): void;
  28194. concatWithNoDuplicate(array: any): void;
  28195. }
  28196. }
  28197. declare module BABYLON {
  28198. /**
  28199. * This class implement a typical dictionary using a string as key and the generic type T as value.
  28200. * The underlying implementation relies on an associative array to ensure the best performances.
  28201. * The value can be anything including 'null' but except 'undefined'
  28202. */
  28203. class StringDictionary<T> {
  28204. /**
  28205. * This will clear this dictionary and copy the content from the 'source' one.
  28206. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  28207. * @param source the dictionary to take the content from and copy to this dictionary
  28208. */
  28209. copyFrom(source: StringDictionary<T>): void;
  28210. /**
  28211. * Get a value based from its key
  28212. * @param key the given key to get the matching value from
  28213. * @return the value if found, otherwise undefined is returned
  28214. */
  28215. get(key: string): T | undefined;
  28216. /**
  28217. * Get a value from its key or add it if it doesn't exist.
  28218. * This method will ensure you that a given key/data will be present in the dictionary.
  28219. * @param key the given key to get the matching value from
  28220. * @param factory the factory that will create the value if the key is not present in the dictionary.
  28221. * The factory will only be invoked if there's no data for the given key.
  28222. * @return the value corresponding to the key.
  28223. */
  28224. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  28225. /**
  28226. * Get a value from its key if present in the dictionary otherwise add it
  28227. * @param key the key to get the value from
  28228. * @param val if there's no such key/value pair in the dictionary add it with this value
  28229. * @return the value corresponding to the key
  28230. */
  28231. getOrAdd(key: string, val: T): T;
  28232. /**
  28233. * Check if there's a given key in the dictionary
  28234. * @param key the key to check for
  28235. * @return true if the key is present, false otherwise
  28236. */
  28237. contains(key: string): boolean;
  28238. /**
  28239. * Add a new key and its corresponding value
  28240. * @param key the key to add
  28241. * @param value the value corresponding to the key
  28242. * @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
  28243. */
  28244. add(key: string, value: T): boolean;
  28245. set(key: string, value: T): boolean;
  28246. /**
  28247. * Get the element of the given key and remove it from the dictionary
  28248. * @param key
  28249. */
  28250. getAndRemove(key: string): Nullable<T>;
  28251. /**
  28252. * Remove a key/value from the dictionary.
  28253. * @param key the key to remove
  28254. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  28255. */
  28256. remove(key: string): boolean;
  28257. /**
  28258. * Clear the whole content of the dictionary
  28259. */
  28260. clear(): void;
  28261. readonly count: number;
  28262. /**
  28263. * Execute a callback on each key/val of the dictionary.
  28264. * Note that you can remove any element in this dictionary in the callback implementation
  28265. * @param callback the callback to execute on a given key/value pair
  28266. */
  28267. forEach(callback: (key: string, val: T) => void): void;
  28268. /**
  28269. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  28270. * If the callback returns null or undefined the method will iterate to the next key/value pair
  28271. * Note that you can remove any element in this dictionary in the callback implementation
  28272. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  28273. */
  28274. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  28275. private _count;
  28276. private _data;
  28277. }
  28278. }
  28279. declare module BABYLON {
  28280. class Tags {
  28281. static EnableFor(obj: any): void;
  28282. static DisableFor(obj: any): void;
  28283. static HasTags(obj: any): boolean;
  28284. static GetTags(obj: any, asString?: boolean): any;
  28285. static AddTagsTo(obj: any, tagsString: string): void;
  28286. static _AddTagTo(obj: any, tag: string): void;
  28287. static RemoveTagsFrom(obj: any, tagsString: string): void;
  28288. static _RemoveTagFrom(obj: any, tag: string): void;
  28289. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  28290. }
  28291. }
  28292. declare module BABYLON {
  28293. class TextureTools {
  28294. /**
  28295. * Uses the GPU to create a copy texture rescaled at a given size
  28296. * @param texture Texture to copy from
  28297. * @param width Desired width
  28298. * @param height Desired height
  28299. * @return Generated texture
  28300. */
  28301. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  28302. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  28303. private static _environmentBRDFBase64Texture;
  28304. }
  28305. }
  28306. declare module BABYLON {
  28307. class TGATools {
  28308. private static _TYPE_INDEXED;
  28309. private static _TYPE_RGB;
  28310. private static _TYPE_GREY;
  28311. private static _TYPE_RLE_INDEXED;
  28312. private static _TYPE_RLE_RGB;
  28313. private static _TYPE_RLE_GREY;
  28314. private static _ORIGIN_MASK;
  28315. private static _ORIGIN_SHIFT;
  28316. private static _ORIGIN_BL;
  28317. private static _ORIGIN_BR;
  28318. private static _ORIGIN_UL;
  28319. private static _ORIGIN_UR;
  28320. static GetTGAHeader(data: Uint8Array): any;
  28321. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  28322. 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;
  28323. 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;
  28324. 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;
  28325. 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;
  28326. 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;
  28327. 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;
  28328. }
  28329. }
  28330. declare module BABYLON {
  28331. interface IAnimatable {
  28332. animations: Array<Animation>;
  28333. }
  28334. class LoadFileError extends Error {
  28335. request: XMLHttpRequest | undefined;
  28336. private static _setPrototypeOf;
  28337. constructor(message: string, request?: XMLHttpRequest | undefined);
  28338. }
  28339. class RetryStrategy {
  28340. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  28341. }
  28342. interface IFileRequest {
  28343. /**
  28344. * Raised when the request is complete (success or error).
  28345. */
  28346. onCompleteObservable: Observable<IFileRequest>;
  28347. /**
  28348. * Aborts the request for a file.
  28349. */
  28350. abort: () => void;
  28351. }
  28352. class Tools {
  28353. static BaseUrl: string;
  28354. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  28355. /**
  28356. * Default behaviour for cors in the application.
  28357. * It can be a string if the expected behavior is identical in the entire app.
  28358. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  28359. */
  28360. static CorsBehavior: string | ((url: string | string[]) => string);
  28361. static UseFallbackTexture: boolean;
  28362. /**
  28363. * Use this object to register external classes like custom textures or material
  28364. * to allow the laoders to instantiate them
  28365. */
  28366. static RegisteredExternalClasses: {
  28367. [key: string]: Object;
  28368. };
  28369. static fallbackTexture: string;
  28370. /**
  28371. * Interpolates between a and b via alpha
  28372. * @param a The lower value (returned when alpha = 0)
  28373. * @param b The upper value (returned when alpha = 1)
  28374. * @param alpha The interpolation-factor
  28375. * @return The mixed value
  28376. */
  28377. static Mix(a: number, b: number, alpha: number): number;
  28378. static Instantiate(className: string): any;
  28379. /**
  28380. * Provides a slice function that will work even on IE
  28381. * @param data defines the array to slice
  28382. * @param start defines the start of the data (optional)
  28383. * @param end defines the end of the data (optional)
  28384. * @returns the new sliced array
  28385. */
  28386. static Slice<T>(data: T, start?: number, end?: number): T;
  28387. static SetImmediate(action: () => void): void;
  28388. static IsExponentOfTwo(value: number): boolean;
  28389. private static _tmpFloatArray;
  28390. /**
  28391. * Returns the nearest 32-bit single precision float representation of a Number
  28392. * @param value A Number. If the parameter is of a different type, it will get converted
  28393. * to a number or to NaN if it cannot be converted
  28394. * @returns number
  28395. */
  28396. static FloatRound(value: number): number;
  28397. /**
  28398. * Find the next highest power of two.
  28399. * @param x Number to start search from.
  28400. * @return Next highest power of two.
  28401. */
  28402. static CeilingPOT(x: number): number;
  28403. /**
  28404. * Find the next lowest power of two.
  28405. * @param x Number to start search from.
  28406. * @return Next lowest power of two.
  28407. */
  28408. static FloorPOT(x: number): number;
  28409. /**
  28410. * Find the nearest power of two.
  28411. * @param x Number to start search from.
  28412. * @return Next nearest power of two.
  28413. */
  28414. static NearestPOT(x: number): number;
  28415. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  28416. static GetFilename(path: string): string;
  28417. /**
  28418. * Extracts the "folder" part of a path (everything before the filename).
  28419. * @param uri The URI to extract the info from
  28420. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  28421. * @returns The "folder" part of the path
  28422. */
  28423. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  28424. static GetDOMTextContent(element: HTMLElement): string;
  28425. static ToDegrees(angle: number): number;
  28426. static ToRadians(angle: number): number;
  28427. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  28428. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  28429. minimum: Vector3;
  28430. maximum: Vector3;
  28431. };
  28432. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  28433. minimum: Vector3;
  28434. maximum: Vector3;
  28435. };
  28436. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  28437. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  28438. minimum: Vector2;
  28439. maximum: Vector2;
  28440. };
  28441. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  28442. static GetPointerPrefix(): string;
  28443. /**
  28444. * @param func - the function to be called
  28445. * @param requester - the object that will request the next frame. Falls back to window.
  28446. */
  28447. static QueueNewFrame(func: () => void, requester?: any): number;
  28448. static RequestFullscreen(element: HTMLElement): void;
  28449. static ExitFullscreen(): void;
  28450. static SetCorsBehavior(url: string | string[], element: {
  28451. crossOrigin: string | null;
  28452. }): void;
  28453. static CleanUrl(url: string): string;
  28454. static PreprocessUrl: (url: string) => string;
  28455. static LoadImage(url: any, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  28456. 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;
  28457. /**
  28458. * Load a script (identified by an url). When the url returns, the
  28459. * content of this file is added into a new script element, attached to the DOM (body element)
  28460. */
  28461. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  28462. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  28463. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  28464. static FileAsURL(content: string): string;
  28465. static Format(value: number, decimals?: number): string;
  28466. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  28467. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  28468. static IsEmpty(obj: any): boolean;
  28469. static RegisterTopRootEvents(events: {
  28470. name: string;
  28471. handler: Nullable<(e: FocusEvent) => any>;
  28472. }[]): void;
  28473. static UnregisterTopRootEvents(events: {
  28474. name: string;
  28475. handler: Nullable<(e: FocusEvent) => any>;
  28476. }[]): void;
  28477. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  28478. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  28479. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  28480. /**
  28481. * Generates an image screenshot from the specified camera.
  28482. *
  28483. * @param engine The engine to use for rendering
  28484. * @param camera The camera to use for rendering
  28485. * @param size This parameter can be set to a single number or to an object with the
  28486. * following (optional) properties: precision, width, height. If a single number is passed,
  28487. * it will be used for both width and height. If an object is passed, the screenshot size
  28488. * will be derived from the parameters. The precision property is a multiplier allowing
  28489. * rendering at a higher or lower resolution.
  28490. * @param successCallback The callback receives a single parameter which contains the
  28491. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  28492. * src parameter of an <img> to display it.
  28493. * @param mimeType The MIME type of the screenshot image (default: image/png).
  28494. * Check your browser for supported MIME types.
  28495. * @param samples Texture samples (default: 1)
  28496. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  28497. * @param fileName A name for for the downloaded file.
  28498. * @constructor
  28499. */
  28500. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  28501. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  28502. /**
  28503. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28504. * Be aware Math.random() could cause collisions, but:
  28505. * "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"
  28506. */
  28507. static RandomId(): string;
  28508. /**
  28509. * Test if the given uri is a base64 string.
  28510. * @param uri The uri to test
  28511. * @return True if the uri is a base64 string or false otherwise.
  28512. */
  28513. static IsBase64(uri: string): boolean;
  28514. /**
  28515. * Decode the given base64 uri.
  28516. * @param uri The uri to decode
  28517. * @return The decoded base64 data.
  28518. */
  28519. static DecodeBase64(uri: string): ArrayBuffer;
  28520. private static _NoneLogLevel;
  28521. private static _MessageLogLevel;
  28522. private static _WarningLogLevel;
  28523. private static _ErrorLogLevel;
  28524. private static _LogCache;
  28525. static errorsCount: number;
  28526. static OnNewCacheEntry: (entry: string) => void;
  28527. static readonly NoneLogLevel: number;
  28528. static readonly MessageLogLevel: number;
  28529. static readonly WarningLogLevel: number;
  28530. static readonly ErrorLogLevel: number;
  28531. static readonly AllLogLevel: number;
  28532. private static _AddLogEntry(entry);
  28533. private static _FormatMessage(message);
  28534. private static _LogDisabled(message);
  28535. private static _LogEnabled(message);
  28536. private static _WarnDisabled(message);
  28537. private static _WarnEnabled(message);
  28538. private static _ErrorDisabled(message);
  28539. private static _ErrorEnabled(message);
  28540. static Log: (message: string) => void;
  28541. static Warn: (message: string) => void;
  28542. static Error: (message: string) => void;
  28543. static readonly LogCache: string;
  28544. static ClearLogCache(): void;
  28545. static LogLevels: number;
  28546. static IsWindowObjectExist(): boolean;
  28547. private static _PerformanceNoneLogLevel;
  28548. private static _PerformanceUserMarkLogLevel;
  28549. private static _PerformanceConsoleLogLevel;
  28550. private static _performance;
  28551. static readonly PerformanceNoneLogLevel: number;
  28552. static readonly PerformanceUserMarkLogLevel: number;
  28553. static readonly PerformanceConsoleLogLevel: number;
  28554. static PerformanceLogLevel: number;
  28555. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  28556. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  28557. static _StartUserMark(counterName: string, condition?: boolean): void;
  28558. static _EndUserMark(counterName: string, condition?: boolean): void;
  28559. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  28560. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  28561. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  28562. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  28563. static readonly Now: number;
  28564. /**
  28565. * This method will return the name of the class used to create the instance of the given object.
  28566. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  28567. * @param object the object to get the class name from
  28568. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  28569. */
  28570. static GetClassName(object: any, isType?: boolean): string;
  28571. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  28572. /**
  28573. * This method will return the name of the full name of the class, including its owning module (if any).
  28574. * 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).
  28575. * @param object the object to get the class name from
  28576. * @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.
  28577. */
  28578. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  28579. /**
  28580. * 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.
  28581. * @param array
  28582. */
  28583. static arrayOrStringFeeder(array: any): (i: number) => number;
  28584. /**
  28585. * Compute the hashCode of a stream of number
  28586. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  28587. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  28588. * @return the hash code computed
  28589. */
  28590. static hashCodeFromStream(feeder: (index: number) => number): number;
  28591. /**
  28592. * Returns a promise that resolves after the given amount of time.
  28593. * @param delay Number of milliseconds to delay
  28594. * @returns Promise that resolves after the given amount of time
  28595. */
  28596. static DelayAsync(delay: number): Promise<void>;
  28597. }
  28598. /**
  28599. * This class is used to track a performance counter which is number based.
  28600. * The user has access to many properties which give statistics of different nature
  28601. *
  28602. * The implementer can track two kinds of Performance Counter: time and count
  28603. * 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.
  28604. * 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.
  28605. */
  28606. class PerfCounter {
  28607. static Enabled: boolean;
  28608. /**
  28609. * Returns the smallest value ever
  28610. */
  28611. readonly min: number;
  28612. /**
  28613. * Returns the biggest value ever
  28614. */
  28615. readonly max: number;
  28616. /**
  28617. * Returns the average value since the performance counter is running
  28618. */
  28619. readonly average: number;
  28620. /**
  28621. * Returns the average value of the last second the counter was monitored
  28622. */
  28623. readonly lastSecAverage: number;
  28624. /**
  28625. * Returns the current value
  28626. */
  28627. readonly current: number;
  28628. readonly total: number;
  28629. readonly count: number;
  28630. constructor();
  28631. /**
  28632. * Call this method to start monitoring a new frame.
  28633. * 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.
  28634. */
  28635. fetchNewFrame(): void;
  28636. /**
  28637. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28638. * @param newCount the count value to add to the monitored count
  28639. * @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.
  28640. */
  28641. addCount(newCount: number, fetchResult: boolean): void;
  28642. /**
  28643. * Start monitoring this performance counter
  28644. */
  28645. beginMonitoring(): void;
  28646. /**
  28647. * Compute the time lapsed since the previous beginMonitoring() call.
  28648. * @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
  28649. */
  28650. endMonitoring(newFrame?: boolean): void;
  28651. private _fetchResult();
  28652. private _startMonitoringTime;
  28653. private _min;
  28654. private _max;
  28655. private _average;
  28656. private _current;
  28657. private _totalValueCount;
  28658. private _totalAccumulated;
  28659. private _lastSecAverage;
  28660. private _lastSecAccumulated;
  28661. private _lastSecTime;
  28662. private _lastSecValueCount;
  28663. }
  28664. /**
  28665. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  28666. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  28667. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  28668. * @param name The name of the class, case should be preserved
  28669. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  28670. */
  28671. function className(name: string, module?: string): (target: Object) => void;
  28672. /**
  28673. * An implementation of a loop for asynchronous functions.
  28674. */
  28675. class AsyncLoop {
  28676. iterations: number;
  28677. private _fn;
  28678. private _successCallback;
  28679. index: number;
  28680. private _done;
  28681. /**
  28682. * Constroctor.
  28683. * @param iterations the number of iterations.
  28684. * @param _fn the function to run each iteration
  28685. * @param _successCallback the callback that will be called upon succesful execution
  28686. * @param offset starting offset.
  28687. */
  28688. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  28689. /**
  28690. * Execute the next iteration. Must be called after the last iteration was finished.
  28691. */
  28692. executeNext(): void;
  28693. /**
  28694. * Break the loop and run the success callback.
  28695. */
  28696. breakLoop(): void;
  28697. /**
  28698. * Helper function
  28699. */
  28700. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  28701. /**
  28702. * A for-loop that will run a given number of iterations synchronous and the rest async.
  28703. * @param iterations total number of iterations
  28704. * @param syncedIterations number of synchronous iterations in each async iteration.
  28705. * @param fn the function to call each iteration.
  28706. * @param callback a success call back that will be called when iterating stops.
  28707. * @param breakFunction a break condition (optional)
  28708. * @param timeout timeout settings for the setTimeout function. default - 0.
  28709. * @constructor
  28710. */
  28711. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  28712. }
  28713. }
  28714. declare module BABYLON {
  28715. /**
  28716. * Defines the potential axis of a Joystick
  28717. */
  28718. enum JoystickAxis {
  28719. /** X axis */
  28720. X = 0,
  28721. /** Y axis */
  28722. Y = 1,
  28723. /** Z axis */
  28724. Z = 2,
  28725. }
  28726. /**
  28727. * Class used to define virtual joystick (used in touch mode)
  28728. */
  28729. class VirtualJoystick {
  28730. /**
  28731. * Gets or sets a boolean indicating that left and right values must be inverted
  28732. */
  28733. reverseLeftRight: boolean;
  28734. /**
  28735. * Gets or sets a boolean indicating that up and down values must be inverted
  28736. */
  28737. reverseUpDown: boolean;
  28738. /**
  28739. * Gets the offset value for the position (ie. the change of the position value)
  28740. */
  28741. deltaPosition: Vector3;
  28742. /**
  28743. * Gets a boolean indicating if the virtual joystick was pressed
  28744. */
  28745. pressed: boolean;
  28746. private static _globalJoystickIndex;
  28747. private static vjCanvas;
  28748. private static vjCanvasContext;
  28749. private static vjCanvasWidth;
  28750. private static vjCanvasHeight;
  28751. private static halfWidth;
  28752. private _action;
  28753. private _axisTargetedByLeftAndRight;
  28754. private _axisTargetedByUpAndDown;
  28755. private _joystickSensibility;
  28756. private _inversedSensibility;
  28757. private _joystickPointerID;
  28758. private _joystickColor;
  28759. private _joystickPointerPos;
  28760. private _joystickPreviousPointerPos;
  28761. private _joystickPointerStartPos;
  28762. private _deltaJoystickVector;
  28763. private _leftJoystick;
  28764. private _touches;
  28765. private _onPointerDownHandlerRef;
  28766. private _onPointerMoveHandlerRef;
  28767. private _onPointerUpHandlerRef;
  28768. private _onResize;
  28769. /**
  28770. * Creates a new virtual joystick
  28771. * @param leftJoystick defines that the joystick is for left hand (false by default)
  28772. */
  28773. constructor(leftJoystick?: boolean);
  28774. /**
  28775. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  28776. * @param newJoystickSensibility defines the new sensibility
  28777. */
  28778. setJoystickSensibility(newJoystickSensibility: number): void;
  28779. private _onPointerDown(e);
  28780. private _onPointerMove(e);
  28781. private _onPointerUp(e);
  28782. /**
  28783. * Change the color of the virtual joystick
  28784. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  28785. */
  28786. setJoystickColor(newColor: string): void;
  28787. /**
  28788. * Defines a callback to call when the joystick is touched
  28789. * @param action defines the callback
  28790. */
  28791. setActionOnTouch(action: () => any): void;
  28792. /**
  28793. * Defines which axis you'd like to control for left & right
  28794. * @param axis defines the axis to use
  28795. */
  28796. setAxisForLeftRight(axis: JoystickAxis): void;
  28797. /**
  28798. * Defines which axis you'd like to control for up & down
  28799. * @param axis defines the axis to use
  28800. */
  28801. setAxisForUpDown(axis: JoystickAxis): void;
  28802. private _drawVirtualJoystick();
  28803. /**
  28804. * Release internal HTML canvas
  28805. */
  28806. releaseCanvas(): void;
  28807. }
  28808. }
  28809. declare module BABYLON {
  28810. /**
  28811. * Helper class to push actions to a pool of workers.
  28812. */
  28813. class WorkerPool implements IDisposable {
  28814. private _workerInfos;
  28815. private _pendingActions;
  28816. /**
  28817. * Constructor
  28818. * @param workers Array of workers to use for actions
  28819. */
  28820. constructor(workers: Array<Worker>);
  28821. /**
  28822. * Terminates all workers and clears any pending actions.
  28823. */
  28824. dispose(): void;
  28825. /**
  28826. * Pushes an action to the worker pool. If all the workers are active, the action will be
  28827. * pended until a worker has completed its action.
  28828. * @param action The action to perform. Call onComplete when the action is complete.
  28829. */
  28830. push(action: (worker: Worker, onComplete: () => void) => void): void;
  28831. private _execute(workerInfo, action);
  28832. }
  28833. }
  28834. declare module BABYLON {
  28835. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  28836. readonly name: string;
  28837. private _zoomStopsAnimation;
  28838. private _idleRotationSpeed;
  28839. private _idleRotationWaitTime;
  28840. private _idleRotationSpinupTime;
  28841. /**
  28842. * Gets the flag that indicates if user zooming should stop animation.
  28843. */
  28844. /**
  28845. * Sets the flag that indicates if user zooming should stop animation.
  28846. */
  28847. zoomStopsAnimation: boolean;
  28848. /**
  28849. * Gets the default speed at which the camera rotates around the model.
  28850. */
  28851. /**
  28852. * Sets the default speed at which the camera rotates around the model.
  28853. */
  28854. idleRotationSpeed: number;
  28855. /**
  28856. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  28857. */
  28858. /**
  28859. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  28860. */
  28861. idleRotationWaitTime: number;
  28862. /**
  28863. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  28864. */
  28865. /**
  28866. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  28867. */
  28868. idleRotationSpinupTime: number;
  28869. /**
  28870. * Gets a value indicating if the camera is currently rotating because of this behavior
  28871. */
  28872. readonly rotationInProgress: boolean;
  28873. private _onPrePointerObservableObserver;
  28874. private _onAfterCheckInputsObserver;
  28875. private _attachedCamera;
  28876. private _isPointerDown;
  28877. private _lastFrameTime;
  28878. private _lastInteractionTime;
  28879. private _cameraRotationSpeed;
  28880. init(): void;
  28881. attach(camera: ArcRotateCamera): void;
  28882. detach(): void;
  28883. /**
  28884. * Returns true if user is scrolling.
  28885. * @return true if user is scrolling.
  28886. */
  28887. private _userIsZooming();
  28888. private _lastFrameRadius;
  28889. private _shouldAnimationStopForInteraction();
  28890. /**
  28891. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  28892. */
  28893. private _applyUserInteraction();
  28894. private _userIsMoving();
  28895. }
  28896. }
  28897. declare module BABYLON {
  28898. /**
  28899. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  28900. */
  28901. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  28902. readonly name: string;
  28903. /**
  28904. * The easing function used by animations
  28905. */
  28906. static EasingFunction: BackEase;
  28907. /**
  28908. * The easing mode used by animations
  28909. */
  28910. static EasingMode: number;
  28911. /**
  28912. * The duration of the animation, in milliseconds
  28913. */
  28914. transitionDuration: number;
  28915. /**
  28916. * Length of the distance animated by the transition when lower radius is reached
  28917. */
  28918. lowerRadiusTransitionRange: number;
  28919. /**
  28920. * Length of the distance animated by the transition when upper radius is reached
  28921. */
  28922. upperRadiusTransitionRange: number;
  28923. private _autoTransitionRange;
  28924. /**
  28925. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  28926. */
  28927. /**
  28928. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  28929. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  28930. */
  28931. autoTransitionRange: boolean;
  28932. private _attachedCamera;
  28933. private _onAfterCheckInputsObserver;
  28934. private _onMeshTargetChangedObserver;
  28935. init(): void;
  28936. attach(camera: ArcRotateCamera): void;
  28937. detach(): void;
  28938. private _radiusIsAnimating;
  28939. private _radiusBounceTransition;
  28940. private _animatables;
  28941. private _cachedWheelPrecision;
  28942. /**
  28943. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  28944. * @param radiusLimit The limit to check against.
  28945. * @return Bool to indicate if at limit.
  28946. */
  28947. private _isRadiusAtLimit(radiusLimit);
  28948. /**
  28949. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  28950. * @param radiusDelta The delta by which to animate to. Can be negative.
  28951. */
  28952. private _applyBoundRadiusAnimation(radiusDelta);
  28953. /**
  28954. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  28955. */
  28956. protected _clearAnimationLocks(): void;
  28957. /**
  28958. * Stops and removes all animations that have been applied to the camera
  28959. */
  28960. stopAllAnimations(): void;
  28961. }
  28962. }
  28963. declare module BABYLON {
  28964. class FramingBehavior implements Behavior<ArcRotateCamera> {
  28965. readonly name: string;
  28966. private _mode;
  28967. private _radiusScale;
  28968. private _positionScale;
  28969. private _defaultElevation;
  28970. private _elevationReturnTime;
  28971. private _elevationReturnWaitTime;
  28972. private _zoomStopsAnimation;
  28973. private _framingTime;
  28974. /**
  28975. * The easing function used by animations
  28976. */
  28977. static EasingFunction: ExponentialEase;
  28978. /**
  28979. * The easing mode used by animations
  28980. */
  28981. static EasingMode: number;
  28982. /**
  28983. * Gets current mode used by the behavior.
  28984. */
  28985. /**
  28986. * Sets the current mode used by the behavior
  28987. */
  28988. mode: number;
  28989. /**
  28990. * Gets the scale applied to the radius
  28991. */
  28992. /**
  28993. * Sets the scale applied to the radius (1 by default)
  28994. */
  28995. radiusScale: number;
  28996. /**
  28997. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  28998. */
  28999. /**
  29000. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  29001. */
  29002. positionScale: number;
  29003. /**
  29004. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29005. * behaviour is triggered, in radians.
  29006. */
  29007. /**
  29008. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29009. * behaviour is triggered, in radians.
  29010. */
  29011. defaultElevation: number;
  29012. /**
  29013. * Gets the time (in milliseconds) taken to return to the default beta position.
  29014. * Negative value indicates camera should not return to default.
  29015. */
  29016. /**
  29017. * Sets the time (in milliseconds) taken to return to the default beta position.
  29018. * Negative value indicates camera should not return to default.
  29019. */
  29020. elevationReturnTime: number;
  29021. /**
  29022. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29023. */
  29024. /**
  29025. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29026. */
  29027. elevationReturnWaitTime: number;
  29028. /**
  29029. * Gets the flag that indicates if user zooming should stop animation.
  29030. */
  29031. /**
  29032. * Sets the flag that indicates if user zooming should stop animation.
  29033. */
  29034. zoomStopsAnimation: boolean;
  29035. /**
  29036. * Gets the transition time when framing the mesh, in milliseconds
  29037. */
  29038. /**
  29039. * Sets the transition time when framing the mesh, in milliseconds
  29040. */
  29041. framingTime: number;
  29042. private _onPrePointerObservableObserver;
  29043. private _onAfterCheckInputsObserver;
  29044. private _onMeshTargetChangedObserver;
  29045. private _attachedCamera;
  29046. private _isPointerDown;
  29047. private _lastInteractionTime;
  29048. init(): void;
  29049. attach(camera: ArcRotateCamera): void;
  29050. detach(): void;
  29051. private _animatables;
  29052. private _betaIsAnimating;
  29053. private _betaTransition;
  29054. private _radiusTransition;
  29055. private _vectorTransition;
  29056. /**
  29057. * Targets the given mesh and updates zoom level accordingly.
  29058. * @param mesh The mesh to target.
  29059. * @param radius Optional. If a cached radius position already exists, overrides default.
  29060. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29061. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29062. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29063. */
  29064. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29065. /**
  29066. * Targets the given mesh with its children and updates zoom level accordingly.
  29067. * @param mesh The mesh to target.
  29068. * @param radius Optional. If a cached radius position already exists, overrides default.
  29069. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29070. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29071. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29072. */
  29073. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29074. /**
  29075. * Targets the given meshes with their children and updates zoom level accordingly.
  29076. * @param meshes The mesh to target.
  29077. * @param radius Optional. If a cached radius position already exists, overrides default.
  29078. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29079. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29080. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29081. */
  29082. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29083. /**
  29084. * Targets the given mesh and updates zoom level accordingly.
  29085. * @param mesh The mesh to target.
  29086. * @param radius Optional. If a cached radius position already exists, overrides default.
  29087. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29088. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29089. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29090. */
  29091. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29092. /**
  29093. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  29094. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  29095. * frustum width.
  29096. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  29097. * to fully enclose the mesh in the viewing frustum.
  29098. */
  29099. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  29100. /**
  29101. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  29102. * is automatically returned to its default position (expected to be above ground plane).
  29103. */
  29104. private _maintainCameraAboveGround();
  29105. /**
  29106. * Returns the frustum slope based on the canvas ratio and camera FOV
  29107. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  29108. */
  29109. private _getFrustumSlope();
  29110. /**
  29111. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  29112. */
  29113. private _clearAnimationLocks();
  29114. /**
  29115. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  29116. */
  29117. private _applyUserInteraction();
  29118. /**
  29119. * Stops and removes all animations that have been applied to the camera
  29120. */
  29121. stopAllAnimations(): void;
  29122. /**
  29123. * Gets a value indicating if the user is moving the camera
  29124. */
  29125. readonly isUserIsMoving: boolean;
  29126. /**
  29127. * The camera can move all the way towards the mesh.
  29128. */
  29129. static IgnoreBoundsSizeMode: number;
  29130. /**
  29131. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  29132. */
  29133. static FitFrustumSidesMode: number;
  29134. }
  29135. }
  29136. declare module BABYLON {
  29137. interface IOctreeContainer<T> {
  29138. blocks: Array<OctreeBlock<T>>;
  29139. }
  29140. class Octree<T> {
  29141. maxDepth: number;
  29142. blocks: Array<OctreeBlock<T>>;
  29143. dynamicContent: T[];
  29144. private _maxBlockCapacity;
  29145. private _selectionContent;
  29146. private _creationFunc;
  29147. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  29148. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  29149. addMesh(entry: T): void;
  29150. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  29151. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  29152. intersectsRay(ray: Ray): SmartArray<T>;
  29153. 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;
  29154. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  29155. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  29156. }
  29157. }
  29158. declare module BABYLON {
  29159. class OctreeBlock<T> {
  29160. entries: T[];
  29161. blocks: Array<OctreeBlock<T>>;
  29162. private _depth;
  29163. private _maxDepth;
  29164. private _capacity;
  29165. private _minPoint;
  29166. private _maxPoint;
  29167. private _boundingVectors;
  29168. private _creationFunc;
  29169. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  29170. readonly capacity: number;
  29171. readonly minPoint: Vector3;
  29172. readonly maxPoint: Vector3;
  29173. addEntry(entry: T): void;
  29174. addEntries(entries: T[]): void;
  29175. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  29176. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  29177. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  29178. createInnerBlocks(): void;
  29179. }
  29180. }
  29181. declare module BABYLON {
  29182. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  29183. camera: ArcRotateCamera;
  29184. gamepad: Nullable<Gamepad>;
  29185. private _onGamepadConnectedObserver;
  29186. private _onGamepadDisconnectedObserver;
  29187. gamepadRotationSensibility: number;
  29188. gamepadMoveSensibility: number;
  29189. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29190. detachControl(element: Nullable<HTMLElement>): void;
  29191. checkInputs(): void;
  29192. getClassName(): string;
  29193. getSimpleName(): string;
  29194. }
  29195. }
  29196. declare module BABYLON {
  29197. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  29198. camera: ArcRotateCamera;
  29199. private _keys;
  29200. keysUp: number[];
  29201. keysDown: number[];
  29202. keysLeft: number[];
  29203. keysRight: number[];
  29204. keysReset: number[];
  29205. panningSensibility: number;
  29206. zoomingSensibility: number;
  29207. useAltToZoom: boolean;
  29208. private _ctrlPressed;
  29209. private _altPressed;
  29210. private _onCanvasBlurObserver;
  29211. private _onKeyboardObserver;
  29212. private _engine;
  29213. private _scene;
  29214. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29215. detachControl(element: Nullable<HTMLElement>): void;
  29216. checkInputs(): void;
  29217. getClassName(): string;
  29218. getSimpleName(): string;
  29219. }
  29220. }
  29221. declare module BABYLON {
  29222. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  29223. camera: ArcRotateCamera;
  29224. private _wheel;
  29225. private _observer;
  29226. wheelPrecision: number;
  29227. /**
  29228. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  29229. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  29230. */
  29231. wheelDeltaPercentage: number;
  29232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29233. detachControl(element: Nullable<HTMLElement>): void;
  29234. getClassName(): string;
  29235. getSimpleName(): string;
  29236. }
  29237. }
  29238. declare module BABYLON {
  29239. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  29240. camera: ArcRotateCamera;
  29241. buttons: number[];
  29242. angularSensibilityX: number;
  29243. angularSensibilityY: number;
  29244. pinchPrecision: number;
  29245. /**
  29246. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  29247. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  29248. */
  29249. pinchDeltaPercentage: number;
  29250. panningSensibility: number;
  29251. multiTouchPanning: boolean;
  29252. multiTouchPanAndZoom: boolean;
  29253. private _isPanClick;
  29254. pinchInwards: boolean;
  29255. private _pointerInput;
  29256. private _observer;
  29257. private _onMouseMove;
  29258. private _onGestureStart;
  29259. private _onGesture;
  29260. private _MSGestureHandler;
  29261. private _onLostFocus;
  29262. private _onContextMenu;
  29263. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29264. detachControl(element: Nullable<HTMLElement>): void;
  29265. getClassName(): string;
  29266. getSimpleName(): string;
  29267. }
  29268. }
  29269. declare module BABYLON {
  29270. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  29271. camera: ArcRotateCamera;
  29272. alphaCorrection: number;
  29273. betaCorrection: number;
  29274. gammaCorrection: number;
  29275. private _alpha;
  29276. private _gamma;
  29277. private _dirty;
  29278. private _deviceOrientationHandler;
  29279. constructor();
  29280. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29281. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  29282. checkInputs(): void;
  29283. detachControl(element: Nullable<HTMLElement>): void;
  29284. getClassName(): string;
  29285. getSimpleName(): string;
  29286. }
  29287. }
  29288. declare module BABYLON {
  29289. /**
  29290. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  29291. * Screen rotation is taken into account.
  29292. */
  29293. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  29294. private _camera;
  29295. private _screenOrientationAngle;
  29296. private _constantTranform;
  29297. private _screenQuaternion;
  29298. private _alpha;
  29299. private _beta;
  29300. private _gamma;
  29301. constructor();
  29302. camera: FreeCamera;
  29303. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29304. private _orientationChanged;
  29305. private _deviceOrientation;
  29306. detachControl(element: Nullable<HTMLElement>): void;
  29307. checkInputs(): void;
  29308. getClassName(): string;
  29309. getSimpleName(): string;
  29310. }
  29311. }
  29312. declare module BABYLON {
  29313. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  29314. camera: FreeCamera;
  29315. gamepad: Nullable<Gamepad>;
  29316. private _onGamepadConnectedObserver;
  29317. private _onGamepadDisconnectedObserver;
  29318. gamepadAngularSensibility: number;
  29319. gamepadMoveSensibility: number;
  29320. private _cameraTransform;
  29321. private _deltaTransform;
  29322. private _vector3;
  29323. private _vector2;
  29324. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29325. detachControl(element: Nullable<HTMLElement>): void;
  29326. checkInputs(): void;
  29327. getClassName(): string;
  29328. getSimpleName(): string;
  29329. }
  29330. }
  29331. declare module BABYLON {
  29332. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  29333. camera: FreeCamera;
  29334. private _keys;
  29335. private _onCanvasBlurObserver;
  29336. private _onKeyboardObserver;
  29337. private _engine;
  29338. private _scene;
  29339. keysUp: number[];
  29340. keysDown: number[];
  29341. keysLeft: number[];
  29342. keysRight: number[];
  29343. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29344. detachControl(element: Nullable<HTMLElement>): void;
  29345. checkInputs(): void;
  29346. getClassName(): string;
  29347. _onLostFocus(e: FocusEvent): void;
  29348. getSimpleName(): string;
  29349. }
  29350. }
  29351. declare module BABYLON {
  29352. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  29353. touchEnabled: boolean;
  29354. camera: FreeCamera;
  29355. buttons: number[];
  29356. angularSensibility: number;
  29357. private _pointerInput;
  29358. private _onMouseMove;
  29359. private _observer;
  29360. private previousPosition;
  29361. constructor(touchEnabled?: boolean);
  29362. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29363. detachControl(element: Nullable<HTMLElement>): void;
  29364. getClassName(): string;
  29365. getSimpleName(): string;
  29366. }
  29367. }
  29368. declare module BABYLON {
  29369. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  29370. camera: FreeCamera;
  29371. private _offsetX;
  29372. private _offsetY;
  29373. private _pointerPressed;
  29374. private _pointerInput;
  29375. private _observer;
  29376. private _onLostFocus;
  29377. touchAngularSensibility: number;
  29378. touchMoveSensibility: number;
  29379. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29380. detachControl(element: Nullable<HTMLElement>): void;
  29381. checkInputs(): void;
  29382. getClassName(): string;
  29383. getSimpleName(): string;
  29384. }
  29385. }
  29386. declare module BABYLON {
  29387. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  29388. camera: FreeCamera;
  29389. private _leftjoystick;
  29390. private _rightjoystick;
  29391. getLeftJoystick(): VirtualJoystick;
  29392. getRightJoystick(): VirtualJoystick;
  29393. checkInputs(): void;
  29394. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29395. detachControl(element: Nullable<HTMLElement>): void;
  29396. getClassName(): string;
  29397. getSimpleName(): string;
  29398. }
  29399. }
  29400. declare module BABYLON {
  29401. class VRCameraMetrics {
  29402. hResolution: number;
  29403. vResolution: number;
  29404. hScreenSize: number;
  29405. vScreenSize: number;
  29406. vScreenCenter: number;
  29407. eyeToScreenDistance: number;
  29408. lensSeparationDistance: number;
  29409. interpupillaryDistance: number;
  29410. distortionK: number[];
  29411. chromaAbCorrection: number[];
  29412. postProcessScaleFactor: number;
  29413. lensCenterOffset: number;
  29414. compensateDistortion: boolean;
  29415. readonly aspectRatio: number;
  29416. readonly aspectRatioFov: number;
  29417. readonly leftHMatrix: Matrix;
  29418. readonly rightHMatrix: Matrix;
  29419. readonly leftPreViewMatrix: Matrix;
  29420. readonly rightPreViewMatrix: Matrix;
  29421. static GetDefault(): VRCameraMetrics;
  29422. }
  29423. }
  29424. declare module BABYLON {
  29425. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  29426. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29427. getClassName(): string;
  29428. }
  29429. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  29430. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29431. getClassName(): string;
  29432. }
  29433. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  29434. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29435. getClassName(): string;
  29436. }
  29437. }
  29438. declare module BABYLON {
  29439. /**
  29440. * Options to modify the vr teleportation behavior.
  29441. */
  29442. interface VRTeleportationOptions {
  29443. /**
  29444. * The name of the mesh which should be used as the teleportation floor. (default: null)
  29445. */
  29446. floorMeshName?: string;
  29447. /**
  29448. * A list of meshes to be used as the teleportation floor. (default: empty)
  29449. */
  29450. floorMeshes?: Mesh[];
  29451. }
  29452. /**
  29453. * Options to modify the vr experience helper's behavior.
  29454. */
  29455. interface VRExperienceHelperOptions extends WebVROptions {
  29456. /**
  29457. * Create a DeviceOrientationCamera to be used as your out of vr camera.
  29458. */
  29459. createDeviceOrientationCamera?: boolean;
  29460. /**
  29461. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found.
  29462. */
  29463. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  29464. }
  29465. /**
  29466. * Helps to quickly add VR support to an existing scene.
  29467. * See http://doc.babylonjs.com/how_to/webvr_helper
  29468. */
  29469. class VRExperienceHelper {
  29470. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  29471. private _scene;
  29472. private _position;
  29473. private _btnVR;
  29474. private _btnVRDisplayed;
  29475. private _webVRsupported;
  29476. private _webVRready;
  29477. private _webVRrequesting;
  29478. private _webVRpresenting;
  29479. private _fullscreenVRpresenting;
  29480. private _canvas;
  29481. private _webVRCamera;
  29482. private _vrDeviceOrientationCamera;
  29483. private _deviceOrientationCamera;
  29484. private _existingCamera;
  29485. private _onKeyDown;
  29486. private _onVrDisplayPresentChange;
  29487. private _onVRDisplayChanged;
  29488. private _onVRRequestPresentStart;
  29489. private _onVRRequestPresentComplete;
  29490. /**
  29491. * Observable raised when entering VR.
  29492. */
  29493. onEnteringVRObservable: Observable<VRExperienceHelper>;
  29494. /**
  29495. * Observable raised when exiting VR.
  29496. */
  29497. onExitingVRObservable: Observable<VRExperienceHelper>;
  29498. /**
  29499. * Observable raised when controller mesh is loaded.
  29500. */
  29501. onControllerMeshLoadedObservable: Observable<WebVRController>;
  29502. /** Return this.onEnteringVRObservable
  29503. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  29504. */
  29505. readonly onEnteringVR: Observable<VRExperienceHelper>;
  29506. /** Return this.onExitingVRObservable
  29507. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  29508. */
  29509. readonly onExitingVR: Observable<VRExperienceHelper>;
  29510. /** Return this.onControllerMeshLoadedObservable
  29511. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  29512. */
  29513. readonly onControllerMeshLoaded: Observable<WebVRController>;
  29514. private _rayLength;
  29515. private _useCustomVRButton;
  29516. private _teleportationRequested;
  29517. private _teleportActive;
  29518. private _floorMeshName;
  29519. private _floorMeshesCollection;
  29520. private _rotationAllowed;
  29521. private _teleportBackwardsVector;
  29522. private _teleportationTarget;
  29523. private _isDefaultTeleportationTarget;
  29524. private _postProcessMove;
  29525. private _teleportationFillColor;
  29526. private _teleportationBorderColor;
  29527. private _rotationAngle;
  29528. private _haloCenter;
  29529. private _cameraGazer;
  29530. private _padSensibilityUp;
  29531. private _padSensibilityDown;
  29532. private leftController;
  29533. private rightController;
  29534. /**
  29535. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  29536. */
  29537. onNewMeshSelected: Observable<AbstractMesh>;
  29538. /**
  29539. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  29540. */
  29541. onNewMeshPicked: Observable<PickingInfo>;
  29542. private _circleEase;
  29543. /**
  29544. * Observable raised before camera teleportation
  29545. */
  29546. onBeforeCameraTeleport: Observable<Vector3>;
  29547. /**
  29548. * Observable raised after camera teleportation
  29549. */
  29550. onAfterCameraTeleport: Observable<Vector3>;
  29551. /**
  29552. * Observable raised when current selected mesh gets unselected
  29553. */
  29554. onSelectedMeshUnselected: Observable<AbstractMesh>;
  29555. private _raySelectionPredicate;
  29556. /**
  29557. * To be optionaly changed by user to define custom ray selection
  29558. */
  29559. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  29560. /**
  29561. * To be optionaly changed by user to define custom selection logic (after ray selection)
  29562. */
  29563. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  29564. /**
  29565. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  29566. */
  29567. teleportationEnabled: boolean;
  29568. private _defaultHeight;
  29569. private _teleportationInitialized;
  29570. private _interactionsEnabled;
  29571. private _interactionsRequested;
  29572. private _displayGaze;
  29573. private _displayLaserPointer;
  29574. /**
  29575. * The mesh used to display where the user is going to teleport.
  29576. */
  29577. /**
  29578. * Sets the mesh to be used to display where the user is going to teleport.
  29579. */
  29580. teleportationTarget: Mesh;
  29581. /**
  29582. * The mesh used to display where the user is selecting,
  29583. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  29584. * See http://doc.babylonjs.com/resources/baking_transformations
  29585. */
  29586. gazeTrackerMesh: Mesh;
  29587. /**
  29588. * If the ray of the gaze should be displayed.
  29589. */
  29590. /**
  29591. * Sets if the ray of the gaze should be displayed.
  29592. */
  29593. displayGaze: boolean;
  29594. /**
  29595. * If the ray of the LaserPointer should be displayed.
  29596. */
  29597. /**
  29598. * Sets if the ray of the LaserPointer should be displayed.
  29599. */
  29600. displayLaserPointer: boolean;
  29601. /**
  29602. * The deviceOrientationCamera used as the camera when not in VR.
  29603. */
  29604. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  29605. /**
  29606. * Based on the current WebVR support, returns the current VR camera used.
  29607. */
  29608. readonly currentVRCamera: Nullable<Camera>;
  29609. /**
  29610. * The webVRCamera which is used when in VR.
  29611. */
  29612. readonly webVRCamera: WebVRFreeCamera;
  29613. /**
  29614. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  29615. */
  29616. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  29617. private readonly _teleportationRequestInitiated;
  29618. /**
  29619. * Instantiates a VRExperienceHelper.
  29620. * Helps to quickly add VR support to an existing scene.
  29621. * @param scene The scene the VRExperienceHelper belongs to.
  29622. * @param webVROptions Options to modify the vr experience helper's behavior.
  29623. */
  29624. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  29625. private _onDefaultMeshLoaded(webVRController);
  29626. private _onResize;
  29627. private _onFullscreenChange;
  29628. /**
  29629. * Gets a value indicating if we are currently in VR mode.
  29630. */
  29631. readonly isInVRMode: boolean;
  29632. private onVrDisplayPresentChange();
  29633. private onVRDisplayChanged(eventArgs);
  29634. private moveButtonToBottomRight();
  29635. private displayVRButton();
  29636. private updateButtonVisibility();
  29637. /**
  29638. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  29639. * Otherwise, will use the fullscreen API.
  29640. */
  29641. enterVR(): void;
  29642. /**
  29643. * Attempt to exit VR, or fullscreen.
  29644. */
  29645. exitVR(): void;
  29646. /**
  29647. * The position of the vr experience helper.
  29648. */
  29649. /**
  29650. * Sets the position of the vr experience helper.
  29651. */
  29652. position: Vector3;
  29653. /**
  29654. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  29655. */
  29656. enableInteractions(): void;
  29657. private beforeRender;
  29658. private _isTeleportationFloor(mesh);
  29659. /**
  29660. * Adds a floor mesh to be used for teleportation.
  29661. * @param floorMesh the mesh to be used for teleportation.
  29662. */
  29663. addFloorMesh(floorMesh: Mesh): void;
  29664. /**
  29665. * Removes a floor mesh from being used for teleportation.
  29666. * @param floorMesh the mesh to be removed.
  29667. */
  29668. removeFloorMesh(floorMesh: Mesh): void;
  29669. /**
  29670. * Enables interactions and teleportation using the VR controllers and gaze.
  29671. * @param vrTeleportationOptions options to modify teleportation behavior.
  29672. */
  29673. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  29674. private _onNewGamepadConnected;
  29675. private _tryEnableInteractionOnController;
  29676. private _onNewGamepadDisconnected;
  29677. private _enableInteractionOnController(controller);
  29678. private _checkTeleportWithRay(stateObject, gazer);
  29679. private _checkRotate(stateObject, gazer);
  29680. private _checkTeleportBackwards(stateObject, gazer);
  29681. private _enableTeleportationOnController(controller);
  29682. private _createTeleportationCircles();
  29683. private _displayTeleportationTarget();
  29684. private _hideTeleportationTarget();
  29685. private _rotateCamera(right);
  29686. private _moveTeleportationSelectorTo(hit, gazer, ray);
  29687. private _workingVector;
  29688. private _workingQuaternion;
  29689. private _workingMatrix;
  29690. private _teleportCamera(location);
  29691. private _convertNormalToDirectionOfRay(normal, ray);
  29692. private _castRayAndSelectObject(gazer);
  29693. private _notifySelectedMeshUnselected(mesh);
  29694. /**
  29695. * Sets the color of the laser ray from the vr controllers.
  29696. * @param color new color for the ray.
  29697. */
  29698. changeLaserColor(color: Color3): void;
  29699. /**
  29700. * Sets the color of the ray from the vr headsets gaze.
  29701. * @param color new color for the ray.
  29702. */
  29703. changeGazeColor(color: Color3): void;
  29704. /**
  29705. * Exits VR and disposes of the vr experience helper
  29706. */
  29707. dispose(): void;
  29708. /**
  29709. * Gets the name of the VRExperienceHelper class
  29710. * @returns "VRExperienceHelper"
  29711. */
  29712. getClassName(): string;
  29713. }
  29714. }
  29715. declare module BABYLON {
  29716. /**
  29717. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  29718. * IMPORTANT!! The data is right-hand data.
  29719. * @export
  29720. * @interface DevicePose
  29721. */
  29722. interface DevicePose {
  29723. /**
  29724. * The position of the device, values in array are [x,y,z].
  29725. */
  29726. readonly position: Nullable<Float32Array>;
  29727. /**
  29728. * The linearVelocity of the device, values in array are [x,y,z].
  29729. */
  29730. readonly linearVelocity: Nullable<Float32Array>;
  29731. /**
  29732. * The linearAcceleration of the device, values in array are [x,y,z].
  29733. */
  29734. readonly linearAcceleration: Nullable<Float32Array>;
  29735. /**
  29736. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  29737. */
  29738. readonly orientation: Nullable<Float32Array>;
  29739. /**
  29740. * The angularVelocity of the device, values in array are [x,y,z].
  29741. */
  29742. readonly angularVelocity: Nullable<Float32Array>;
  29743. /**
  29744. * The angularAcceleration of the device, values in array are [x,y,z].
  29745. */
  29746. readonly angularAcceleration: Nullable<Float32Array>;
  29747. }
  29748. /**
  29749. * Interface representing a pose controlled object in Babylon.
  29750. * A pose controlled object has both regular pose values as well as pose values
  29751. * from an external device such as a VR head mounted display
  29752. */
  29753. interface PoseControlled {
  29754. /**
  29755. * The position of the object in babylon space.
  29756. */
  29757. position: Vector3;
  29758. /**
  29759. * The rotation quaternion of the object in babylon space.
  29760. */
  29761. rotationQuaternion: Quaternion;
  29762. /**
  29763. * The position of the device in babylon space.
  29764. */
  29765. devicePosition?: Vector3;
  29766. /**
  29767. * The rotation quaternion of the device in babylon space.
  29768. */
  29769. deviceRotationQuaternion: Quaternion;
  29770. /**
  29771. * The raw pose coming from the device.
  29772. */
  29773. rawPose: Nullable<DevicePose>;
  29774. /**
  29775. * The scale of the device to be used when translating from device space to babylon space.
  29776. */
  29777. deviceScaleFactor: number;
  29778. /**
  29779. * Updates the poseControlled values based on the input device pose.
  29780. * @param poseData the pose data to update the object with
  29781. */
  29782. updateFromDevice(poseData: DevicePose): void;
  29783. }
  29784. /**
  29785. * Set of options to customize the webVRCamera
  29786. */
  29787. interface WebVROptions {
  29788. /**
  29789. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  29790. */
  29791. trackPosition?: boolean;
  29792. /**
  29793. * Sets the scale of the vrDevice in babylon space. (default: 1)
  29794. */
  29795. positionScale?: number;
  29796. /**
  29797. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  29798. */
  29799. displayName?: string;
  29800. /**
  29801. * Should the native controller meshes be initialized. (default: true)
  29802. */
  29803. controllerMeshes?: boolean;
  29804. /**
  29805. * Creating a default HemiLight only on controllers. (default: true)
  29806. */
  29807. defaultLightingOnControllers?: boolean;
  29808. /**
  29809. * If you don't want to use the default VR button of the helper. (default: false)
  29810. */
  29811. useCustomVRButton?: boolean;
  29812. /**
  29813. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  29814. */
  29815. customVRButton?: HTMLButtonElement;
  29816. /**
  29817. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  29818. */
  29819. rayLength?: number;
  29820. /**
  29821. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  29822. */
  29823. defaultHeight?: number;
  29824. }
  29825. /**
  29826. * This represents a WebVR camera.
  29827. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  29828. * @example http://doc.babylonjs.com/how_to/webvr_camera
  29829. */
  29830. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  29831. private webVROptions;
  29832. /**
  29833. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  29834. */
  29835. _vrDevice: any;
  29836. /**
  29837. * The rawPose of the vrDevice.
  29838. */
  29839. rawPose: Nullable<DevicePose>;
  29840. private _onVREnabled;
  29841. private _specsVersion;
  29842. private _attached;
  29843. private _frameData;
  29844. protected _descendants: Array<Node>;
  29845. private _deviceRoomPosition;
  29846. private _deviceRoomRotationQuaternion;
  29847. private _standingMatrix;
  29848. /**
  29849. * Represents device position in babylon space.
  29850. */
  29851. devicePosition: Vector3;
  29852. /**
  29853. * Represents device rotation in babylon space.
  29854. */
  29855. deviceRotationQuaternion: Quaternion;
  29856. /**
  29857. * The scale of the device to be used when translating from device space to babylon space.
  29858. */
  29859. deviceScaleFactor: number;
  29860. private _deviceToWorld;
  29861. private _worldToDevice;
  29862. /**
  29863. * References to the webVR controllers for the vrDevice.
  29864. */
  29865. controllers: Array<WebVRController>;
  29866. /**
  29867. * Emits an event when a controller is attached.
  29868. */
  29869. onControllersAttachedObservable: Observable<WebVRController[]>;
  29870. /**
  29871. * Emits an event when a controller's mesh has been loaded;
  29872. */
  29873. onControllerMeshLoadedObservable: Observable<WebVRController>;
  29874. /**
  29875. * If the rig cameras be used as parent instead of this camera.
  29876. */
  29877. rigParenting: boolean;
  29878. private _lightOnControllers;
  29879. private _defaultHeight?;
  29880. /**
  29881. * Instantiates a WebVRFreeCamera.
  29882. * @param name The name of the WebVRFreeCamera
  29883. * @param position The starting anchor position for the camera
  29884. * @param scene The scene the camera belongs to
  29885. * @param webVROptions a set of customizable options for the webVRCamera
  29886. */
  29887. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  29888. /**
  29889. * Gets the device distance from the ground in meters.
  29890. * @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.
  29891. */
  29892. deviceDistanceToRoomGround(): number;
  29893. /**
  29894. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  29895. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  29896. */
  29897. useStandingMatrix(callback?: (bool: boolean) => void): void;
  29898. /**
  29899. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  29900. * @returns A promise with a boolean set to if the standing matrix is supported.
  29901. */
  29902. useStandingMatrixAsync(): Promise<boolean>;
  29903. /**
  29904. * Disposes the camera
  29905. */
  29906. dispose(): void;
  29907. /**
  29908. * Gets a vrController by name.
  29909. * @param name The name of the controller to retreive
  29910. * @returns the controller matching the name specified or null if not found
  29911. */
  29912. getControllerByName(name: string): Nullable<WebVRController>;
  29913. private _leftController;
  29914. /**
  29915. * The controller corrisponding to the users left hand.
  29916. */
  29917. readonly leftController: Nullable<WebVRController>;
  29918. private _rightController;
  29919. /**
  29920. * The controller corrisponding to the users right hand.
  29921. */
  29922. readonly rightController: Nullable<WebVRController>;
  29923. /**
  29924. * Casts a ray forward from the vrCamera's gaze.
  29925. * @param length Length of the ray (default: 100)
  29926. * @returns the ray corrisponding to the gaze
  29927. */
  29928. getForwardRay(length?: number): Ray;
  29929. /**
  29930. * Updates the camera based on device's frame data
  29931. */
  29932. _checkInputs(): void;
  29933. /**
  29934. * Updates the poseControlled values based on the input device pose.
  29935. * @param poseData Pose coming from the device
  29936. */
  29937. updateFromDevice(poseData: DevicePose): void;
  29938. /**
  29939. * WebVR's attach control will start broadcasting frames to the device.
  29940. * Note that in certain browsers (chrome for example) this function must be called
  29941. * within a user-interaction callback. Example:
  29942. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  29943. *
  29944. * @param element html element to attach the vrDevice to
  29945. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  29946. */
  29947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29948. /**
  29949. * Detaches the camera from the html element and disables VR
  29950. *
  29951. * @param element html element to detach from
  29952. */
  29953. detachControl(element: HTMLElement): void;
  29954. /**
  29955. * @returns the name of this class
  29956. */
  29957. getClassName(): string;
  29958. /**
  29959. * Calls resetPose on the vrDisplay
  29960. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  29961. */
  29962. resetToCurrentRotation(): void;
  29963. /**
  29964. * Updates the rig cameras (left and right eye)
  29965. */
  29966. _updateRigCameras(): void;
  29967. private _workingVector;
  29968. private _oneVector;
  29969. private _workingMatrix;
  29970. private updateCacheCalled;
  29971. /**
  29972. * Updates the cached values of the camera
  29973. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  29974. */
  29975. _updateCache(ignoreParentClass?: boolean): void;
  29976. /**
  29977. * Updates the current device position and rotation in the babylon world
  29978. */
  29979. update(): void;
  29980. /**
  29981. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  29982. * @returns an identity matrix
  29983. */
  29984. _getViewMatrix(): Matrix;
  29985. /**
  29986. * This function is called by the two RIG cameras.
  29987. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  29988. */
  29989. protected _getWebVRViewMatrix(): Matrix;
  29990. protected _getWebVRProjectionMatrix(): Matrix;
  29991. private _onGamepadConnectedObserver;
  29992. private _onGamepadDisconnectedObserver;
  29993. /**
  29994. * Initializes the controllers and their meshes
  29995. */
  29996. initControllers(): void;
  29997. }
  29998. }
  29999. declare module BABYLON {
  30000. /**
  30001. * Google Daydream controller
  30002. */
  30003. class DaydreamController extends WebVRController {
  30004. /**
  30005. * Base Url for the controller model.
  30006. */
  30007. static MODEL_BASE_URL: string;
  30008. /**
  30009. * File name for the controller model.
  30010. */
  30011. static MODEL_FILENAME: string;
  30012. /**
  30013. * Gamepad Id prefix used to identify Daydream Controller.
  30014. */
  30015. static readonly GAMEPAD_ID_PREFIX: string;
  30016. /**
  30017. * Creates a new DaydreamController from a gamepad
  30018. * @param vrGamepad the gamepad that the controller should be created from
  30019. */
  30020. constructor(vrGamepad: any);
  30021. /**
  30022. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30023. * @param scene scene in which to add meshes
  30024. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30025. */
  30026. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30027. /**
  30028. * Called once for each button that changed state since the last frame
  30029. * @param buttonIdx Which button index changed
  30030. * @param state New state of the button
  30031. * @param changes Which properties on the state changed since last frame
  30032. */
  30033. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30034. }
  30035. }
  30036. declare module BABYLON {
  30037. /**
  30038. * Gear VR Controller
  30039. */
  30040. class GearVRController extends WebVRController {
  30041. /**
  30042. * Base Url for the controller model.
  30043. */
  30044. static MODEL_BASE_URL: string;
  30045. /**
  30046. * File name for the controller model.
  30047. */
  30048. static MODEL_FILENAME: string;
  30049. /**
  30050. * Gamepad Id prefix used to identify this controller.
  30051. */
  30052. static readonly GAMEPAD_ID_PREFIX: string;
  30053. private readonly _buttonIndexToObservableNameMap;
  30054. /**
  30055. * Creates a new GearVRController from a gamepad
  30056. * @param vrGamepad the gamepad that the controller should be created from
  30057. */
  30058. constructor(vrGamepad: any);
  30059. /**
  30060. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30061. * @param scene scene in which to add meshes
  30062. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30063. */
  30064. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30065. /**
  30066. * Called once for each button that changed state since the last frame
  30067. * @param buttonIdx Which button index changed
  30068. * @param state New state of the button
  30069. * @param changes Which properties on the state changed since last frame
  30070. */
  30071. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30072. }
  30073. }
  30074. declare module BABYLON {
  30075. /**
  30076. * Generic Controller
  30077. */
  30078. class GenericController extends WebVRController {
  30079. /**
  30080. * Base Url for the controller model.
  30081. */
  30082. static readonly MODEL_BASE_URL: string;
  30083. /**
  30084. * File name for the controller model.
  30085. */
  30086. static readonly MODEL_FILENAME: string;
  30087. /**
  30088. * Creates a new GenericController from a gamepad
  30089. * @param vrGamepad the gamepad that the controller should be created from
  30090. */
  30091. constructor(vrGamepad: any);
  30092. /**
  30093. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30094. * @param scene scene in which to add meshes
  30095. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30096. */
  30097. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30098. /**
  30099. * Called once for each button that changed state since the last frame
  30100. * @param buttonIdx Which button index changed
  30101. * @param state New state of the button
  30102. * @param changes Which properties on the state changed since last frame
  30103. */
  30104. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30105. }
  30106. }
  30107. declare module BABYLON {
  30108. /**
  30109. * Oculus Touch Controller
  30110. */
  30111. class OculusTouchController extends WebVRController {
  30112. /**
  30113. * Base Url for the controller model.
  30114. */
  30115. static MODEL_BASE_URL: string;
  30116. /**
  30117. * File name for the left controller model.
  30118. */
  30119. static MODEL_LEFT_FILENAME: string;
  30120. /**
  30121. * File name for the right controller model.
  30122. */
  30123. static MODEL_RIGHT_FILENAME: string;
  30124. /**
  30125. * Fired when the secondary trigger on this controller is modified
  30126. */
  30127. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  30128. /**
  30129. * Fired when the thumb rest on this controller is modified
  30130. */
  30131. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  30132. /**
  30133. * Creates a new OculusTouchController from a gamepad
  30134. * @param vrGamepad the gamepad that the controller should be created from
  30135. */
  30136. constructor(vrGamepad: any);
  30137. /**
  30138. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30139. * @param scene scene in which to add meshes
  30140. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30141. */
  30142. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30143. /**
  30144. * Fired when the A button on this controller is modified
  30145. */
  30146. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30147. /**
  30148. * Fired when the B button on this controller is modified
  30149. */
  30150. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30151. /**
  30152. * Fired when the X button on this controller is modified
  30153. */
  30154. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30155. /**
  30156. * Fired when the Y button on this controller is modified
  30157. */
  30158. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30159. /**
  30160. * Called once for each button that changed state since the last frame
  30161. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  30162. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  30163. * 2) secondary trigger (same)
  30164. * 3) A (right) X (left), touch, pressed = value
  30165. * 4) B / Y
  30166. * 5) thumb rest
  30167. * @param buttonIdx Which button index changed
  30168. * @param state New state of the button
  30169. * @param changes Which properties on the state changed since last frame
  30170. */
  30171. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30172. }
  30173. }
  30174. declare module BABYLON {
  30175. /**
  30176. * Defines the types of pose enabled controllers that are supported
  30177. */
  30178. enum PoseEnabledControllerType {
  30179. /**
  30180. * HTC Vive
  30181. */
  30182. VIVE = 0,
  30183. /**
  30184. * Oculus Rift
  30185. */
  30186. OCULUS = 1,
  30187. /**
  30188. * Windows mixed reality
  30189. */
  30190. WINDOWS = 2,
  30191. /**
  30192. * Samsung gear VR
  30193. */
  30194. GEAR_VR = 3,
  30195. /**
  30196. * Google Daydream
  30197. */
  30198. DAYDREAM = 4,
  30199. /**
  30200. * Generic
  30201. */
  30202. GENERIC = 5,
  30203. }
  30204. /**
  30205. * Defines the MutableGamepadButton interface for the state of a gamepad button
  30206. */
  30207. interface MutableGamepadButton {
  30208. /**
  30209. * Value of the button/trigger
  30210. */
  30211. value: number;
  30212. /**
  30213. * If the button/trigger is currently touched
  30214. */
  30215. touched: boolean;
  30216. /**
  30217. * If the button/trigger is currently pressed
  30218. */
  30219. pressed: boolean;
  30220. }
  30221. /**
  30222. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  30223. * @hidden
  30224. */
  30225. interface ExtendedGamepadButton extends GamepadButton {
  30226. /**
  30227. * If the button/trigger is currently pressed
  30228. */
  30229. readonly pressed: boolean;
  30230. /**
  30231. * If the button/trigger is currently touched
  30232. */
  30233. readonly touched: boolean;
  30234. /**
  30235. * Value of the button/trigger
  30236. */
  30237. readonly value: number;
  30238. }
  30239. /**
  30240. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30241. */
  30242. class PoseEnabledControllerHelper {
  30243. /**
  30244. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30245. * @param vrGamepad the gamepad to initialized
  30246. * @returns a vr controller of the type the gamepad identified as
  30247. */
  30248. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  30249. }
  30250. /**
  30251. * Defines the PoseEnabledController object that contains state of a vr capable controller
  30252. */
  30253. class PoseEnabledController extends Gamepad implements PoseControlled {
  30254. private _deviceRoomPosition;
  30255. private _deviceRoomRotationQuaternion;
  30256. /**
  30257. * The device position in babylon space
  30258. */
  30259. devicePosition: Vector3;
  30260. /**
  30261. * The device rotation in babylon space
  30262. */
  30263. deviceRotationQuaternion: Quaternion;
  30264. /**
  30265. * The scale factor of the device in babylon space
  30266. */
  30267. deviceScaleFactor: number;
  30268. /**
  30269. * (Likely devicePosition should be used instead) The device position in its room space
  30270. */
  30271. position: Vector3;
  30272. /**
  30273. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  30274. */
  30275. rotationQuaternion: Quaternion;
  30276. /**
  30277. * The type of controller (Eg. Windows mixed reality)
  30278. */
  30279. controllerType: PoseEnabledControllerType;
  30280. private _calculatedPosition;
  30281. private _calculatedRotation;
  30282. /**
  30283. * The raw pose from the device
  30284. */
  30285. rawPose: DevicePose;
  30286. /**
  30287. * Internal, the mesh attached to the controller
  30288. */
  30289. _mesh: Nullable<AbstractMesh>;
  30290. private _poseControlledCamera;
  30291. private _leftHandSystemQuaternion;
  30292. /**
  30293. * Internal, matrix used to convert room space to babylon space
  30294. */
  30295. _deviceToWorld: Matrix;
  30296. /**
  30297. * Node to be used when casting a ray from the controller
  30298. */
  30299. _pointingPoseNode: Nullable<AbstractMesh>;
  30300. /**
  30301. * Name of the child mesh that can be used to cast a ray from the controller
  30302. */
  30303. static readonly POINTING_POSE: string;
  30304. /**
  30305. * Creates a new PoseEnabledController from a gamepad
  30306. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  30307. */
  30308. constructor(browserGamepad: any);
  30309. private _workingMatrix;
  30310. /**
  30311. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  30312. */
  30313. update(): void;
  30314. /**
  30315. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  30316. * @param poseData raw pose fromthe device
  30317. */
  30318. updateFromDevice(poseData: DevicePose): void;
  30319. /**
  30320. * @hidden
  30321. */
  30322. _meshAttachedObservable: Observable<AbstractMesh>;
  30323. /**
  30324. * Attaches a mesh to the controller
  30325. * @param mesh the mesh to be attached
  30326. */
  30327. attachToMesh(mesh: AbstractMesh): void;
  30328. /**
  30329. * Attaches the controllers mesh to a camera
  30330. * @param camera the camera the mesh should be attached to
  30331. */
  30332. attachToPoseControlledCamera(camera: TargetCamera): void;
  30333. /**
  30334. * Disposes of the controller
  30335. */
  30336. dispose(): void;
  30337. /**
  30338. * The mesh that is attached to the controller
  30339. */
  30340. readonly mesh: Nullable<AbstractMesh>;
  30341. /**
  30342. * Gets the ray of the controller in the direction the controller is pointing
  30343. * @param length the length the resulting ray should be
  30344. * @returns a ray in the direction the controller is pointing
  30345. */
  30346. getForwardRay(length?: number): Ray;
  30347. }
  30348. }
  30349. declare module BABYLON {
  30350. /**
  30351. * Vive Controller
  30352. */
  30353. class ViveController extends WebVRController {
  30354. /**
  30355. * Base Url for the controller model.
  30356. */
  30357. static MODEL_BASE_URL: string;
  30358. /**
  30359. * File name for the controller model.
  30360. */
  30361. static MODEL_FILENAME: string;
  30362. /**
  30363. * Creates a new ViveController from a gamepad
  30364. * @param vrGamepad the gamepad that the controller should be created from
  30365. */
  30366. constructor(vrGamepad: any);
  30367. /**
  30368. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30369. * @param scene scene in which to add meshes
  30370. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30371. */
  30372. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30373. /**
  30374. * Fired when the left button on this controller is modified
  30375. */
  30376. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30377. /**
  30378. * Fired when the right button on this controller is modified
  30379. */
  30380. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30381. /**
  30382. * Fired when the menu button on this controller is modified
  30383. */
  30384. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30385. /**
  30386. * Called once for each button that changed state since the last frame
  30387. * Vive mapping:
  30388. * 0: touchpad
  30389. * 1: trigger
  30390. * 2: left AND right buttons
  30391. * 3: menu button
  30392. * @param buttonIdx Which button index changed
  30393. * @param state New state of the button
  30394. * @param changes Which properties on the state changed since last frame
  30395. */
  30396. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30397. }
  30398. }
  30399. declare module BABYLON {
  30400. /**
  30401. * Defines the WebVRController object that represents controllers tracked in 3D space
  30402. */
  30403. abstract class WebVRController extends PoseEnabledController {
  30404. /**
  30405. * Internal, the default controller model for the controller
  30406. */
  30407. protected _defaultModel: AbstractMesh;
  30408. /**
  30409. * Fired when the trigger state has changed
  30410. */
  30411. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  30412. /**
  30413. * Fired when the main button state has changed
  30414. */
  30415. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30416. /**
  30417. * Fired when the secondary button state has changed
  30418. */
  30419. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30420. /**
  30421. * Fired when the pad state has changed
  30422. */
  30423. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  30424. /**
  30425. * Fired when controllers stick values have changed
  30426. */
  30427. onPadValuesChangedObservable: Observable<StickValues>;
  30428. /**
  30429. * Array of button availible on the controller
  30430. */
  30431. protected _buttons: Array<MutableGamepadButton>;
  30432. private _onButtonStateChange;
  30433. /**
  30434. * Fired when a controller button's state has changed
  30435. * @param callback the callback containing the button that was modified
  30436. */
  30437. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  30438. /**
  30439. * X and Y axis corrisponding to the controllers joystick
  30440. */
  30441. pad: StickValues;
  30442. /**
  30443. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  30444. */
  30445. hand: string;
  30446. /**
  30447. * The default controller model for the controller
  30448. */
  30449. readonly defaultModel: AbstractMesh;
  30450. /**
  30451. * Creates a new WebVRController from a gamepad
  30452. * @param vrGamepad the gamepad that the WebVRController should be created from
  30453. */
  30454. constructor(vrGamepad: any);
  30455. /**
  30456. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  30457. */
  30458. update(): void;
  30459. /**
  30460. * Function to be called when a button is modified
  30461. */
  30462. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30463. /**
  30464. * Loads a mesh and attaches it to the controller
  30465. * @param scene the scene the mesh should be added to
  30466. * @param meshLoaded callback for when the mesh has been loaded
  30467. */
  30468. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30469. private _setButtonValue(newState, currentState, buttonIndex);
  30470. private _changes;
  30471. private _checkChanges(newState, currentState);
  30472. /**
  30473. * Disposes of th webVRCOntroller
  30474. */
  30475. dispose(): void;
  30476. }
  30477. }
  30478. declare module BABYLON {
  30479. /**
  30480. * Defines the WindowsMotionController object that the state of the windows motion controller
  30481. */
  30482. class WindowsMotionController extends WebVRController {
  30483. /**
  30484. * The base url used to load the left and right controller models
  30485. */
  30486. static MODEL_BASE_URL: string;
  30487. /**
  30488. * The name of the left controller model file
  30489. */
  30490. static MODEL_LEFT_FILENAME: string;
  30491. /**
  30492. * The name of the right controller model file
  30493. */
  30494. static MODEL_RIGHT_FILENAME: string;
  30495. /**
  30496. * The controller name prefix for this controller type
  30497. */
  30498. static readonly GAMEPAD_ID_PREFIX: string;
  30499. /**
  30500. * The controller id pattern for this controller type
  30501. */
  30502. private static readonly GAMEPAD_ID_PATTERN;
  30503. private _loadedMeshInfo;
  30504. private readonly _mapping;
  30505. /**
  30506. * Fired when the trackpad on this controller is clicked
  30507. */
  30508. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  30509. /**
  30510. * Fired when the trackpad on this controller is modified
  30511. */
  30512. onTrackpadValuesChangedObservable: Observable<StickValues>;
  30513. /**
  30514. * The current x and y values of this controller's trackpad
  30515. */
  30516. trackpad: StickValues;
  30517. /**
  30518. * Creates a new WindowsMotionController from a gamepad
  30519. * @param vrGamepad the gamepad that the controller should be created from
  30520. */
  30521. constructor(vrGamepad: any);
  30522. /**
  30523. * Fired when the trigger on this controller is modified
  30524. */
  30525. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30526. /**
  30527. * Fired when the menu button on this controller is modified
  30528. */
  30529. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30530. /**
  30531. * Fired when the grip button on this controller is modified
  30532. */
  30533. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30534. /**
  30535. * Fired when the thumbstick button on this controller is modified
  30536. */
  30537. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30538. /**
  30539. * Fired when the touchpad button on this controller is modified
  30540. */
  30541. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30542. /**
  30543. * Fired when the touchpad values on this controller are modified
  30544. */
  30545. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  30546. /**
  30547. * Called once per frame by the engine.
  30548. */
  30549. update(): void;
  30550. /**
  30551. * Called once for each button that changed state since the last frame
  30552. * @param buttonIdx Which button index changed
  30553. * @param state New state of the button
  30554. * @param changes Which properties on the state changed since last frame
  30555. */
  30556. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30557. /**
  30558. * Moves the buttons on the controller mesh based on their current state
  30559. * @param buttonName the name of the button to move
  30560. * @param buttonValue the value of the button which determines the buttons new position
  30561. */
  30562. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  30563. /**
  30564. * Moves the axis on the controller mesh based on its current state
  30565. * @param axis the index of the axis
  30566. * @param axisValue the value of the axis which determines the meshes new position
  30567. * @hidden
  30568. */
  30569. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  30570. /**
  30571. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30572. * @param scene scene in which to add meshes
  30573. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30574. */
  30575. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  30576. /**
  30577. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  30578. * can be transformed by button presses and axes values, based on this._mapping.
  30579. *
  30580. * @param scene scene in which the meshes exist
  30581. * @param meshes list of meshes that make up the controller model to process
  30582. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  30583. */
  30584. private processModel(scene, meshes);
  30585. private createMeshInfo(rootNode);
  30586. /**
  30587. * Gets the ray of the controller in the direction the controller is pointing
  30588. * @param length the length the resulting ray should be
  30589. * @returns a ray in the direction the controller is pointing
  30590. */
  30591. getForwardRay(length?: number): Ray;
  30592. /**
  30593. * Disposes of the controller
  30594. */
  30595. dispose(): void;
  30596. }
  30597. }
  30598. declare module BABYLON {
  30599. }
  30600. declare module BABYLON {
  30601. /**
  30602. * Interface to implement to create a shadow generator compatible with BJS.
  30603. */
  30604. interface IShadowGenerator {
  30605. /**
  30606. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30607. * @returns The render target texture if present otherwise, null
  30608. */
  30609. getShadowMap(): Nullable<RenderTargetTexture>;
  30610. /**
  30611. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30612. * @returns The render target texture if the shadow map is present otherwise, null
  30613. */
  30614. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30615. /**
  30616. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30617. * @param subMesh The submesh we want to render in the shadow map
  30618. * @param useInstances Defines wether will draw in the map using instances
  30619. * @returns true if ready otherwise, false
  30620. */
  30621. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  30622. /**
  30623. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30624. * @param defines Defines of the material we want to update
  30625. * @param lightIndex Index of the light in the enabled light list of the material
  30626. */
  30627. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  30628. /**
  30629. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30630. * defined in the generator but impacting the effect).
  30631. * It implies the unifroms available on the materials are the standard BJS ones.
  30632. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30633. * @param effect The effect we are binfing the information for
  30634. */
  30635. bindShadowLight(lightIndex: string, effect: Effect): void;
  30636. /**
  30637. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30638. * (eq to shadow prjection matrix * light transform matrix)
  30639. * @returns The transform matrix used to create the shadow map
  30640. */
  30641. getTransformMatrix(): Matrix;
  30642. /**
  30643. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30644. * Cube and 2D textures for instance.
  30645. */
  30646. recreateShadowMap(): void;
  30647. /**
  30648. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30649. * @param onCompiled Callback triggered at the and of the effects compilation
  30650. * @param options Sets of optional options forcing the compilation with different modes
  30651. */
  30652. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  30653. useInstances: boolean;
  30654. }>): void;
  30655. /**
  30656. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30657. * @param options Sets of optional options forcing the compilation with different modes
  30658. * @returns A promise that resolves when the compilation completes
  30659. */
  30660. forceCompilationAsync(options?: Partial<{
  30661. useInstances: boolean;
  30662. }>): Promise<void>;
  30663. /**
  30664. * Serializes the shadow generator setup to a json object.
  30665. * @returns The serialized JSON object
  30666. */
  30667. serialize(): any;
  30668. /**
  30669. * Disposes the Shadow map and related Textures and effects.
  30670. */
  30671. dispose(): void;
  30672. }
  30673. /**
  30674. * Default implementation IShadowGenerator.
  30675. * This is the main object responsible of generating shadows in the framework.
  30676. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  30677. */
  30678. class ShadowGenerator implements IShadowGenerator {
  30679. /**
  30680. * Shadow generator mode None: no filtering applied.
  30681. */
  30682. static readonly FILTER_NONE: number;
  30683. /**
  30684. * Shadow generator mode ESM: Exponential Shadow Mapping.
  30685. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30686. */
  30687. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  30688. /**
  30689. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  30690. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  30691. */
  30692. static readonly FILTER_POISSONSAMPLING: number;
  30693. /**
  30694. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  30695. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30696. */
  30697. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  30698. /**
  30699. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  30700. * edge artifacts on steep falloff.
  30701. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30702. */
  30703. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  30704. /**
  30705. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  30706. * edge artifacts on steep falloff.
  30707. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  30708. */
  30709. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  30710. /**
  30711. * Shadow generator mode PCF: Percentage Closer Filtering
  30712. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30713. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  30714. */
  30715. static readonly FILTER_PCF: number;
  30716. /**
  30717. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  30718. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  30719. * Contact Hardening
  30720. */
  30721. static readonly FILTER_PCSS: number;
  30722. /**
  30723. * Reserved for PCF and PCSS
  30724. * Highest Quality.
  30725. *
  30726. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  30727. *
  30728. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  30729. */
  30730. static readonly QUALITY_HIGH: number;
  30731. /**
  30732. * Reserved for PCF and PCSS
  30733. * Good tradeoff for quality/perf cross devices
  30734. *
  30735. * Execute PCF on a 3*3 kernel.
  30736. *
  30737. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  30738. */
  30739. static readonly QUALITY_MEDIUM: number;
  30740. /**
  30741. * Reserved for PCF and PCSS
  30742. * The lowest quality but the fastest.
  30743. *
  30744. * Execute PCF on a 1*1 kernel.
  30745. *
  30746. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  30747. */
  30748. static readonly QUALITY_LOW: number;
  30749. private _bias;
  30750. /**
  30751. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  30752. */
  30753. /**
  30754. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  30755. */
  30756. bias: number;
  30757. private _normalBias;
  30758. /**
  30759. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30760. */
  30761. /**
  30762. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30763. */
  30764. normalBias: number;
  30765. private _blurBoxOffset;
  30766. /**
  30767. * Gets the blur box offset: offset applied during the blur pass.
  30768. * Only usefull if useKernelBlur = false
  30769. */
  30770. /**
  30771. * Sets the blur box offset: offset applied during the blur pass.
  30772. * Only usefull if useKernelBlur = false
  30773. */
  30774. blurBoxOffset: number;
  30775. private _blurScale;
  30776. /**
  30777. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  30778. * 2 means half of the size.
  30779. */
  30780. /**
  30781. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  30782. * 2 means half of the size.
  30783. */
  30784. blurScale: number;
  30785. private _blurKernel;
  30786. /**
  30787. * Gets the blur kernel: kernel size of the blur pass.
  30788. * Only usefull if useKernelBlur = true
  30789. */
  30790. /**
  30791. * Sets the blur kernel: kernel size of the blur pass.
  30792. * Only usefull if useKernelBlur = true
  30793. */
  30794. blurKernel: number;
  30795. private _useKernelBlur;
  30796. /**
  30797. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  30798. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  30799. */
  30800. /**
  30801. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  30802. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  30803. */
  30804. useKernelBlur: boolean;
  30805. private _depthScale;
  30806. /**
  30807. * Gets the depth scale used in ESM mode.
  30808. */
  30809. /**
  30810. * Sets the depth scale used in ESM mode.
  30811. * This can override the scale stored on the light.
  30812. */
  30813. depthScale: number;
  30814. private _filter;
  30815. /**
  30816. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  30817. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30818. */
  30819. /**
  30820. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  30821. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30822. */
  30823. filter: number;
  30824. /**
  30825. * Gets if the current filter is set to Poisson Sampling.
  30826. */
  30827. /**
  30828. * Sets the current filter to Poisson Sampling.
  30829. */
  30830. usePoissonSampling: boolean;
  30831. /**
  30832. * Gets if the current filter is set to VSM.
  30833. * DEPRECATED. Should use useExponentialShadowMap instead.
  30834. */
  30835. /**
  30836. * Sets the current filter is to VSM.
  30837. * DEPRECATED. Should use useExponentialShadowMap instead.
  30838. */
  30839. useVarianceShadowMap: boolean;
  30840. /**
  30841. * Gets if the current filter is set to blurred VSM.
  30842. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  30843. */
  30844. /**
  30845. * Sets the current filter is to blurred VSM.
  30846. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  30847. */
  30848. useBlurVarianceShadowMap: boolean;
  30849. /**
  30850. * Gets if the current filter is set to ESM.
  30851. */
  30852. /**
  30853. * Sets the current filter is to ESM.
  30854. */
  30855. useExponentialShadowMap: boolean;
  30856. /**
  30857. * Gets if the current filter is set to filtered ESM.
  30858. */
  30859. /**
  30860. * Gets if the current filter is set to filtered ESM.
  30861. */
  30862. useBlurExponentialShadowMap: boolean;
  30863. /**
  30864. * Gets if the current filter is set to "close ESM" (using the inverse of the
  30865. * exponential to prevent steep falloff artifacts).
  30866. */
  30867. /**
  30868. * Sets the current filter to "close ESM" (using the inverse of the
  30869. * exponential to prevent steep falloff artifacts).
  30870. */
  30871. useCloseExponentialShadowMap: boolean;
  30872. /**
  30873. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  30874. * exponential to prevent steep falloff artifacts).
  30875. */
  30876. /**
  30877. * Sets the current filter to filtered "close ESM" (using the inverse of the
  30878. * exponential to prevent steep falloff artifacts).
  30879. */
  30880. useBlurCloseExponentialShadowMap: boolean;
  30881. /**
  30882. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  30883. */
  30884. /**
  30885. * Sets the current filter to "PCF" (percentage closer filtering).
  30886. */
  30887. usePercentageCloserFiltering: boolean;
  30888. private _filteringQuality;
  30889. /**
  30890. * Gets the PCF or PCSS Quality.
  30891. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30892. */
  30893. /**
  30894. * Sets the PCF or PCSS Quality.
  30895. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30896. */
  30897. filteringQuality: number;
  30898. /**
  30899. * Gets if the current filter is set to "PCSS" (contact hardening).
  30900. */
  30901. /**
  30902. * Sets the current filter to "PCSS" (contact hardening).
  30903. */
  30904. useContactHardeningShadow: boolean;
  30905. private _contactHardeningLightSizeUVRatio;
  30906. /**
  30907. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30908. * Using a ratio helps keeping shape stability independently of the map size.
  30909. *
  30910. * It does not account for the light projection as it was having too much
  30911. * instability during the light setup or during light position changes.
  30912. *
  30913. * Only valid if useContactHardeningShadow is true.
  30914. */
  30915. /**
  30916. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30917. * Using a ratio helps keeping shape stability independently of the map size.
  30918. *
  30919. * It does not account for the light projection as it was having too much
  30920. * instability during the light setup or during light position changes.
  30921. *
  30922. * Only valid if useContactHardeningShadow is true.
  30923. */
  30924. contactHardeningLightSizeUVRatio: number;
  30925. private _darkness;
  30926. /**
  30927. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  30928. * 0 means strongest and 1 would means no shadow.
  30929. * @returns the darkness.
  30930. */
  30931. getDarkness(): number;
  30932. /**
  30933. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  30934. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  30935. * @returns the shadow generator allowing fluent coding.
  30936. */
  30937. setDarkness(darkness: number): ShadowGenerator;
  30938. private _transparencyShadow;
  30939. /**
  30940. * Sets the ability to have transparent shadow (boolean).
  30941. * @param transparent True if transparent else False
  30942. * @returns the shadow generator allowing fluent coding
  30943. */
  30944. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  30945. private _shadowMap;
  30946. private _shadowMap2;
  30947. /**
  30948. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30949. * @returns The render target texture if present otherwise, null
  30950. */
  30951. getShadowMap(): Nullable<RenderTargetTexture>;
  30952. /**
  30953. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30954. * @returns The render target texture if the shadow map is present otherwise, null
  30955. */
  30956. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30957. /**
  30958. * Helper function to add a mesh and its descendants to the list of shadow casters.
  30959. * @param mesh Mesh to add
  30960. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  30961. * @returns the Shadow Generator itself
  30962. */
  30963. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30964. /**
  30965. * Helper function to remove a mesh and its descendants from the list of shadow casters
  30966. * @param mesh Mesh to remove
  30967. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  30968. * @returns the Shadow Generator itself
  30969. */
  30970. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30971. /**
  30972. * Controls the extent to which the shadows fade out at the edge of the frustum
  30973. * Used only by directionals and spots
  30974. */
  30975. frustumEdgeFalloff: number;
  30976. private _light;
  30977. /**
  30978. * Returns the associated light object.
  30979. * @returns the light generating the shadow
  30980. */
  30981. getLight(): IShadowLight;
  30982. /**
  30983. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  30984. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  30985. * It might on the other hand introduce peter panning.
  30986. */
  30987. forceBackFacesOnly: boolean;
  30988. private _scene;
  30989. private _lightDirection;
  30990. private _effect;
  30991. private _viewMatrix;
  30992. private _projectionMatrix;
  30993. private _transformMatrix;
  30994. private _cachedPosition;
  30995. private _cachedDirection;
  30996. private _cachedDefines;
  30997. private _currentRenderID;
  30998. private _boxBlurPostprocess;
  30999. private _kernelBlurXPostprocess;
  31000. private _kernelBlurYPostprocess;
  31001. private _blurPostProcesses;
  31002. private _mapSize;
  31003. private _currentFaceIndex;
  31004. private _currentFaceIndexCache;
  31005. private _textureType;
  31006. private _defaultTextureMatrix;
  31007. /**
  31008. * Creates a ShadowGenerator object.
  31009. * A ShadowGenerator is the required tool to use the shadows.
  31010. * Each light casting shadows needs to use its own ShadowGenerator.
  31011. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  31012. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  31013. * @param light The light object generating the shadows.
  31014. * @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.
  31015. */
  31016. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  31017. private _initializeGenerator();
  31018. private _initializeShadowMap();
  31019. private _initializeBlurRTTAndPostProcesses();
  31020. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  31021. private _renderSubMeshForShadowMap(subMesh);
  31022. private _applyFilterValues();
  31023. /**
  31024. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31025. * @param onCompiled Callback triggered at the and of the effects compilation
  31026. * @param options Sets of optional options forcing the compilation with different modes
  31027. */
  31028. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  31029. useInstances: boolean;
  31030. }>): void;
  31031. /**
  31032. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31033. * @param options Sets of optional options forcing the compilation with different modes
  31034. * @returns A promise that resolves when the compilation completes
  31035. */
  31036. forceCompilationAsync(options?: Partial<{
  31037. useInstances: boolean;
  31038. }>): Promise<void>;
  31039. /**
  31040. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  31041. * @param subMesh The submesh we want to render in the shadow map
  31042. * @param useInstances Defines wether will draw in the map using instances
  31043. * @returns true if ready otherwise, false
  31044. */
  31045. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  31046. /**
  31047. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  31048. * @param defines Defines of the material we want to update
  31049. * @param lightIndex Index of the light in the enabled light list of the material
  31050. */
  31051. prepareDefines(defines: any, lightIndex: number): void;
  31052. /**
  31053. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  31054. * defined in the generator but impacting the effect).
  31055. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  31056. * @param effect The effect we are binfing the information for
  31057. */
  31058. bindShadowLight(lightIndex: string, effect: Effect): void;
  31059. /**
  31060. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  31061. * (eq to shadow prjection matrix * light transform matrix)
  31062. * @returns The transform matrix used to create the shadow map
  31063. */
  31064. getTransformMatrix(): Matrix;
  31065. /**
  31066. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  31067. * Cube and 2D textures for instance.
  31068. */
  31069. recreateShadowMap(): void;
  31070. private _disposeBlurPostProcesses();
  31071. private _disposeRTTandPostProcesses();
  31072. /**
  31073. * Disposes the ShadowGenerator.
  31074. * Returns nothing.
  31075. */
  31076. dispose(): void;
  31077. /**
  31078. * Serializes the shadow generator setup to a json object.
  31079. * @returns The serialized JSON object
  31080. */
  31081. serialize(): any;
  31082. /**
  31083. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  31084. * @param parsedShadowGenerator The JSON object to parse
  31085. * @param scene The scene to create the shadow map for
  31086. * @returns The parsed shadow generator
  31087. */
  31088. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  31089. }
  31090. }
  31091. declare module BABYLON {
  31092. /**
  31093. * Background material used to create an efficient environement around your scene.
  31094. */
  31095. class BackgroundMaterial extends PushMaterial {
  31096. /**
  31097. * Standard reflectance value at parallel view angle.
  31098. */
  31099. static StandardReflectance0: number;
  31100. /**
  31101. * Standard reflectance value at grazing angle.
  31102. */
  31103. static StandardReflectance90: number;
  31104. protected _primaryColor: Color3;
  31105. /**
  31106. * Key light Color (multiply against the environement texture)
  31107. */
  31108. primaryColor: Color3;
  31109. protected __perceptualColor: Nullable<Color3>;
  31110. /**
  31111. * Experimental Internal Use Only.
  31112. *
  31113. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  31114. * This acts as a helper to set the primary color to a more "human friendly" value.
  31115. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  31116. * output color as close as possible from the chosen value.
  31117. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  31118. * part of lighting setup.)
  31119. */
  31120. _perceptualColor: Nullable<Color3>;
  31121. protected _primaryColorShadowLevel: float;
  31122. /**
  31123. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  31124. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  31125. */
  31126. primaryColorShadowLevel: float;
  31127. protected _primaryColorHighlightLevel: float;
  31128. /**
  31129. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  31130. * The primary color is used at the level chosen to define what the white area would look.
  31131. */
  31132. primaryColorHighlightLevel: float;
  31133. protected _reflectionTexture: Nullable<BaseTexture>;
  31134. /**
  31135. * Reflection Texture used in the material.
  31136. * Should be author in a specific way for the best result (refer to the documentation).
  31137. */
  31138. reflectionTexture: Nullable<BaseTexture>;
  31139. protected _reflectionBlur: float;
  31140. /**
  31141. * Reflection Texture level of blur.
  31142. *
  31143. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  31144. * texture twice.
  31145. */
  31146. reflectionBlur: float;
  31147. protected _diffuseTexture: Nullable<BaseTexture>;
  31148. /**
  31149. * Diffuse Texture used in the material.
  31150. * Should be author in a specific way for the best result (refer to the documentation).
  31151. */
  31152. diffuseTexture: Nullable<BaseTexture>;
  31153. protected _shadowLights: Nullable<IShadowLight[]>;
  31154. /**
  31155. * Specify the list of lights casting shadow on the material.
  31156. * All scene shadow lights will be included if null.
  31157. */
  31158. shadowLights: Nullable<IShadowLight[]>;
  31159. protected _shadowLevel: float;
  31160. /**
  31161. * Helps adjusting the shadow to a softer level if required.
  31162. * 0 means black shadows and 1 means no shadows.
  31163. */
  31164. shadowLevel: float;
  31165. protected _sceneCenter: Vector3;
  31166. /**
  31167. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  31168. * It is usually zero but might be interesting to modify according to your setup.
  31169. */
  31170. sceneCenter: Vector3;
  31171. protected _opacityFresnel: boolean;
  31172. /**
  31173. * This helps specifying that the material is falling off to the sky box at grazing angle.
  31174. * This helps ensuring a nice transition when the camera goes under the ground.
  31175. */
  31176. opacityFresnel: boolean;
  31177. protected _reflectionFresnel: boolean;
  31178. /**
  31179. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  31180. * This helps adding a mirror texture on the ground.
  31181. */
  31182. reflectionFresnel: boolean;
  31183. protected _reflectionFalloffDistance: number;
  31184. /**
  31185. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  31186. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  31187. */
  31188. reflectionFalloffDistance: number;
  31189. protected _reflectionAmount: number;
  31190. /**
  31191. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  31192. */
  31193. reflectionAmount: number;
  31194. protected _reflectionReflectance0: number;
  31195. /**
  31196. * This specifies the weight of the reflection at grazing angle.
  31197. */
  31198. reflectionReflectance0: number;
  31199. protected _reflectionReflectance90: number;
  31200. /**
  31201. * This specifies the weight of the reflection at a perpendicular point of view.
  31202. */
  31203. reflectionReflectance90: number;
  31204. /**
  31205. * Sets the reflection reflectance fresnel values according to the default standard
  31206. * empirically know to work well :-)
  31207. */
  31208. reflectionStandardFresnelWeight: number;
  31209. protected _useRGBColor: boolean;
  31210. /**
  31211. * Helps to directly use the maps channels instead of their level.
  31212. */
  31213. useRGBColor: boolean;
  31214. protected _enableNoise: boolean;
  31215. /**
  31216. * This helps reducing the banding effect that could occur on the background.
  31217. */
  31218. enableNoise: boolean;
  31219. /**
  31220. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  31221. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  31222. * Recommended to be keep at 1.0 except for special cases.
  31223. */
  31224. fovMultiplier: number;
  31225. private _fovMultiplier;
  31226. /**
  31227. * Enable the FOV adjustment feature controlled by fovMultiplier.
  31228. */
  31229. useEquirectangularFOV: boolean;
  31230. private _maxSimultaneousLights;
  31231. /**
  31232. * Number of Simultaneous lights allowed on the material.
  31233. */
  31234. maxSimultaneousLights: int;
  31235. /**
  31236. * Default configuration related to image processing available in the Background Material.
  31237. */
  31238. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31239. /**
  31240. * Keep track of the image processing observer to allow dispose and replace.
  31241. */
  31242. private _imageProcessingObserver;
  31243. /**
  31244. * Attaches a new image processing configuration to the PBR Material.
  31245. * @param configuration (if null the scene configuration will be use)
  31246. */
  31247. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31248. /**
  31249. * Gets the image processing configuration used either in this material.
  31250. */
  31251. /**
  31252. * Sets the Default image processing configuration used either in the this material.
  31253. *
  31254. * If sets to null, the scene one is in use.
  31255. */
  31256. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  31257. /**
  31258. * Gets wether the color curves effect is enabled.
  31259. */
  31260. /**
  31261. * Sets wether the color curves effect is enabled.
  31262. */
  31263. cameraColorCurvesEnabled: boolean;
  31264. /**
  31265. * Gets wether the color grading effect is enabled.
  31266. */
  31267. /**
  31268. * Gets wether the color grading effect is enabled.
  31269. */
  31270. cameraColorGradingEnabled: boolean;
  31271. /**
  31272. * Gets wether tonemapping is enabled or not.
  31273. */
  31274. /**
  31275. * Sets wether tonemapping is enabled or not
  31276. */
  31277. cameraToneMappingEnabled: boolean;
  31278. /**
  31279. * The camera exposure used on this material.
  31280. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31281. * This corresponds to a photographic exposure.
  31282. */
  31283. /**
  31284. * The camera exposure used on this material.
  31285. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31286. * This corresponds to a photographic exposure.
  31287. */
  31288. cameraExposure: float;
  31289. /**
  31290. * Gets The camera contrast used on this material.
  31291. */
  31292. /**
  31293. * Sets The camera contrast used on this material.
  31294. */
  31295. cameraContrast: float;
  31296. /**
  31297. * Gets the Color Grading 2D Lookup Texture.
  31298. */
  31299. /**
  31300. * Sets the Color Grading 2D Lookup Texture.
  31301. */
  31302. cameraColorGradingTexture: Nullable<BaseTexture>;
  31303. /**
  31304. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31305. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31306. * 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;
  31307. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31308. */
  31309. /**
  31310. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31311. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31312. * 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;
  31313. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31314. */
  31315. cameraColorCurves: Nullable<ColorCurves>;
  31316. /**
  31317. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  31318. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  31319. */
  31320. switchToBGR: boolean;
  31321. private _renderTargets;
  31322. private _reflectionControls;
  31323. private _white;
  31324. private _primaryShadowColor;
  31325. private _primaryHighlightColor;
  31326. /**
  31327. * Instantiates a Background Material in the given scene
  31328. * @param name The friendly name of the material
  31329. * @param scene The scene to add the material to
  31330. */
  31331. constructor(name: string, scene: Scene);
  31332. /**
  31333. * The entire material has been created in order to prevent overdraw.
  31334. * @returns false
  31335. */
  31336. needAlphaTesting(): boolean;
  31337. /**
  31338. * The entire material has been created in order to prevent overdraw.
  31339. * @returns true if blending is enable
  31340. */
  31341. needAlphaBlending(): boolean;
  31342. /**
  31343. * Checks wether the material is ready to be rendered for a given mesh.
  31344. * @param mesh The mesh to render
  31345. * @param subMesh The submesh to check against
  31346. * @param useInstances Specify wether or not the material is used with instances
  31347. * @returns true if all the dependencies are ready (Textures, Effects...)
  31348. */
  31349. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31350. /**
  31351. * Compute the primary color according to the chosen perceptual color.
  31352. */
  31353. private _computePrimaryColorFromPerceptualColor();
  31354. /**
  31355. * Compute the highlights and shadow colors according to their chosen levels.
  31356. */
  31357. private _computePrimaryColors();
  31358. /**
  31359. * Build the uniform buffer used in the material.
  31360. */
  31361. buildUniformLayout(): void;
  31362. /**
  31363. * Unbind the material.
  31364. */
  31365. unbind(): void;
  31366. /**
  31367. * Bind only the world matrix to the material.
  31368. * @param world The world matrix to bind.
  31369. */
  31370. bindOnlyWorldMatrix(world: Matrix): void;
  31371. /**
  31372. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  31373. * @param world The world matrix to bind.
  31374. * @param subMesh The submesh to bind for.
  31375. */
  31376. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31377. /**
  31378. * Dispose the material.
  31379. * @param forceDisposeEffect Force disposal of the associated effect.
  31380. * @param forceDisposeTextures Force disposal of the associated textures.
  31381. */
  31382. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31383. /**
  31384. * Clones the material.
  31385. * @param name The cloned name.
  31386. * @returns The cloned material.
  31387. */
  31388. clone(name: string): BackgroundMaterial;
  31389. /**
  31390. * Serializes the current material to its JSON representation.
  31391. * @returns The JSON representation.
  31392. */
  31393. serialize(): any;
  31394. /**
  31395. * Gets the class name of the material
  31396. * @returns "BackgroundMaterial"
  31397. */
  31398. getClassName(): string;
  31399. /**
  31400. * Parse a JSON input to create back a background material.
  31401. * @param source The JSON data to parse
  31402. * @param scene The scene to create the parsed material in
  31403. * @param rootUrl The root url of the assets the material depends upon
  31404. * @returns the instantiated BackgroundMaterial.
  31405. */
  31406. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  31407. }
  31408. }
  31409. declare module BABYLON {
  31410. /**
  31411. * The Physically based material base class of BJS.
  31412. *
  31413. * This offers the main features of a standard PBR material.
  31414. * For more information, please refer to the documentation :
  31415. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  31416. */
  31417. abstract class PBRBaseMaterial extends PushMaterial {
  31418. /**
  31419. * Intensity of the direct lights e.g. the four lights available in your scene.
  31420. * This impacts both the direct diffuse and specular highlights.
  31421. */
  31422. protected _directIntensity: number;
  31423. /**
  31424. * Intensity of the emissive part of the material.
  31425. * This helps controlling the emissive effect without modifying the emissive color.
  31426. */
  31427. protected _emissiveIntensity: number;
  31428. /**
  31429. * Intensity of the environment e.g. how much the environment will light the object
  31430. * either through harmonics for rough material or through the refelction for shiny ones.
  31431. */
  31432. protected _environmentIntensity: number;
  31433. /**
  31434. * This is a special control allowing the reduction of the specular highlights coming from the
  31435. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  31436. */
  31437. protected _specularIntensity: number;
  31438. /**
  31439. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  31440. */
  31441. private _lightingInfos;
  31442. /**
  31443. * Debug Control allowing disabling the bump map on this material.
  31444. */
  31445. protected _disableBumpMap: boolean;
  31446. /**
  31447. * AKA Diffuse Texture in standard nomenclature.
  31448. */
  31449. protected _albedoTexture: BaseTexture;
  31450. /**
  31451. * AKA Occlusion Texture in other nomenclature.
  31452. */
  31453. protected _ambientTexture: BaseTexture;
  31454. /**
  31455. * AKA Occlusion Texture Intensity in other nomenclature.
  31456. */
  31457. protected _ambientTextureStrength: number;
  31458. /**
  31459. * Stores the alpha values in a texture.
  31460. */
  31461. protected _opacityTexture: BaseTexture;
  31462. /**
  31463. * Stores the reflection values in a texture.
  31464. */
  31465. protected _reflectionTexture: BaseTexture;
  31466. /**
  31467. * Stores the refraction values in a texture.
  31468. */
  31469. protected _refractionTexture: BaseTexture;
  31470. /**
  31471. * Stores the emissive values in a texture.
  31472. */
  31473. protected _emissiveTexture: BaseTexture;
  31474. /**
  31475. * AKA Specular texture in other nomenclature.
  31476. */
  31477. protected _reflectivityTexture: BaseTexture;
  31478. /**
  31479. * Used to switch from specular/glossiness to metallic/roughness workflow.
  31480. */
  31481. protected _metallicTexture: BaseTexture;
  31482. /**
  31483. * Specifies the metallic scalar of the metallic/roughness workflow.
  31484. * Can also be used to scale the metalness values of the metallic texture.
  31485. */
  31486. protected _metallic: number;
  31487. /**
  31488. * Specifies the roughness scalar of the metallic/roughness workflow.
  31489. * Can also be used to scale the roughness values of the metallic texture.
  31490. */
  31491. protected _roughness: number;
  31492. /**
  31493. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  31494. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  31495. */
  31496. protected _microSurfaceTexture: BaseTexture;
  31497. /**
  31498. * Stores surface normal data used to displace a mesh in a texture.
  31499. */
  31500. protected _bumpTexture: BaseTexture;
  31501. /**
  31502. * Stores the pre-calculated light information of a mesh in a texture.
  31503. */
  31504. protected _lightmapTexture: BaseTexture;
  31505. /**
  31506. * The color of a material in ambient lighting.
  31507. */
  31508. protected _ambientColor: Color3;
  31509. /**
  31510. * AKA Diffuse Color in other nomenclature.
  31511. */
  31512. protected _albedoColor: Color3;
  31513. /**
  31514. * AKA Specular Color in other nomenclature.
  31515. */
  31516. protected _reflectivityColor: Color3;
  31517. /**
  31518. * The color applied when light is reflected from a material.
  31519. */
  31520. protected _reflectionColor: Color3;
  31521. /**
  31522. * The color applied when light is emitted from a material.
  31523. */
  31524. protected _emissiveColor: Color3;
  31525. /**
  31526. * AKA Glossiness in other nomenclature.
  31527. */
  31528. protected _microSurface: number;
  31529. /**
  31530. * source material index of refraction (IOR)' / 'destination material IOR.
  31531. */
  31532. protected _indexOfRefraction: number;
  31533. /**
  31534. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  31535. */
  31536. protected _invertRefractionY: boolean;
  31537. /**
  31538. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  31539. * Materials half opaque for instance using refraction could benefit from this control.
  31540. */
  31541. protected _linkRefractionWithTransparency: boolean;
  31542. /**
  31543. * Specifies that the material will use the light map as a show map.
  31544. */
  31545. protected _useLightmapAsShadowmap: boolean;
  31546. /**
  31547. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  31548. * makes the reflect vector face the model (under horizon).
  31549. */
  31550. protected _useHorizonOcclusion: boolean;
  31551. /**
  31552. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  31553. * too much the area relying on ambient texture to define their ambient occlusion.
  31554. */
  31555. protected _useRadianceOcclusion: boolean;
  31556. /**
  31557. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  31558. */
  31559. protected _useAlphaFromAlbedoTexture: boolean;
  31560. /**
  31561. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  31562. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31563. */
  31564. protected _useSpecularOverAlpha: boolean;
  31565. /**
  31566. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  31567. */
  31568. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  31569. /**
  31570. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  31571. */
  31572. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  31573. /**
  31574. * Specifies if the metallic texture contains the roughness information in its green channel.
  31575. */
  31576. protected _useRoughnessFromMetallicTextureGreen: boolean;
  31577. /**
  31578. * Specifies if the metallic texture contains the metallness information in its blue channel.
  31579. */
  31580. protected _useMetallnessFromMetallicTextureBlue: boolean;
  31581. /**
  31582. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  31583. */
  31584. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  31585. /**
  31586. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  31587. */
  31588. protected _useAmbientInGrayScale: boolean;
  31589. /**
  31590. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  31591. * The material will try to infer what glossiness each pixel should be.
  31592. */
  31593. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  31594. /**
  31595. * BJS is using an harcoded light falloff based on a manually sets up range.
  31596. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  31597. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  31598. */
  31599. protected _usePhysicalLightFalloff: boolean;
  31600. /**
  31601. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31602. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31603. */
  31604. protected _useRadianceOverAlpha: boolean;
  31605. /**
  31606. * Allows using an object space normal map (instead of tangent space).
  31607. */
  31608. protected _useObjectSpaceNormalMap: boolean;
  31609. /**
  31610. * Allows using the bump map in parallax mode.
  31611. */
  31612. protected _useParallax: boolean;
  31613. /**
  31614. * Allows using the bump map in parallax occlusion mode.
  31615. */
  31616. protected _useParallaxOcclusion: boolean;
  31617. /**
  31618. * Controls the scale bias of the parallax mode.
  31619. */
  31620. protected _parallaxScaleBias: number;
  31621. /**
  31622. * If sets to true, disables all the lights affecting the material.
  31623. */
  31624. protected _disableLighting: boolean;
  31625. /**
  31626. * Number of Simultaneous lights allowed on the material.
  31627. */
  31628. protected _maxSimultaneousLights: number;
  31629. /**
  31630. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  31631. */
  31632. protected _invertNormalMapX: boolean;
  31633. /**
  31634. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  31635. */
  31636. protected _invertNormalMapY: boolean;
  31637. /**
  31638. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31639. */
  31640. protected _twoSidedLighting: boolean;
  31641. /**
  31642. * Defines the alpha limits in alpha test mode.
  31643. */
  31644. protected _alphaCutOff: number;
  31645. /**
  31646. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  31647. */
  31648. protected _forceAlphaTest: boolean;
  31649. /**
  31650. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  31651. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  31652. */
  31653. protected _useAlphaFresnel: boolean;
  31654. /**
  31655. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  31656. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  31657. */
  31658. protected _useLinearAlphaFresnel: boolean;
  31659. /**
  31660. * The transparency mode of the material.
  31661. */
  31662. protected _transparencyMode: Nullable<number>;
  31663. /**
  31664. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  31665. * from cos thetav and roughness:
  31666. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  31667. */
  31668. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  31669. /**
  31670. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  31671. */
  31672. protected _forceIrradianceInFragment: boolean;
  31673. /**
  31674. * Force normal to face away from face.
  31675. */
  31676. protected _forceNormalForward: boolean;
  31677. /**
  31678. * Enables specular anti aliasing in the PBR shader.
  31679. * It will both interacts on the Geometry for analytical and IBL lighting.
  31680. * It also prefilter the roughness map based on the bump values.
  31681. */
  31682. protected _enableSpecularAntiAliasing: boolean;
  31683. /**
  31684. * Default configuration related to image processing available in the PBR Material.
  31685. */
  31686. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31687. /**
  31688. * Keep track of the image processing observer to allow dispose and replace.
  31689. */
  31690. private _imageProcessingObserver;
  31691. /**
  31692. * Attaches a new image processing configuration to the PBR Material.
  31693. * @param configuration
  31694. */
  31695. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31696. /**
  31697. * Stores the available render targets.
  31698. */
  31699. private _renderTargets;
  31700. /**
  31701. * Sets the global ambient color for the material used in lighting calculations.
  31702. */
  31703. private _globalAmbientColor;
  31704. /**
  31705. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  31706. */
  31707. private _useLogarithmicDepth;
  31708. /**
  31709. * If set to true, no lighting calculations will be applied.
  31710. */
  31711. private _unlit;
  31712. /**
  31713. * Instantiates a new PBRMaterial instance.
  31714. *
  31715. * @param name The material name
  31716. * @param scene The scene the material will be use in.
  31717. */
  31718. constructor(name: string, scene: Scene);
  31719. /**
  31720. * Gets the name of the material class.
  31721. */
  31722. getClassName(): string;
  31723. /**
  31724. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  31725. */
  31726. /**
  31727. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  31728. */
  31729. useLogarithmicDepth: boolean;
  31730. /**
  31731. * Gets the current transparency mode.
  31732. */
  31733. /**
  31734. * Sets the transparency mode of the material.
  31735. */
  31736. transparencyMode: Nullable<number>;
  31737. /**
  31738. * Returns true if alpha blending should be disabled.
  31739. */
  31740. private readonly _disableAlphaBlending;
  31741. /**
  31742. * Specifies whether or not this material should be rendered in alpha blend mode.
  31743. */
  31744. needAlphaBlending(): boolean;
  31745. /**
  31746. * Specifies if the mesh will require alpha blending.
  31747. * @param mesh - BJS mesh.
  31748. */
  31749. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  31750. /**
  31751. * Specifies whether or not this material should be rendered in alpha test mode.
  31752. */
  31753. needAlphaTesting(): boolean;
  31754. /**
  31755. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  31756. */
  31757. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  31758. /**
  31759. * Gets the texture used for the alpha test.
  31760. */
  31761. getAlphaTestTexture(): BaseTexture;
  31762. /**
  31763. * Stores the reflectivity values based on metallic roughness workflow.
  31764. */
  31765. private static _scaledReflectivity;
  31766. /**
  31767. * Specifies that the submesh is ready to be used.
  31768. * @param mesh - BJS mesh.
  31769. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  31770. * @param useInstances - Specifies that instances should be used.
  31771. * @returns - boolean indicating that the submesh is ready or not.
  31772. */
  31773. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31774. /**
  31775. * Specifies if the material uses metallic roughness workflow.
  31776. * @returns boolean specifiying if the material uses metallic roughness workflow.
  31777. */
  31778. isMetallicWorkflow(): boolean;
  31779. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  31780. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  31781. /**
  31782. * Force shader compilation
  31783. */
  31784. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  31785. clipPlane: boolean;
  31786. }>): void;
  31787. /**
  31788. * Initializes the uniform buffer layout for the shader.
  31789. */
  31790. buildUniformLayout(): void;
  31791. /**
  31792. * Unbinds the textures.
  31793. */
  31794. unbind(): void;
  31795. /**
  31796. * Binds the submesh data.
  31797. * @param world - The world matrix.
  31798. * @param mesh - The BJS mesh.
  31799. * @param subMesh - A submesh of the BJS mesh.
  31800. */
  31801. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31802. /**
  31803. * Returns the animatable textures.
  31804. * @returns - Array of animatable textures.
  31805. */
  31806. getAnimatables(): IAnimatable[];
  31807. /**
  31808. * Returns the texture used for reflections.
  31809. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  31810. */
  31811. private _getReflectionTexture();
  31812. /**
  31813. * Returns the texture used for refraction or null if none is used.
  31814. * @returns - Refection texture if present. If no refraction texture and refraction
  31815. * is linked with transparency, returns environment texture. Otherwise, returns null.
  31816. */
  31817. private _getRefractionTexture();
  31818. /**
  31819. * Disposes the resources of the material.
  31820. * @param forceDisposeEffect - Forces the disposal of effects.
  31821. * @param forceDisposeTextures - Forces the disposal of all textures.
  31822. */
  31823. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31824. }
  31825. }
  31826. declare module BABYLON {
  31827. /**
  31828. * The Physically based simple base material of BJS.
  31829. *
  31830. * This enables better naming and convention enforcements on top of the pbrMaterial.
  31831. * It is used as the base class for both the specGloss and metalRough conventions.
  31832. */
  31833. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  31834. /**
  31835. * Number of Simultaneous lights allowed on the material.
  31836. */
  31837. maxSimultaneousLights: number;
  31838. /**
  31839. * If sets to true, disables all the lights affecting the material.
  31840. */
  31841. disableLighting: boolean;
  31842. /**
  31843. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  31844. */
  31845. environmentTexture: BaseTexture;
  31846. /**
  31847. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31848. */
  31849. invertNormalMapX: boolean;
  31850. /**
  31851. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31852. */
  31853. invertNormalMapY: boolean;
  31854. /**
  31855. * Normal map used in the model.
  31856. */
  31857. normalTexture: BaseTexture;
  31858. /**
  31859. * Emissivie color used to self-illuminate the model.
  31860. */
  31861. emissiveColor: Color3;
  31862. /**
  31863. * Emissivie texture used to self-illuminate the model.
  31864. */
  31865. emissiveTexture: BaseTexture;
  31866. /**
  31867. * Occlusion Channel Strenght.
  31868. */
  31869. occlusionStrength: number;
  31870. /**
  31871. * Occlusion Texture of the material (adding extra occlusion effects).
  31872. */
  31873. occlusionTexture: BaseTexture;
  31874. /**
  31875. * Defines the alpha limits in alpha test mode.
  31876. */
  31877. alphaCutOff: number;
  31878. /**
  31879. * Gets the current double sided mode.
  31880. */
  31881. /**
  31882. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31883. */
  31884. doubleSided: boolean;
  31885. lightmapTexture: BaseTexture;
  31886. useLightmapAsShadowmap: boolean;
  31887. /**
  31888. * Return the active textures of the material.
  31889. */
  31890. getActiveTextures(): BaseTexture[];
  31891. hasTexture(texture: BaseTexture): boolean;
  31892. /**
  31893. * Instantiates a new PBRMaterial instance.
  31894. *
  31895. * @param name The material name
  31896. * @param scene The scene the material will be use in.
  31897. */
  31898. constructor(name: string, scene: Scene);
  31899. getClassName(): string;
  31900. }
  31901. }
  31902. declare module BABYLON {
  31903. /**
  31904. * The Physically based material of BJS.
  31905. *
  31906. * This offers the main features of a standard PBR material.
  31907. * For more information, please refer to the documentation :
  31908. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  31909. */
  31910. class PBRMaterial extends PBRBaseMaterial {
  31911. private static _PBRMATERIAL_OPAQUE;
  31912. /**
  31913. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  31914. */
  31915. static readonly PBRMATERIAL_OPAQUE: number;
  31916. /**
  31917. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  31918. */
  31919. private static _PBRMATERIAL_ALPHATEST;
  31920. /**
  31921. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  31922. */
  31923. static readonly PBRMATERIAL_ALPHATEST: number;
  31924. /**
  31925. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31926. */
  31927. private static _PBRMATERIAL_ALPHABLEND;
  31928. /**
  31929. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31930. */
  31931. static readonly PBRMATERIAL_ALPHABLEND: number;
  31932. /**
  31933. * 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.
  31934. * They are also discarded below the alpha cutoff threshold to improve performances.
  31935. */
  31936. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  31937. /**
  31938. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  31939. * They are also discarded below the alpha cutoff threshold to improve performances.
  31940. */
  31941. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  31942. /**
  31943. * Intensity of the direct lights e.g. the four lights available in your scene.
  31944. * This impacts both the direct diffuse and specular highlights.
  31945. */
  31946. directIntensity: number;
  31947. /**
  31948. * Intensity of the emissive part of the material.
  31949. * This helps controlling the emissive effect without modifying the emissive color.
  31950. */
  31951. emissiveIntensity: number;
  31952. /**
  31953. * Intensity of the environment e.g. how much the environment will light the object
  31954. * either through harmonics for rough material or through the refelction for shiny ones.
  31955. */
  31956. environmentIntensity: number;
  31957. /**
  31958. * This is a special control allowing the reduction of the specular highlights coming from the
  31959. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  31960. */
  31961. specularIntensity: number;
  31962. /**
  31963. * Debug Control allowing disabling the bump map on this material.
  31964. */
  31965. disableBumpMap: boolean;
  31966. /**
  31967. * AKA Diffuse Texture in standard nomenclature.
  31968. */
  31969. albedoTexture: BaseTexture;
  31970. /**
  31971. * AKA Occlusion Texture in other nomenclature.
  31972. */
  31973. ambientTexture: BaseTexture;
  31974. /**
  31975. * AKA Occlusion Texture Intensity in other nomenclature.
  31976. */
  31977. ambientTextureStrength: number;
  31978. /**
  31979. * Stores the alpha values in a texture.
  31980. */
  31981. opacityTexture: BaseTexture;
  31982. /**
  31983. * Stores the reflection values in a texture.
  31984. */
  31985. reflectionTexture: Nullable<BaseTexture>;
  31986. /**
  31987. * Stores the emissive values in a texture.
  31988. */
  31989. emissiveTexture: BaseTexture;
  31990. /**
  31991. * AKA Specular texture in other nomenclature.
  31992. */
  31993. reflectivityTexture: BaseTexture;
  31994. /**
  31995. * Used to switch from specular/glossiness to metallic/roughness workflow.
  31996. */
  31997. metallicTexture: BaseTexture;
  31998. /**
  31999. * Specifies the metallic scalar of the metallic/roughness workflow.
  32000. * Can also be used to scale the metalness values of the metallic texture.
  32001. */
  32002. metallic: number;
  32003. /**
  32004. * Specifies the roughness scalar of the metallic/roughness workflow.
  32005. * Can also be used to scale the roughness values of the metallic texture.
  32006. */
  32007. roughness: number;
  32008. /**
  32009. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  32010. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  32011. */
  32012. microSurfaceTexture: BaseTexture;
  32013. /**
  32014. * Stores surface normal data used to displace a mesh in a texture.
  32015. */
  32016. bumpTexture: BaseTexture;
  32017. /**
  32018. * Stores the pre-calculated light information of a mesh in a texture.
  32019. */
  32020. lightmapTexture: BaseTexture;
  32021. /**
  32022. * Stores the refracted light information in a texture.
  32023. */
  32024. refractionTexture: BaseTexture;
  32025. /**
  32026. * The color of a material in ambient lighting.
  32027. */
  32028. ambientColor: Color3;
  32029. /**
  32030. * AKA Diffuse Color in other nomenclature.
  32031. */
  32032. albedoColor: Color3;
  32033. /**
  32034. * AKA Specular Color in other nomenclature.
  32035. */
  32036. reflectivityColor: Color3;
  32037. /**
  32038. * The color reflected from the material.
  32039. */
  32040. reflectionColor: Color3;
  32041. /**
  32042. * The color emitted from the material.
  32043. */
  32044. emissiveColor: Color3;
  32045. /**
  32046. * AKA Glossiness in other nomenclature.
  32047. */
  32048. microSurface: number;
  32049. /**
  32050. * source material index of refraction (IOR)' / 'destination material IOR.
  32051. */
  32052. indexOfRefraction: number;
  32053. /**
  32054. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  32055. */
  32056. invertRefractionY: boolean;
  32057. /**
  32058. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  32059. * Materials half opaque for instance using refraction could benefit from this control.
  32060. */
  32061. linkRefractionWithTransparency: boolean;
  32062. useLightmapAsShadowmap: boolean;
  32063. /**
  32064. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  32065. */
  32066. useAlphaFromAlbedoTexture: boolean;
  32067. /**
  32068. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  32069. */
  32070. forceAlphaTest: boolean;
  32071. /**
  32072. * Defines the alpha limits in alpha test mode.
  32073. */
  32074. alphaCutOff: number;
  32075. /**
  32076. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  32077. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  32078. */
  32079. useSpecularOverAlpha: boolean;
  32080. /**
  32081. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  32082. */
  32083. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  32084. /**
  32085. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  32086. */
  32087. useRoughnessFromMetallicTextureAlpha: boolean;
  32088. /**
  32089. * Specifies if the metallic texture contains the roughness information in its green channel.
  32090. */
  32091. useRoughnessFromMetallicTextureGreen: boolean;
  32092. /**
  32093. * Specifies if the metallic texture contains the metallness information in its blue channel.
  32094. */
  32095. useMetallnessFromMetallicTextureBlue: boolean;
  32096. /**
  32097. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  32098. */
  32099. useAmbientOcclusionFromMetallicTextureRed: boolean;
  32100. /**
  32101. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  32102. */
  32103. useAmbientInGrayScale: boolean;
  32104. /**
  32105. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  32106. * The material will try to infer what glossiness each pixel should be.
  32107. */
  32108. useAutoMicroSurfaceFromReflectivityMap: boolean;
  32109. /**
  32110. * BJS is using an harcoded light falloff based on a manually sets up range.
  32111. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  32112. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  32113. */
  32114. usePhysicalLightFalloff: boolean;
  32115. /**
  32116. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  32117. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  32118. */
  32119. useRadianceOverAlpha: boolean;
  32120. /**
  32121. * Allows using an object space normal map (instead of tangent space).
  32122. */
  32123. useObjectSpaceNormalMap: boolean;
  32124. /**
  32125. * Allows using the bump map in parallax mode.
  32126. */
  32127. useParallax: boolean;
  32128. /**
  32129. * Allows using the bump map in parallax occlusion mode.
  32130. */
  32131. useParallaxOcclusion: boolean;
  32132. /**
  32133. * Controls the scale bias of the parallax mode.
  32134. */
  32135. parallaxScaleBias: number;
  32136. /**
  32137. * If sets to true, disables all the lights affecting the material.
  32138. */
  32139. disableLighting: boolean;
  32140. /**
  32141. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  32142. */
  32143. forceIrradianceInFragment: boolean;
  32144. /**
  32145. * Number of Simultaneous lights allowed on the material.
  32146. */
  32147. maxSimultaneousLights: number;
  32148. /**
  32149. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32150. */
  32151. invertNormalMapX: boolean;
  32152. /**
  32153. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32154. */
  32155. invertNormalMapY: boolean;
  32156. /**
  32157. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32158. */
  32159. twoSidedLighting: boolean;
  32160. /**
  32161. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32162. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  32163. */
  32164. useAlphaFresnel: boolean;
  32165. /**
  32166. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32167. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  32168. */
  32169. useLinearAlphaFresnel: boolean;
  32170. /**
  32171. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32172. * And/Or occlude the blended part.
  32173. */
  32174. environmentBRDFTexture: Nullable<BaseTexture>;
  32175. /**
  32176. * Force normal to face away from face.
  32177. */
  32178. forceNormalForward: boolean;
  32179. /**
  32180. * Enables specular anti aliasing in the PBR shader.
  32181. * It will both interacts on the Geometry for analytical and IBL lighting.
  32182. * It also prefilter the roughness map based on the bump values.
  32183. */
  32184. enableSpecularAntiAliasing: boolean;
  32185. /**
  32186. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  32187. * makes the reflect vector face the model (under horizon).
  32188. */
  32189. useHorizonOcclusion: boolean;
  32190. /**
  32191. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  32192. * too much the area relying on ambient texture to define their ambient occlusion.
  32193. */
  32194. useRadianceOcclusion: boolean;
  32195. /**
  32196. * If set to true, no lighting calculations will be applied.
  32197. */
  32198. unlit: boolean;
  32199. /**
  32200. * Gets the image processing configuration used either in this material.
  32201. */
  32202. /**
  32203. * Sets the Default image processing configuration used either in the this material.
  32204. *
  32205. * If sets to null, the scene one is in use.
  32206. */
  32207. imageProcessingConfiguration: ImageProcessingConfiguration;
  32208. /**
  32209. * Gets wether the color curves effect is enabled.
  32210. */
  32211. /**
  32212. * Sets wether the color curves effect is enabled.
  32213. */
  32214. cameraColorCurvesEnabled: boolean;
  32215. /**
  32216. * Gets wether the color grading effect is enabled.
  32217. */
  32218. /**
  32219. * Gets wether the color grading effect is enabled.
  32220. */
  32221. cameraColorGradingEnabled: boolean;
  32222. /**
  32223. * Gets wether tonemapping is enabled or not.
  32224. */
  32225. /**
  32226. * Sets wether tonemapping is enabled or not
  32227. */
  32228. cameraToneMappingEnabled: boolean;
  32229. /**
  32230. * The camera exposure used on this material.
  32231. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32232. * This corresponds to a photographic exposure.
  32233. */
  32234. /**
  32235. * The camera exposure used on this material.
  32236. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32237. * This corresponds to a photographic exposure.
  32238. */
  32239. cameraExposure: number;
  32240. /**
  32241. * Gets The camera contrast used on this material.
  32242. */
  32243. /**
  32244. * Sets The camera contrast used on this material.
  32245. */
  32246. cameraContrast: number;
  32247. /**
  32248. * Gets the Color Grading 2D Lookup Texture.
  32249. */
  32250. /**
  32251. * Sets the Color Grading 2D Lookup Texture.
  32252. */
  32253. cameraColorGradingTexture: Nullable<BaseTexture>;
  32254. /**
  32255. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32256. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32257. * 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;
  32258. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32259. */
  32260. /**
  32261. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32262. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32263. * 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;
  32264. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32265. */
  32266. cameraColorCurves: Nullable<ColorCurves>;
  32267. /**
  32268. * Instantiates a new PBRMaterial instance.
  32269. *
  32270. * @param name The material name
  32271. * @param scene The scene the material will be use in.
  32272. */
  32273. constructor(name: string, scene: Scene);
  32274. /**
  32275. * Returns the name of this material class.
  32276. */
  32277. getClassName(): string;
  32278. /**
  32279. * Returns an array of the actively used textures.
  32280. * @returns - Array of BaseTextures
  32281. */
  32282. getActiveTextures(): BaseTexture[];
  32283. /**
  32284. * Checks to see if a texture is used in the material.
  32285. * @param texture - Base texture to use.
  32286. * @returns - Boolean specifying if a texture is used in the material.
  32287. */
  32288. hasTexture(texture: BaseTexture): boolean;
  32289. /**
  32290. * Makes a duplicate of the current material.
  32291. * @param name - name to use for the new material.
  32292. */
  32293. clone(name: string): PBRMaterial;
  32294. /**
  32295. * Serializes this PBR Material.
  32296. * @returns - An object with the serialized material.
  32297. */
  32298. serialize(): any;
  32299. /**
  32300. * Parses a PBR Material from a serialized object.
  32301. * @param source - Serialized object.
  32302. * @param scene - BJS scene instance.
  32303. * @param rootUrl - url for the scene object
  32304. * @returns - PBRMaterial
  32305. */
  32306. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  32307. }
  32308. }
  32309. declare module BABYLON {
  32310. /**
  32311. * The PBR material of BJS following the metal roughness convention.
  32312. *
  32313. * This fits to the PBR convention in the GLTF definition:
  32314. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  32315. */
  32316. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  32317. /**
  32318. * The base color has two different interpretations depending on the value of metalness.
  32319. * When the material is a metal, the base color is the specific measured reflectance value
  32320. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  32321. * of the material.
  32322. */
  32323. baseColor: Color3;
  32324. /**
  32325. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  32326. * well as opacity information in the alpha channel.
  32327. */
  32328. baseTexture: BaseTexture;
  32329. /**
  32330. * Specifies the metallic scalar value of the material.
  32331. * Can also be used to scale the metalness values of the metallic texture.
  32332. */
  32333. metallic: number;
  32334. /**
  32335. * Specifies the roughness scalar value of the material.
  32336. * Can also be used to scale the roughness values of the metallic texture.
  32337. */
  32338. roughness: number;
  32339. /**
  32340. * Texture containing both the metallic value in the B channel and the
  32341. * roughness value in the G channel to keep better precision.
  32342. */
  32343. metallicRoughnessTexture: BaseTexture;
  32344. /**
  32345. * Instantiates a new PBRMetalRoughnessMaterial instance.
  32346. *
  32347. * @param name The material name
  32348. * @param scene The scene the material will be use in.
  32349. */
  32350. constructor(name: string, scene: Scene);
  32351. /**
  32352. * Return the currrent class name of the material.
  32353. */
  32354. getClassName(): string;
  32355. /**
  32356. * Return the active textures of the material.
  32357. */
  32358. getActiveTextures(): BaseTexture[];
  32359. /**
  32360. * Checks to see if a texture is used in the material.
  32361. * @param texture - Base texture to use.
  32362. * @returns - Boolean specifying if a texture is used in the material.
  32363. */
  32364. hasTexture(texture: BaseTexture): boolean;
  32365. /**
  32366. * Makes a duplicate of the current material.
  32367. * @param name - name to use for the new material.
  32368. */
  32369. clone(name: string): PBRMetallicRoughnessMaterial;
  32370. /**
  32371. * Serialize the material to a parsable JSON object.
  32372. */
  32373. serialize(): any;
  32374. /**
  32375. * Parses a JSON object correponding to the serialize function.
  32376. */
  32377. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  32378. }
  32379. }
  32380. declare module BABYLON {
  32381. /**
  32382. * The PBR material of BJS following the specular glossiness convention.
  32383. *
  32384. * This fits to the PBR convention in the GLTF definition:
  32385. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  32386. */
  32387. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  32388. /**
  32389. * Specifies the diffuse color of the material.
  32390. */
  32391. diffuseColor: Color3;
  32392. /**
  32393. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  32394. * channel.
  32395. */
  32396. diffuseTexture: BaseTexture;
  32397. /**
  32398. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  32399. */
  32400. specularColor: Color3;
  32401. /**
  32402. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  32403. */
  32404. glossiness: number;
  32405. /**
  32406. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  32407. */
  32408. specularGlossinessTexture: BaseTexture;
  32409. /**
  32410. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  32411. *
  32412. * @param name The material name
  32413. * @param scene The scene the material will be use in.
  32414. */
  32415. constructor(name: string, scene: Scene);
  32416. /**
  32417. * Return the currrent class name of the material.
  32418. */
  32419. getClassName(): string;
  32420. /**
  32421. * Return the active textures of the material.
  32422. */
  32423. getActiveTextures(): BaseTexture[];
  32424. /**
  32425. * Checks to see if a texture is used in the material.
  32426. * @param texture - Base texture to use.
  32427. * @returns - Boolean specifying if a texture is used in the material.
  32428. */
  32429. hasTexture(texture: BaseTexture): boolean;
  32430. /**
  32431. * Makes a duplicate of the current material.
  32432. * @param name - name to use for the new material.
  32433. */
  32434. clone(name: string): PBRSpecularGlossinessMaterial;
  32435. /**
  32436. * Serialize the material to a parsable JSON object.
  32437. */
  32438. serialize(): any;
  32439. /**
  32440. * Parses a JSON object correponding to the serialize function.
  32441. */
  32442. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  32443. }
  32444. }
  32445. declare module BABYLON {
  32446. class BaseTexture {
  32447. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32448. name: string;
  32449. private _hasAlpha;
  32450. hasAlpha: boolean;
  32451. getAlphaFromRGB: boolean;
  32452. level: number;
  32453. coordinatesIndex: number;
  32454. private _coordinatesMode;
  32455. /**
  32456. * How a texture is mapped.
  32457. *
  32458. * | Value | Type | Description |
  32459. * | ----- | ----------------------------------- | ----------- |
  32460. * | 0 | EXPLICIT_MODE | |
  32461. * | 1 | SPHERICAL_MODE | |
  32462. * | 2 | PLANAR_MODE | |
  32463. * | 3 | CUBIC_MODE | |
  32464. * | 4 | PROJECTION_MODE | |
  32465. * | 5 | SKYBOX_MODE | |
  32466. * | 6 | INVCUBIC_MODE | |
  32467. * | 7 | EQUIRECTANGULAR_MODE | |
  32468. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32469. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32470. */
  32471. coordinatesMode: number;
  32472. /**
  32473. * | Value | Type | Description |
  32474. * | ----- | ------------------ | ----------- |
  32475. * | 0 | CLAMP_ADDRESSMODE | |
  32476. * | 1 | WRAP_ADDRESSMODE | |
  32477. * | 2 | MIRROR_ADDRESSMODE | |
  32478. */
  32479. wrapU: number;
  32480. /**
  32481. * | Value | Type | Description |
  32482. * | ----- | ------------------ | ----------- |
  32483. * | 0 | CLAMP_ADDRESSMODE | |
  32484. * | 1 | WRAP_ADDRESSMODE | |
  32485. * | 2 | MIRROR_ADDRESSMODE | |
  32486. */
  32487. wrapV: number;
  32488. /**
  32489. * | Value | Type | Description |
  32490. * | ----- | ------------------ | ----------- |
  32491. * | 0 | CLAMP_ADDRESSMODE | |
  32492. * | 1 | WRAP_ADDRESSMODE | |
  32493. * | 2 | MIRROR_ADDRESSMODE | |
  32494. */
  32495. wrapR: number;
  32496. anisotropicFilteringLevel: number;
  32497. isCube: boolean;
  32498. is3D: boolean;
  32499. gammaSpace: boolean;
  32500. invertZ: boolean;
  32501. lodLevelInAlpha: boolean;
  32502. lodGenerationOffset: number;
  32503. lodGenerationScale: number;
  32504. isRenderTarget: boolean;
  32505. readonly uid: string;
  32506. toString(): string;
  32507. getClassName(): string;
  32508. animations: Animation[];
  32509. /**
  32510. * An event triggered when the texture is disposed.
  32511. */
  32512. onDisposeObservable: Observable<BaseTexture>;
  32513. private _onDisposeObserver;
  32514. onDispose: () => void;
  32515. delayLoadState: number;
  32516. private _scene;
  32517. _texture: Nullable<InternalTexture>;
  32518. private _uid;
  32519. readonly isBlocking: boolean;
  32520. constructor(scene: Nullable<Scene>);
  32521. getScene(): Nullable<Scene>;
  32522. getTextureMatrix(): Matrix;
  32523. getReflectionTextureMatrix(): Matrix;
  32524. getInternalTexture(): Nullable<InternalTexture>;
  32525. isReadyOrNotBlocking(): boolean;
  32526. isReady(): boolean;
  32527. getSize(): ISize;
  32528. getBaseSize(): ISize;
  32529. scale(ratio: number): void;
  32530. readonly canRescale: boolean;
  32531. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  32532. _rebuild(): void;
  32533. delayLoad(): void;
  32534. clone(): Nullable<BaseTexture>;
  32535. readonly textureType: number;
  32536. readonly textureFormat: number;
  32537. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  32538. releaseInternalTexture(): void;
  32539. sphericalPolynomial: Nullable<SphericalPolynomial>;
  32540. readonly _lodTextureHigh: Nullable<BaseTexture>;
  32541. readonly _lodTextureMid: Nullable<BaseTexture>;
  32542. readonly _lodTextureLow: Nullable<BaseTexture>;
  32543. dispose(): void;
  32544. serialize(): any;
  32545. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  32546. }
  32547. }
  32548. declare module BABYLON {
  32549. /**
  32550. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  32551. * It can help converting any input color in a desired output one. This can then be used to create effects
  32552. * from sepia, black and white to sixties or futuristic rendering...
  32553. *
  32554. * The only supported format is currently 3dl.
  32555. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  32556. */
  32557. class ColorGradingTexture extends BaseTexture {
  32558. /**
  32559. * The current texture matrix. (will always be identity in color grading texture)
  32560. */
  32561. private _textureMatrix;
  32562. /**
  32563. * The texture URL.
  32564. */
  32565. url: string;
  32566. /**
  32567. * Empty line regex stored for GC.
  32568. */
  32569. private static _noneEmptyLineRegex;
  32570. private _engine;
  32571. /**
  32572. * Instantiates a ColorGradingTexture from the following parameters.
  32573. *
  32574. * @param url The location of the color gradind data (currently only supporting 3dl)
  32575. * @param scene The scene the texture will be used in
  32576. */
  32577. constructor(url: string, scene: Scene);
  32578. /**
  32579. * Returns the texture matrix used in most of the material.
  32580. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  32581. */
  32582. getTextureMatrix(): Matrix;
  32583. /**
  32584. * Occurs when the file being loaded is a .3dl LUT file.
  32585. */
  32586. private load3dlTexture();
  32587. /**
  32588. * Starts the loading process of the texture.
  32589. */
  32590. private loadTexture();
  32591. /**
  32592. * Clones the color gradind texture.
  32593. */
  32594. clone(): ColorGradingTexture;
  32595. /**
  32596. * Called during delayed load for textures.
  32597. */
  32598. delayLoad(): void;
  32599. /**
  32600. * Parses a color grading texture serialized by Babylon.
  32601. * @param parsedTexture The texture information being parsedTexture
  32602. * @param scene The scene to load the texture in
  32603. * @param rootUrl The root url of the data assets to load
  32604. * @return A color gradind texture
  32605. */
  32606. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  32607. /**
  32608. * Serializes the LUT texture to json format.
  32609. */
  32610. serialize(): any;
  32611. }
  32612. }
  32613. declare module BABYLON {
  32614. class CubeTexture extends BaseTexture {
  32615. url: string;
  32616. coordinatesMode: number;
  32617. /**
  32618. * Gets or sets the center of the bounding box associated with the cube texture
  32619. * It must define where the camera used to render the texture was set
  32620. */
  32621. boundingBoxPosition: Vector3;
  32622. private _boundingBoxSize;
  32623. /**
  32624. * Gets or sets the size of the bounding box associated with the cube texture
  32625. * When defined, the cubemap will switch to local mode
  32626. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  32627. * @example https://www.babylonjs-playground.com/#RNASML
  32628. */
  32629. boundingBoxSize: Vector3;
  32630. protected _rotationY: number;
  32631. /**
  32632. * Gets texture matrix rotation angle around Y axis radians.
  32633. */
  32634. /**
  32635. * Sets texture matrix rotation angle around Y axis in radians.
  32636. */
  32637. rotationY: number;
  32638. private _noMipmap;
  32639. private _files;
  32640. private _extensions;
  32641. private _textureMatrix;
  32642. private _format;
  32643. private _prefiltered;
  32644. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  32645. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any): CubeTexture;
  32646. 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);
  32647. delayLoad(): void;
  32648. getReflectionTextureMatrix(): Matrix;
  32649. setReflectionTextureMatrix(value: Matrix): void;
  32650. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  32651. clone(): CubeTexture;
  32652. }
  32653. }
  32654. declare module BABYLON {
  32655. /**
  32656. * A class extending {BABYLON.Texture} allowing drawing on a texture
  32657. * @see http://doc.babylonjs.com/how_to/dynamictexture
  32658. */
  32659. class DynamicTexture extends Texture {
  32660. private _generateMipMaps;
  32661. private _canvas;
  32662. private _context;
  32663. private _engine;
  32664. /**
  32665. * Creates a {BABYLON.DynamicTexture}
  32666. * @param name defines the name of the texture
  32667. * @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
  32668. * @param scene defines the scene where you want the texture
  32669. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  32670. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  32671. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  32672. */
  32673. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  32674. /**
  32675. * Gets the current state of canRescale
  32676. */
  32677. readonly canRescale: boolean;
  32678. private _recreate(textureSize);
  32679. /**
  32680. * Scales the texture
  32681. * @param ratio the scale factor to apply to both width and height
  32682. */
  32683. scale(ratio: number): void;
  32684. /**
  32685. * Resizes the texture
  32686. * @param width the new width
  32687. * @param height the new height
  32688. */
  32689. scaleTo(width: number, height: number): void;
  32690. /**
  32691. * Gets the context of the canvas used by the texture
  32692. * @returns the canvas context of the dynamic texture
  32693. */
  32694. getContext(): CanvasRenderingContext2D;
  32695. /**
  32696. * Clears the texture
  32697. */
  32698. clear(): void;
  32699. /**
  32700. * Updates the texture
  32701. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  32702. */
  32703. update(invertY?: boolean): void;
  32704. /**
  32705. * Draws text onto the texture
  32706. * @param text defines the text to be drawn
  32707. * @param x defines the placement of the text from the left
  32708. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  32709. * @param font defines the font to be used with font-style, font-size, font-name
  32710. * @param color defines the color used for the text
  32711. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  32712. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  32713. * @param update defines whether texture is immediately update (default is true)
  32714. */
  32715. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  32716. /**
  32717. * Clones the texture
  32718. * @returns the clone of the texture.
  32719. */
  32720. clone(): DynamicTexture;
  32721. /** @hidden */
  32722. _rebuild(): void;
  32723. }
  32724. }
  32725. declare module BABYLON {
  32726. /**
  32727. * This represents a texture coming from an HDR input.
  32728. *
  32729. * The only supported format is currently panorama picture stored in RGBE format.
  32730. * Example of such files can be found on HDRLib: http://hdrlib.com/
  32731. */
  32732. class HDRCubeTexture extends BaseTexture {
  32733. private static _facesMapping;
  32734. private _generateHarmonics;
  32735. private _noMipmap;
  32736. private _textureMatrix;
  32737. private _size;
  32738. private _onLoad;
  32739. private _onError;
  32740. /**
  32741. * The texture URL.
  32742. */
  32743. url: string;
  32744. /**
  32745. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  32746. */
  32747. coordinatesMode: number;
  32748. protected _isBlocking: boolean;
  32749. /**
  32750. * Gets wether or not the texture is blocking during loading.
  32751. */
  32752. /**
  32753. * Sets wether or not the texture is blocking during loading.
  32754. */
  32755. isBlocking: boolean;
  32756. protected _rotationY: number;
  32757. /**
  32758. * Gets texture matrix rotation angle around Y axis radians.
  32759. */
  32760. /**
  32761. * Sets texture matrix rotation angle around Y axis in radians.
  32762. */
  32763. rotationY: number;
  32764. /**
  32765. * Gets or sets the center of the bounding box associated with the cube texture
  32766. * It must define where the camera used to render the texture was set
  32767. */
  32768. boundingBoxPosition: Vector3;
  32769. private _boundingBoxSize;
  32770. /**
  32771. * Gets or sets the size of the bounding box associated with the cube texture
  32772. * When defined, the cubemap will switch to local mode
  32773. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  32774. * @example https://www.babylonjs-playground.com/#RNASML
  32775. */
  32776. boundingBoxSize: Vector3;
  32777. /**
  32778. * Instantiates an HDRTexture from the following parameters.
  32779. *
  32780. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  32781. * @param scene The scene the texture will be used in
  32782. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  32783. * @param noMipmap Forces to not generate the mipmap if true
  32784. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  32785. * @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)
  32786. * @param reserved Reserved flag for internal use.
  32787. */
  32788. 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>);
  32789. /**
  32790. * Occurs when the file is raw .hdr file.
  32791. */
  32792. private loadTexture();
  32793. clone(): HDRCubeTexture;
  32794. delayLoad(): void;
  32795. getReflectionTextureMatrix(): Matrix;
  32796. setReflectionTextureMatrix(value: Matrix): void;
  32797. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  32798. serialize(): any;
  32799. }
  32800. }
  32801. declare module BABYLON {
  32802. /**
  32803. * Class used to store data associated with WebGL texture data for the engine
  32804. * This class should not be used directly
  32805. */
  32806. class InternalTexture implements IInternalTextureTracker {
  32807. /**
  32808. * The source of the texture data is unknown
  32809. */
  32810. static DATASOURCE_UNKNOWN: number;
  32811. /**
  32812. * Texture data comes from an URL
  32813. */
  32814. static DATASOURCE_URL: number;
  32815. /**
  32816. * Texture data is only used for temporary storage
  32817. */
  32818. static DATASOURCE_TEMP: number;
  32819. /**
  32820. * Texture data comes from raw data (ArrayBuffer)
  32821. */
  32822. static DATASOURCE_RAW: number;
  32823. /**
  32824. * Texture content is dynamic (video or dynamic texture)
  32825. */
  32826. static DATASOURCE_DYNAMIC: number;
  32827. /**
  32828. * Texture content is generated by rendering to it
  32829. */
  32830. static DATASOURCE_RENDERTARGET: number;
  32831. /**
  32832. * Texture content is part of a multi render target process
  32833. */
  32834. static DATASOURCE_MULTIRENDERTARGET: number;
  32835. /**
  32836. * Texture data comes from a cube data file
  32837. */
  32838. static DATASOURCE_CUBE: number;
  32839. /**
  32840. * Texture data comes from a raw cube data
  32841. */
  32842. static DATASOURCE_CUBERAW: number;
  32843. /**
  32844. * Texture data come from a prefiltered cube data file
  32845. */
  32846. static DATASOURCE_CUBEPREFILTERED: number;
  32847. /**
  32848. * Texture content is raw 3D data
  32849. */
  32850. static DATASOURCE_RAW3D: number;
  32851. /**
  32852. * Texture content is a depth texture
  32853. */
  32854. static DATASOURCE_DEPTHTEXTURE: number;
  32855. /**
  32856. * Defines if the texture is ready
  32857. */
  32858. isReady: boolean;
  32859. /**
  32860. * Defines if the texture is a cube texture
  32861. */
  32862. isCube: boolean;
  32863. /**
  32864. * Defines if the texture contains 3D data
  32865. */
  32866. is3D: boolean;
  32867. /**
  32868. * Gets the URL used to load this texture
  32869. */
  32870. url: string;
  32871. /**
  32872. * Gets the sampling mode of the texture
  32873. */
  32874. samplingMode: number;
  32875. /**
  32876. * Gets a boolean indicating if the texture needs mipmaps generation
  32877. */
  32878. generateMipMaps: boolean;
  32879. /**
  32880. * Gets the number of samples used by the texture (WebGL2+ only)
  32881. */
  32882. samples: number;
  32883. /**
  32884. * Gets the type of the texture
  32885. */
  32886. type: number;
  32887. /**
  32888. * Gets the format of the texture
  32889. */
  32890. format: number;
  32891. /**
  32892. * Observable called when the texture is loaded
  32893. */
  32894. onLoadedObservable: Observable<InternalTexture>;
  32895. /**
  32896. * Gets the width of the texture
  32897. */
  32898. width: number;
  32899. /**
  32900. * Gets the height of the texture
  32901. */
  32902. height: number;
  32903. /**
  32904. * Gets the depth of the texture
  32905. */
  32906. depth: number;
  32907. /**
  32908. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32909. */
  32910. baseWidth: number;
  32911. /**
  32912. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32913. */
  32914. baseHeight: number;
  32915. /**
  32916. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32917. */
  32918. baseDepth: number;
  32919. /**
  32920. * Gets a boolean indicating if the texture is inverted on Y axis
  32921. */
  32922. invertY: boolean;
  32923. /**
  32924. * Gets or set the previous tracker in the list
  32925. */
  32926. previous: Nullable<IInternalTextureTracker>;
  32927. /**
  32928. * Gets or set the next tracker in the list
  32929. */
  32930. next: Nullable<IInternalTextureTracker>;
  32931. /** @hidden */
  32932. _initialSlot: number;
  32933. /** @hidden */
  32934. _designatedSlot: number;
  32935. /** @hidden */
  32936. _dataSource: number;
  32937. /** @hidden */
  32938. _buffer: Nullable<ArrayBuffer | HTMLImageElement>;
  32939. /** @hidden */
  32940. _bufferView: Nullable<ArrayBufferView>;
  32941. /** @hidden */
  32942. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32943. /** @hidden */
  32944. _size: number;
  32945. /** @hidden */
  32946. _extension: string;
  32947. /** @hidden */
  32948. _files: Nullable<string[]>;
  32949. /** @hidden */
  32950. _workingCanvas: HTMLCanvasElement;
  32951. /** @hidden */
  32952. _workingContext: CanvasRenderingContext2D;
  32953. /** @hidden */
  32954. _framebuffer: Nullable<WebGLFramebuffer>;
  32955. /** @hidden */
  32956. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32957. /** @hidden */
  32958. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32959. /** @hidden */
  32960. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32961. /** @hidden */
  32962. _attachments: Nullable<number[]>;
  32963. /** @hidden */
  32964. _cachedCoordinatesMode: Nullable<number>;
  32965. /** @hidden */
  32966. _cachedWrapU: Nullable<number>;
  32967. /** @hidden */
  32968. _cachedWrapV: Nullable<number>;
  32969. /** @hidden */
  32970. _cachedWrapR: Nullable<number>;
  32971. /** @hidden */
  32972. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32973. /** @hidden */
  32974. _isDisabled: boolean;
  32975. /** @hidden */
  32976. _compression: Nullable<string>;
  32977. /** @hidden */
  32978. _generateStencilBuffer: boolean;
  32979. /** @hidden */
  32980. _generateDepthBuffer: boolean;
  32981. /** @hidden */
  32982. _comparisonFunction: number;
  32983. /** @hidden */
  32984. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32985. /** @hidden */
  32986. _lodGenerationScale: number;
  32987. /** @hidden */
  32988. _lodGenerationOffset: number;
  32989. /** @hidden */
  32990. _lodTextureHigh: BaseTexture;
  32991. /** @hidden */
  32992. _lodTextureMid: BaseTexture;
  32993. /** @hidden */
  32994. _lodTextureLow: BaseTexture;
  32995. /** @hidden */
  32996. _webGLTexture: Nullable<WebGLTexture>;
  32997. /** @hidden */
  32998. _references: number;
  32999. private _engine;
  33000. /**
  33001. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  33002. */
  33003. readonly dataSource: number;
  33004. /**
  33005. * Creates a new InternalTexture
  33006. * @param engine defines the engine to use
  33007. * @param dataSource defines the type of data that will be used
  33008. */
  33009. constructor(engine: Engine, dataSource: number);
  33010. /**
  33011. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  33012. */
  33013. incrementReferences(): void;
  33014. /**
  33015. * Change the size of the texture (not the size of the content)
  33016. * @param width defines the new width
  33017. * @param height defines the new height
  33018. * @param depth defines the new depth (1 by default)
  33019. */
  33020. updateSize(width: int, height: int, depth?: int): void;
  33021. /** @hidden */
  33022. _rebuild(): void;
  33023. private _swapAndDie(target);
  33024. /**
  33025. * Dispose the current allocated resources
  33026. */
  33027. dispose(): void;
  33028. }
  33029. }
  33030. declare module BABYLON {
  33031. /**
  33032. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  33033. */
  33034. interface IInternalTextureTracker {
  33035. /**
  33036. * Gets or set the previous tracker in the list
  33037. */
  33038. previous: Nullable<IInternalTextureTracker>;
  33039. /**
  33040. * Gets or set the next tracker in the list
  33041. */
  33042. next: Nullable<IInternalTextureTracker>;
  33043. }
  33044. /**
  33045. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  33046. */
  33047. class DummyInternalTextureTracker {
  33048. /**
  33049. * Gets or set the previous tracker in the list
  33050. */
  33051. previous: Nullable<IInternalTextureTracker>;
  33052. /**
  33053. * Gets or set the next tracker in the list
  33054. */
  33055. next: Nullable<IInternalTextureTracker>;
  33056. }
  33057. }
  33058. declare module BABYLON {
  33059. class MirrorTexture extends RenderTargetTexture {
  33060. private scene;
  33061. mirrorPlane: Plane;
  33062. private _transformMatrix;
  33063. private _mirrorMatrix;
  33064. private _savedViewMatrix;
  33065. private _blurX;
  33066. private _blurY;
  33067. private _adaptiveBlurKernel;
  33068. private _blurKernelX;
  33069. private _blurKernelY;
  33070. private _blurRatio;
  33071. blurRatio: number;
  33072. adaptiveBlurKernel: number;
  33073. blurKernel: number;
  33074. blurKernelX: number;
  33075. blurKernelY: number;
  33076. private _autoComputeBlurKernel();
  33077. protected _onRatioRescale(): void;
  33078. private _updateGammaSpace();
  33079. private _imageProcessingConfigChangeObserver;
  33080. constructor(name: string, size: number | {
  33081. width: number;
  33082. height: number;
  33083. } | {
  33084. ratio: number;
  33085. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  33086. private _preparePostProcesses();
  33087. clone(): MirrorTexture;
  33088. serialize(): any;
  33089. dispose(): void;
  33090. }
  33091. }
  33092. declare module BABYLON {
  33093. interface IMultiRenderTargetOptions {
  33094. generateMipMaps?: boolean;
  33095. types?: number[];
  33096. samplingModes?: number[];
  33097. generateDepthBuffer?: boolean;
  33098. generateStencilBuffer?: boolean;
  33099. generateDepthTexture?: boolean;
  33100. textureCount?: number;
  33101. doNotChangeAspectRatio?: boolean;
  33102. defaultType?: number;
  33103. }
  33104. class MultiRenderTarget extends RenderTargetTexture {
  33105. private _internalTextures;
  33106. private _textures;
  33107. readonly isSupported: boolean;
  33108. private _multiRenderTargetOptions;
  33109. readonly textures: Texture[];
  33110. readonly depthTexture: Texture;
  33111. wrapU: number;
  33112. wrapV: number;
  33113. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  33114. _rebuild(): void;
  33115. private _createInternalTextures();
  33116. private _createTextures();
  33117. samples: number;
  33118. resize(size: any): void;
  33119. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  33120. dispose(): void;
  33121. releaseInternalTextures(): void;
  33122. }
  33123. }
  33124. declare module BABYLON {
  33125. class RawTexture extends Texture {
  33126. format: number;
  33127. private _engine;
  33128. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  33129. update(data: ArrayBufferView): void;
  33130. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33131. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33132. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33133. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33134. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33135. }
  33136. }
  33137. declare module BABYLON {
  33138. /**
  33139. * Class used to store 3D textures containing user data
  33140. */
  33141. class RawTexture3D extends Texture {
  33142. /** Gets or sets the texture format to use*/
  33143. format: number;
  33144. private _engine;
  33145. /**
  33146. * Create a new RawTexture3D
  33147. * @param data defines the data of the texture
  33148. * @param width defines the width of the texture
  33149. * @param height defines the height of the texture
  33150. * @param depth defines the depth of the texture
  33151. * @param format defines the texture format to use
  33152. * @param scene defines the hosting scene
  33153. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  33154. * @param invertY defines if texture must be stored with Y axis inverted
  33155. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  33156. */
  33157. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  33158. /** Gets or sets the texture format to use*/
  33159. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number);
  33160. /**
  33161. * Update the texture with new data
  33162. * @param data defines the data to store in the texture
  33163. */
  33164. update(data: ArrayBufferView): void;
  33165. }
  33166. }
  33167. declare module BABYLON {
  33168. /**
  33169. * Creates a refraction texture used by refraction channel of the standard material.
  33170. * @param name the texture name
  33171. * @param size size of the underlying texture
  33172. * @param scene root scene
  33173. */
  33174. class RefractionTexture extends RenderTargetTexture {
  33175. refractionPlane: Plane;
  33176. depth: number;
  33177. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  33178. clone(): RefractionTexture;
  33179. serialize(): any;
  33180. }
  33181. }
  33182. declare module BABYLON {
  33183. class RenderTargetTexture extends Texture {
  33184. isCube: boolean;
  33185. static _REFRESHRATE_RENDER_ONCE: number;
  33186. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  33187. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  33188. static readonly REFRESHRATE_RENDER_ONCE: number;
  33189. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  33190. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  33191. /**
  33192. * Use this predicate to dynamically define the list of mesh you want to render.
  33193. * If set, the renderList property will be overwritten.
  33194. */
  33195. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  33196. /**
  33197. * Use this list to define the list of mesh you want to render.
  33198. */
  33199. renderList: Nullable<Array<AbstractMesh>>;
  33200. renderParticles: boolean;
  33201. renderSprites: boolean;
  33202. coordinatesMode: number;
  33203. activeCamera: Nullable<Camera>;
  33204. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  33205. useCameraPostProcesses: boolean;
  33206. ignoreCameraViewport: boolean;
  33207. private _postProcessManager;
  33208. private _postProcesses;
  33209. private _resizeObserver;
  33210. /**
  33211. * An event triggered when the texture is unbind.
  33212. */
  33213. onBeforeBindObservable: Observable<RenderTargetTexture>;
  33214. /**
  33215. * An event triggered when the texture is unbind.
  33216. */
  33217. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  33218. private _onAfterUnbindObserver;
  33219. onAfterUnbind: () => void;
  33220. /**
  33221. * An event triggered before rendering the texture
  33222. */
  33223. onBeforeRenderObservable: Observable<number>;
  33224. private _onBeforeRenderObserver;
  33225. onBeforeRender: (faceIndex: number) => void;
  33226. /**
  33227. * An event triggered after rendering the texture
  33228. */
  33229. onAfterRenderObservable: Observable<number>;
  33230. private _onAfterRenderObserver;
  33231. onAfterRender: (faceIndex: number) => void;
  33232. /**
  33233. * An event triggered after the texture clear
  33234. */
  33235. onClearObservable: Observable<Engine>;
  33236. private _onClearObserver;
  33237. onClear: (Engine: Engine) => void;
  33238. clearColor: Color4;
  33239. protected _size: number | {
  33240. width: number;
  33241. height: number;
  33242. };
  33243. protected _initialSizeParameter: number | {
  33244. width: number;
  33245. height: number;
  33246. } | {
  33247. ratio: number;
  33248. };
  33249. protected _sizeRatio: Nullable<number>;
  33250. _generateMipMaps: boolean;
  33251. protected _renderingManager: RenderingManager;
  33252. _waitingRenderList: string[];
  33253. protected _doNotChangeAspectRatio: boolean;
  33254. protected _currentRefreshId: number;
  33255. protected _refreshRate: number;
  33256. protected _textureMatrix: Matrix;
  33257. protected _samples: number;
  33258. protected _renderTargetOptions: RenderTargetCreationOptions;
  33259. readonly renderTargetOptions: RenderTargetCreationOptions;
  33260. protected _engine: Engine;
  33261. protected _onRatioRescale(): void;
  33262. /**
  33263. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  33264. * It must define where the camera used to render the texture is set
  33265. */
  33266. boundingBoxPosition: Vector3;
  33267. private _boundingBoxSize;
  33268. /**
  33269. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  33270. * When defined, the cubemap will switch to local mode
  33271. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33272. * @example https://www.babylonjs-playground.com/#RNASML
  33273. */
  33274. boundingBoxSize: Vector3;
  33275. /**
  33276. * In case the RTT has been created with a depth texture, get the associated
  33277. * depth texture.
  33278. * Otherwise, return null.
  33279. */
  33280. depthStencilTexture: Nullable<InternalTexture>;
  33281. /**
  33282. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  33283. * or used a shadow, depth texture...
  33284. * @param name The friendly name of the texture
  33285. * @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)
  33286. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  33287. * @param generateMipMaps True if mip maps need to be generated after render.
  33288. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  33289. * @param type The type of the buffer in the RTT (int, half float, float...)
  33290. * @param isCube True if a cube texture needs to be created
  33291. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  33292. * @param generateDepthBuffer True to generate a depth buffer
  33293. * @param generateStencilBuffer True to generate a stencil buffer
  33294. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  33295. */
  33296. constructor(name: string, size: number | {
  33297. width: number;
  33298. height: number;
  33299. } | {
  33300. ratio: number;
  33301. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  33302. /**
  33303. * Creates a depth stencil texture.
  33304. * This is only available in WebGL 2 or with the depth texture extension available.
  33305. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  33306. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  33307. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  33308. */
  33309. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  33310. private _processSizeParameter(size);
  33311. samples: number;
  33312. resetRefreshCounter(): void;
  33313. refreshRate: number;
  33314. addPostProcess(postProcess: PostProcess): void;
  33315. clearPostProcesses(dispose?: boolean): void;
  33316. removePostProcess(postProcess: PostProcess): void;
  33317. _shouldRender(): boolean;
  33318. getRenderSize(): number;
  33319. getRenderWidth(): number;
  33320. getRenderHeight(): number;
  33321. readonly canRescale: boolean;
  33322. scale(ratio: number): void;
  33323. getReflectionTextureMatrix(): Matrix;
  33324. resize(size: number | {
  33325. width: number;
  33326. height: number;
  33327. } | {
  33328. ratio: number;
  33329. }): void;
  33330. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  33331. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  33332. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  33333. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  33334. /**
  33335. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33336. * This allowed control for front to back rendering or reversly depending of the special needs.
  33337. *
  33338. * @param renderingGroupId The rendering group id corresponding to its index
  33339. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33340. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33341. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33342. */
  33343. 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;
  33344. /**
  33345. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33346. *
  33347. * @param renderingGroupId The rendering group id corresponding to its index
  33348. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33349. */
  33350. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  33351. clone(): RenderTargetTexture;
  33352. serialize(): any;
  33353. disposeFramebufferObjects(): void;
  33354. dispose(): void;
  33355. _rebuild(): void;
  33356. /**
  33357. * Clear the info related to rendering groups preventing retention point in material dispose.
  33358. */
  33359. freeRenderingGroups(): void;
  33360. }
  33361. }
  33362. declare module BABYLON {
  33363. class Texture extends BaseTexture {
  33364. static NEAREST_SAMPLINGMODE: number;
  33365. static NEAREST_NEAREST_MIPLINEAR: number;
  33366. static BILINEAR_SAMPLINGMODE: number;
  33367. static LINEAR_LINEAR_MIPNEAREST: number;
  33368. static TRILINEAR_SAMPLINGMODE: number;
  33369. static LINEAR_LINEAR_MIPLINEAR: number;
  33370. static NEAREST_NEAREST_MIPNEAREST: number;
  33371. static NEAREST_LINEAR_MIPNEAREST: number;
  33372. static NEAREST_LINEAR_MIPLINEAR: number;
  33373. static NEAREST_LINEAR: number;
  33374. static NEAREST_NEAREST: number;
  33375. static LINEAR_NEAREST_MIPNEAREST: number;
  33376. static LINEAR_NEAREST_MIPLINEAR: number;
  33377. static LINEAR_LINEAR: number;
  33378. static LINEAR_NEAREST: number;
  33379. static EXPLICIT_MODE: number;
  33380. static SPHERICAL_MODE: number;
  33381. static PLANAR_MODE: number;
  33382. static CUBIC_MODE: number;
  33383. static PROJECTION_MODE: number;
  33384. static SKYBOX_MODE: number;
  33385. static INVCUBIC_MODE: number;
  33386. static EQUIRECTANGULAR_MODE: number;
  33387. static FIXED_EQUIRECTANGULAR_MODE: number;
  33388. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33389. static CLAMP_ADDRESSMODE: number;
  33390. static WRAP_ADDRESSMODE: number;
  33391. static MIRROR_ADDRESSMODE: number;
  33392. /**
  33393. * 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
  33394. */
  33395. static UseSerializedUrlIfAny: boolean;
  33396. url: Nullable<string>;
  33397. uOffset: number;
  33398. vOffset: number;
  33399. uScale: number;
  33400. vScale: number;
  33401. uAng: number;
  33402. vAng: number;
  33403. wAng: number;
  33404. readonly noMipmap: boolean;
  33405. private _noMipmap;
  33406. _invertY: boolean;
  33407. private _rowGenerationMatrix;
  33408. private _cachedTextureMatrix;
  33409. private _projectionModeMatrix;
  33410. private _t0;
  33411. private _t1;
  33412. private _t2;
  33413. private _cachedUOffset;
  33414. private _cachedVOffset;
  33415. private _cachedUScale;
  33416. private _cachedVScale;
  33417. private _cachedUAng;
  33418. private _cachedVAng;
  33419. private _cachedWAng;
  33420. private _cachedProjectionMatrixId;
  33421. private _cachedCoordinatesMode;
  33422. _samplingMode: number;
  33423. private _buffer;
  33424. private _deleteBuffer;
  33425. protected _format: Nullable<number>;
  33426. private _delayedOnLoad;
  33427. private _delayedOnError;
  33428. protected _onLoadObservable: Nullable<Observable<Texture>>;
  33429. protected _isBlocking: boolean;
  33430. isBlocking: boolean;
  33431. readonly samplingMode: number;
  33432. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: any, deleteBuffer?: boolean, format?: number);
  33433. updateURL(url: string): void;
  33434. delayLoad(): void;
  33435. updateSamplingMode(samplingMode: number): void;
  33436. private _prepareRowForTextureGeneration(x, y, z, t);
  33437. getTextureMatrix(): Matrix;
  33438. getReflectionTextureMatrix(): Matrix;
  33439. clone(): Texture;
  33440. readonly onLoadObservable: Observable<Texture>;
  33441. serialize(): any;
  33442. getClassName(): string;
  33443. dispose(): void;
  33444. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  33445. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  33446. 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;
  33447. }
  33448. }
  33449. declare module BABYLON {
  33450. /**
  33451. * Settings for finer control over video usage
  33452. */
  33453. interface VideoTextureSettings {
  33454. /**
  33455. * Applies `autoplay` to video, if specified
  33456. */
  33457. autoPlay?: boolean;
  33458. /**
  33459. * Applies `loop` to video, if specified
  33460. */
  33461. loop?: boolean;
  33462. /**
  33463. * Automatically updates internal texture from video at every frame in the render loop
  33464. */
  33465. autoUpdateTexture: boolean;
  33466. }
  33467. class VideoTexture extends Texture {
  33468. /**
  33469. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  33470. */
  33471. readonly autoUpdateTexture: boolean;
  33472. /**
  33473. * The video instance used by the texture internally
  33474. */
  33475. readonly video: HTMLVideoElement;
  33476. private _generateMipMaps;
  33477. private _engine;
  33478. private _stillImageCaptured;
  33479. /**
  33480. * Creates a video texture.
  33481. * Sample : https://doc.babylonjs.com/how_to/video_texture
  33482. * @param {string | null} name optional name, will detect from video source, if not defined
  33483. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  33484. * @param {BABYLON.Scene} scene is obviously the current scene.
  33485. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  33486. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  33487. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  33488. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  33489. */
  33490. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  33491. private _getName(src);
  33492. private _getVideo(src);
  33493. private _createInternalTexture;
  33494. private reset;
  33495. /**
  33496. * Internal method to initiate `update`.
  33497. */
  33498. _rebuild(): void;
  33499. /**
  33500. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  33501. */
  33502. update(): void;
  33503. /**
  33504. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  33505. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  33506. */
  33507. updateTexture(isVisible: boolean): void;
  33508. protected _updateInternalTexture: (e?: Event | undefined) => void;
  33509. /**
  33510. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  33511. * @param url New url.
  33512. */
  33513. updateURL(url: string): void;
  33514. dispose(): void;
  33515. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  33516. minWidth: number;
  33517. maxWidth: number;
  33518. minHeight: number;
  33519. maxHeight: number;
  33520. deviceId: string;
  33521. }): void;
  33522. }
  33523. }
  33524. declare var DracoDecoderModule: any;
  33525. declare var WebAssembly: any;
  33526. declare module BABYLON {
  33527. /**
  33528. * Configuration for Draco compression
  33529. */
  33530. interface IDracoCompressionConfiguration {
  33531. /**
  33532. * Configuration for the decoder.
  33533. */
  33534. decoder?: {
  33535. /**
  33536. * The url to the WebAssembly module.
  33537. */
  33538. wasmUrl?: string;
  33539. /**
  33540. * The url to the WebAssembly binary.
  33541. */
  33542. wasmBinaryUrl?: string;
  33543. /**
  33544. * The url to the fallback JavaScript module.
  33545. */
  33546. fallbackUrl?: string;
  33547. };
  33548. }
  33549. /**
  33550. * Draco compression (https://google.github.io/draco/)
  33551. */
  33552. class DracoCompression implements IDisposable {
  33553. private static _DecoderModulePromise;
  33554. /**
  33555. * The configuration.
  33556. */
  33557. static Configuration: IDracoCompressionConfiguration;
  33558. /**
  33559. * Returns true if the decoder is available.
  33560. */
  33561. static readonly DecoderAvailable: boolean;
  33562. /**
  33563. * Constructor
  33564. */
  33565. constructor();
  33566. /**
  33567. * Stop all async operations and release resources.
  33568. */
  33569. dispose(): void;
  33570. /**
  33571. * Decode Draco compressed mesh data to vertex data.
  33572. * @param data The array buffer view for the Draco compression data
  33573. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  33574. * @returns A promise that resolves with the decoded vertex data
  33575. */
  33576. decodeMeshAsync(data: ArrayBufferView, attributes: {
  33577. [kind: string]: number;
  33578. }): Promise<VertexData>;
  33579. private static _GetDecoderModule();
  33580. private static _LoadScriptAsync(url);
  33581. private static _LoadFileAsync(url);
  33582. }
  33583. }
  33584. declare module BABYLON {
  33585. /**
  33586. * Particle emitter emitting particles from the inside of a box.
  33587. * It emits the particles randomly between 2 given directions.
  33588. */
  33589. class BoxParticleEmitter implements IParticleEmitterType {
  33590. /**
  33591. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  33592. */
  33593. direction1: Vector3;
  33594. /**
  33595. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  33596. */
  33597. direction2: Vector3;
  33598. /**
  33599. * 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.
  33600. */
  33601. minEmitBox: Vector3;
  33602. /**
  33603. * 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.
  33604. */
  33605. maxEmitBox: Vector3;
  33606. /**
  33607. * Creates a new instance BoxParticleEmitter
  33608. */
  33609. constructor();
  33610. /**
  33611. * Called by the particle System when the direction is computed for the created particle.
  33612. * @param emitPower is the power of the particle (speed)
  33613. * @param worldMatrix is the world matrix of the particle system
  33614. * @param directionToUpdate is the direction vector to update with the result
  33615. * @param particle is the particle we are computed the direction for
  33616. */
  33617. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33618. /**
  33619. * Called by the particle System when the position is computed for the created particle.
  33620. * @param worldMatrix is the world matrix of the particle system
  33621. * @param positionToUpdate is the position vector to update with the result
  33622. * @param particle is the particle we are computed the position for
  33623. */
  33624. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33625. /**
  33626. * Clones the current emitter and returns a copy of it
  33627. * @returns the new emitter
  33628. */
  33629. clone(): BoxParticleEmitter;
  33630. /**
  33631. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33632. * @param effect defines the update shader
  33633. */
  33634. applyToShader(effect: Effect): void;
  33635. /**
  33636. * Returns a string to use to update the GPU particles update shader
  33637. * @returns a string containng the defines string
  33638. */
  33639. getEffectDefines(): string;
  33640. /**
  33641. * Returns the string "BoxEmitter"
  33642. * @returns a string containing the class name
  33643. */
  33644. getClassName(): string;
  33645. /**
  33646. * Serializes the particle system to a JSON object.
  33647. * @returns the JSON object
  33648. */
  33649. serialize(): any;
  33650. /**
  33651. * Parse properties from a JSON object
  33652. * @param serializationObject defines the JSON object
  33653. */
  33654. parse(serializationObject: any): void;
  33655. }
  33656. }
  33657. declare module BABYLON {
  33658. /**
  33659. * Particle emitter emitting particles from the inside of a cone.
  33660. * It emits the particles alongside the cone volume from the base to the particle.
  33661. * The emission direction might be randomized.
  33662. */
  33663. class ConeParticleEmitter implements IParticleEmitterType {
  33664. /**
  33665. * The radius of the emission cone.
  33666. */
  33667. angle: number;
  33668. /**
  33669. * The cone base angle.
  33670. */
  33671. directionRandomizer: number;
  33672. private _radius;
  33673. private _height;
  33674. /**
  33675. * Gets the radius of the emission cone.
  33676. */
  33677. /**
  33678. * Sets the radius of the emission cone.
  33679. */
  33680. radius: number;
  33681. /**
  33682. * Creates a new instance ConeParticleEmitter
  33683. * @param radius the radius of the emission cone (1 by default)
  33684. * @param angles the cone base angle (PI by default)
  33685. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  33686. */
  33687. constructor(radius?: number,
  33688. /**
  33689. * The radius of the emission cone.
  33690. */
  33691. angle?: number,
  33692. /**
  33693. * The cone base angle.
  33694. */
  33695. directionRandomizer?: number);
  33696. /**
  33697. * Called by the particle System when the direction is computed for the created particle.
  33698. * @param emitPower is the power of the particle (speed)
  33699. * @param worldMatrix is the world matrix of the particle system
  33700. * @param directionToUpdate is the direction vector to update with the result
  33701. * @param particle is the particle we are computed the direction for
  33702. */
  33703. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33704. /**
  33705. * Called by the particle System when the position is computed for the created particle.
  33706. * @param worldMatrix is the world matrix of the particle system
  33707. * @param positionToUpdate is the position vector to update with the result
  33708. * @param particle is the particle we are computed the position for
  33709. */
  33710. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33711. /**
  33712. * Clones the current emitter and returns a copy of it
  33713. * @returns the new emitter
  33714. */
  33715. clone(): ConeParticleEmitter;
  33716. /**
  33717. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33718. * @param effect defines the update shader
  33719. */
  33720. applyToShader(effect: Effect): void;
  33721. /**
  33722. * Returns a string to use to update the GPU particles update shader
  33723. * @returns a string containng the defines string
  33724. */
  33725. getEffectDefines(): string;
  33726. /**
  33727. * Returns the string "BoxEmitter"
  33728. * @returns a string containing the class name
  33729. */
  33730. getClassName(): string;
  33731. /**
  33732. * Serializes the particle system to a JSON object.
  33733. * @returns the JSON object
  33734. */
  33735. serialize(): any;
  33736. /**
  33737. * Parse properties from a JSON object
  33738. * @param serializationObject defines the JSON object
  33739. */
  33740. parse(serializationObject: any): void;
  33741. }
  33742. }
  33743. declare module BABYLON {
  33744. /**
  33745. * Particle emitter represents a volume emitting particles.
  33746. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  33747. */
  33748. interface IParticleEmitterType {
  33749. /**
  33750. * Called by the particle System when the direction is computed for the created particle.
  33751. * @param emitPower is the power of the particle (speed)
  33752. * @param worldMatrix is the world matrix of the particle system
  33753. * @param directionToUpdate is the direction vector to update with the result
  33754. * @param particle is the particle we are computed the direction for
  33755. */
  33756. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33757. /**
  33758. * Called by the particle System when the position is computed for the created particle.
  33759. * @param worldMatrix is the world matrix of the particle system
  33760. * @param positionToUpdate is the position vector to update with the result
  33761. * @param particle is the particle we are computed the position for
  33762. */
  33763. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33764. /**
  33765. * Clones the current emitter and returns a copy of it
  33766. * @returns the new emitter
  33767. */
  33768. clone(): IParticleEmitterType;
  33769. /**
  33770. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33771. * @param effect defines the update shader
  33772. */
  33773. applyToShader(effect: Effect): void;
  33774. /**
  33775. * Returns a string to use to update the GPU particles update shader
  33776. * @returns the effect defines string
  33777. */
  33778. getEffectDefines(): string;
  33779. /**
  33780. * Returns a string representing the class name
  33781. * @returns a string containing the class name
  33782. */
  33783. getClassName(): string;
  33784. /**
  33785. * Serializes the particle system to a JSON object.
  33786. * @returns the JSON object
  33787. */
  33788. serialize(): any;
  33789. /**
  33790. * Parse properties from a JSON object
  33791. * @param serializationObject defines the JSON object
  33792. */
  33793. parse(serializationObject: any): void;
  33794. }
  33795. }
  33796. declare module BABYLON {
  33797. /**
  33798. * Particle emitter emitting particles from the inside of a sphere.
  33799. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  33800. */
  33801. class SphereParticleEmitter implements IParticleEmitterType {
  33802. /**
  33803. * The radius of the emission sphere.
  33804. */
  33805. radius: number;
  33806. /**
  33807. * How much to randomize the particle direction [0-1].
  33808. */
  33809. directionRandomizer: number;
  33810. /**
  33811. * Creates a new instance SphereParticleEmitter
  33812. * @param radius the radius of the emission sphere (1 by default)
  33813. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  33814. */
  33815. constructor(
  33816. /**
  33817. * The radius of the emission sphere.
  33818. */
  33819. radius?: number,
  33820. /**
  33821. * How much to randomize the particle direction [0-1].
  33822. */
  33823. directionRandomizer?: number);
  33824. /**
  33825. * Called by the particle System when the direction is computed for the created particle.
  33826. * @param emitPower is the power of the particle (speed)
  33827. * @param worldMatrix is the world matrix of the particle system
  33828. * @param directionToUpdate is the direction vector to update with the result
  33829. * @param particle is the particle we are computed the direction for
  33830. */
  33831. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33832. /**
  33833. * Called by the particle System when the position is computed for the created particle.
  33834. * @param worldMatrix is the world matrix of the particle system
  33835. * @param positionToUpdate is the position vector to update with the result
  33836. * @param particle is the particle we are computed the position for
  33837. */
  33838. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  33839. /**
  33840. * Clones the current emitter and returns a copy of it
  33841. * @returns the new emitter
  33842. */
  33843. clone(): SphereParticleEmitter;
  33844. /**
  33845. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33846. * @param effect defines the update shader
  33847. */
  33848. applyToShader(effect: Effect): void;
  33849. /**
  33850. * Returns a string to use to update the GPU particles update shader
  33851. * @returns a string containng the defines string
  33852. */
  33853. getEffectDefines(): string;
  33854. /**
  33855. * Returns the string "SphereParticleEmitter"
  33856. * @returns a string containing the class name
  33857. */
  33858. getClassName(): string;
  33859. /**
  33860. * Serializes the particle system to a JSON object.
  33861. * @returns the JSON object
  33862. */
  33863. serialize(): any;
  33864. /**
  33865. * Parse properties from a JSON object
  33866. * @param serializationObject defines the JSON object
  33867. */
  33868. parse(serializationObject: any): void;
  33869. }
  33870. /**
  33871. * Particle emitter emitting particles from the inside of a sphere.
  33872. * It emits the particles randomly between two vectors.
  33873. */
  33874. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  33875. /**
  33876. * The min limit of the emission direction.
  33877. */
  33878. direction1: Vector3;
  33879. /**
  33880. * The max limit of the emission direction.
  33881. */
  33882. direction2: Vector3;
  33883. /**
  33884. * Creates a new instance SphereDirectedParticleEmitter
  33885. * @param radius the radius of the emission sphere (1 by default)
  33886. * @param direction1 the min limit of the emission direction (up vector by default)
  33887. * @param direction2 the max limit of the emission direction (up vector by default)
  33888. */
  33889. constructor(radius?: number,
  33890. /**
  33891. * The min limit of the emission direction.
  33892. */
  33893. direction1?: Vector3,
  33894. /**
  33895. * The max limit of the emission direction.
  33896. */
  33897. direction2?: Vector3);
  33898. /**
  33899. * Called by the particle System when the direction is computed for the created particle.
  33900. * @param emitPower is the power of the particle (speed)
  33901. * @param worldMatrix is the world matrix of the particle system
  33902. * @param directionToUpdate is the direction vector to update with the result
  33903. * @param particle is the particle we are computed the direction for
  33904. */
  33905. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  33906. /**
  33907. * Clones the current emitter and returns a copy of it
  33908. * @returns the new emitter
  33909. */
  33910. clone(): SphereDirectedParticleEmitter;
  33911. /**
  33912. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  33913. * @param effect defines the update shader
  33914. */
  33915. applyToShader(effect: Effect): void;
  33916. /**
  33917. * Returns a string to use to update the GPU particles update shader
  33918. * @returns a string containng the defines string
  33919. */
  33920. getEffectDefines(): string;
  33921. /**
  33922. * Returns the string "SphereDirectedParticleEmitter"
  33923. * @returns a string containing the class name
  33924. */
  33925. getClassName(): string;
  33926. /**
  33927. * Serializes the particle system to a JSON object.
  33928. * @returns the JSON object
  33929. */
  33930. serialize(): any;
  33931. /**
  33932. * Parse properties from a JSON object
  33933. * @param serializationObject defines the JSON object
  33934. */
  33935. parse(serializationObject: any): void;
  33936. }
  33937. }
  33938. declare module BABYLON {
  33939. class CannonJSPlugin implements IPhysicsEnginePlugin {
  33940. private _useDeltaForWorldStep;
  33941. world: any;
  33942. name: string;
  33943. private _physicsMaterials;
  33944. private _fixedTimeStep;
  33945. BJSCANNON: any;
  33946. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  33947. setGravity(gravity: Vector3): void;
  33948. setTimeStep(timeStep: number): void;
  33949. getTimeStep(): number;
  33950. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  33951. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33952. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33953. generatePhysicsBody(impostor: PhysicsImpostor): void;
  33954. private _processChildMeshes(mainImpostor);
  33955. removePhysicsBody(impostor: PhysicsImpostor): void;
  33956. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  33957. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  33958. private _addMaterial(name, friction, restitution);
  33959. private _checkWithEpsilon(value);
  33960. private _createShape(impostor);
  33961. private _createHeightmap(object, pointDepth?);
  33962. private _minus90X;
  33963. private _plus90X;
  33964. private _tmpPosition;
  33965. private _tmpDeltaPosition;
  33966. private _tmpUnityRotation;
  33967. private _updatePhysicsBodyTransformation(impostor);
  33968. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  33969. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  33970. isSupported(): boolean;
  33971. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  33972. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  33973. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33974. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33975. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  33976. getBodyMass(impostor: PhysicsImpostor): number;
  33977. getBodyFriction(impostor: PhysicsImpostor): number;
  33978. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  33979. getBodyRestitution(impostor: PhysicsImpostor): number;
  33980. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  33981. sleepBody(impostor: PhysicsImpostor): void;
  33982. wakeUpBody(impostor: PhysicsImpostor): void;
  33983. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  33984. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  33985. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  33986. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  33987. getRadius(impostor: PhysicsImpostor): number;
  33988. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  33989. dispose(): void;
  33990. private _extendNamespace();
  33991. }
  33992. }
  33993. declare module BABYLON {
  33994. class OimoJSPlugin implements IPhysicsEnginePlugin {
  33995. world: any;
  33996. name: string;
  33997. BJSOIMO: any;
  33998. constructor(iterations?: number);
  33999. setGravity(gravity: Vector3): void;
  34000. setTimeStep(timeStep: number): void;
  34001. getTimeStep(): number;
  34002. private _tmpImpostorsArray;
  34003. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  34004. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34005. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34006. generatePhysicsBody(impostor: PhysicsImpostor): void;
  34007. private _tmpPositionVector;
  34008. removePhysicsBody(impostor: PhysicsImpostor): void;
  34009. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  34010. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  34011. isSupported(): boolean;
  34012. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  34013. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  34014. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34015. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34016. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34017. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34018. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  34019. getBodyMass(impostor: PhysicsImpostor): number;
  34020. getBodyFriction(impostor: PhysicsImpostor): number;
  34021. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  34022. getBodyRestitution(impostor: PhysicsImpostor): number;
  34023. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  34024. sleepBody(impostor: PhysicsImpostor): void;
  34025. wakeUpBody(impostor: PhysicsImpostor): void;
  34026. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  34027. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  34028. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34029. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  34030. getRadius(impostor: PhysicsImpostor): number;
  34031. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  34032. dispose(): void;
  34033. }
  34034. }
  34035. declare module BABYLON {
  34036. /**
  34037. * This represents a set of one or more post processes in Babylon.
  34038. * A post process can be used to apply a shader to a texture after it is rendered.
  34039. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  34040. */
  34041. class PostProcessRenderEffect {
  34042. private _postProcesses;
  34043. private _getPostProcesses;
  34044. private _singleInstance;
  34045. private _cameras;
  34046. private _indicesForCamera;
  34047. /**
  34048. * Name of the effect
  34049. */
  34050. _name: string;
  34051. /**
  34052. * Instantiates a post process render effect.
  34053. * A post process can be used to apply a shader to a texture after it is rendered.
  34054. * @param engine The engine the effect is tied to
  34055. * @param name The name of the effect
  34056. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  34057. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  34058. */
  34059. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  34060. /**
  34061. * Checks if all the post processes in the effect are supported.
  34062. */
  34063. readonly isSupported: boolean;
  34064. /**
  34065. * Updates the current state of the effect
  34066. */
  34067. _update(): void;
  34068. /**
  34069. * Attaches the effect on cameras
  34070. * @param cameras The camera to attach to.
  34071. */
  34072. _attachCameras(cameras: Camera): void;
  34073. /**
  34074. * Attaches the effect on cameras
  34075. * @param cameras The camera to attach to.
  34076. */
  34077. _attachCameras(cameras: Camera[]): void;
  34078. /**
  34079. * Detatches the effect on cameras
  34080. * @param cameras The camera to detatch from.
  34081. */
  34082. _detachCameras(cameras: Camera): void;
  34083. /**
  34084. * Detatches the effect on cameras
  34085. * @param cameras The camera to detatch from.
  34086. */
  34087. _detachCameras(cameras: Camera[]): void;
  34088. /**
  34089. * Enables the effect on given cameras
  34090. * @param cameras The camera to enable.
  34091. */
  34092. _enable(cameras: Camera): void;
  34093. /**
  34094. * Enables the effect on given cameras
  34095. * @param cameras The camera to enable.
  34096. */
  34097. _enable(cameras: Nullable<Camera[]>): void;
  34098. /**
  34099. * Disables the effect on the given cameras
  34100. * @param cameras The camera to disable.
  34101. */
  34102. _disable(cameras: Camera): void;
  34103. /**
  34104. * Disables the effect on the given cameras
  34105. * @param cameras The camera to disable.
  34106. */
  34107. _disable(cameras: Nullable<Camera[]>): void;
  34108. /**
  34109. * Gets a list of the post processes contained in the effect.
  34110. * @param camera The camera to get the post processes on.
  34111. * @returns The list of the post processes in the effect.
  34112. */
  34113. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  34114. }
  34115. }
  34116. declare module BABYLON {
  34117. class PostProcessRenderPipeline {
  34118. private engine;
  34119. private _renderEffects;
  34120. private _renderEffectsForIsolatedPass;
  34121. protected _cameras: Camera[];
  34122. _name: string;
  34123. constructor(engine: Engine, name: string);
  34124. getClassName(): string;
  34125. readonly isSupported: boolean;
  34126. addEffect(renderEffect: PostProcessRenderEffect): void;
  34127. _rebuild(): void;
  34128. _enableEffect(renderEffectName: string, cameras: Camera): void;
  34129. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  34130. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  34131. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  34132. _attachCameras(cameras: Camera, unique: boolean): void;
  34133. _attachCameras(cameras: Camera[], unique: boolean): void;
  34134. _detachCameras(cameras: Camera): void;
  34135. _detachCameras(cameras: Nullable<Camera[]>): void;
  34136. _update(): void;
  34137. _reset(): void;
  34138. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  34139. dispose(): void;
  34140. }
  34141. }
  34142. declare module BABYLON {
  34143. class PostProcessRenderPipelineManager {
  34144. private _renderPipelines;
  34145. constructor();
  34146. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  34147. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  34148. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  34149. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  34150. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  34151. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  34152. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  34153. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  34154. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  34155. update(): void;
  34156. _rebuild(): void;
  34157. dispose(): void;
  34158. }
  34159. }
  34160. declare module BABYLON {
  34161. /**
  34162. * Helper class dealing with the extraction of spherical polynomial dataArray
  34163. * from a cube map.
  34164. */
  34165. class CubeMapToSphericalPolynomialTools {
  34166. private static FileFaces;
  34167. /**
  34168. * Converts a texture to the according Spherical Polynomial data.
  34169. * This extracts the first 3 orders only as they are the only one used in the lighting.
  34170. *
  34171. * @param texture The texture to extract the information from.
  34172. * @return The Spherical Polynomial data.
  34173. */
  34174. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  34175. /**
  34176. * Converts a cubemap to the according Spherical Polynomial data.
  34177. * This extracts the first 3 orders only as they are the only one used in the lighting.
  34178. *
  34179. * @param cubeInfo The Cube map to extract the information from.
  34180. * @return The Spherical Polynomial data.
  34181. */
  34182. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  34183. }
  34184. }
  34185. declare module BABYLON {
  34186. /**
  34187. * Header information of HDR texture files.
  34188. */
  34189. interface HDRInfo {
  34190. /**
  34191. * The height of the texture in pixels.
  34192. */
  34193. height: number;
  34194. /**
  34195. * The width of the texture in pixels.
  34196. */
  34197. width: number;
  34198. /**
  34199. * The index of the beginning of the data in the binary file.
  34200. */
  34201. dataPosition: number;
  34202. }
  34203. /**
  34204. * This groups tools to convert HDR texture to native colors array.
  34205. */
  34206. class HDRTools {
  34207. private static Ldexp(mantissa, exponent);
  34208. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  34209. private static readStringLine(uint8array, startIndex);
  34210. /**
  34211. * Reads header information from an RGBE texture stored in a native array.
  34212. * More information on this format are available here:
  34213. * https://en.wikipedia.org/wiki/RGBE_image_format
  34214. *
  34215. * @param uint8array The binary file stored in native array.
  34216. * @return The header information.
  34217. */
  34218. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  34219. /**
  34220. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  34221. * This RGBE texture needs to store the information as a panorama.
  34222. *
  34223. * More information on this format are available here:
  34224. * https://en.wikipedia.org/wiki/RGBE_image_format
  34225. *
  34226. * @param buffer The binary file stored in an array buffer.
  34227. * @param size The expected size of the extracted cubemap.
  34228. * @return The Cube Map information.
  34229. */
  34230. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  34231. /**
  34232. * Returns the pixels data extracted from an RGBE texture.
  34233. * This pixels will be stored left to right up to down in the R G B order in one array.
  34234. *
  34235. * More information on this format are available here:
  34236. * https://en.wikipedia.org/wiki/RGBE_image_format
  34237. *
  34238. * @param uint8array The binary file stored in an array buffer.
  34239. * @param hdrInfo The header information of the file.
  34240. * @return The pixels data in RGB right to left up to down order.
  34241. */
  34242. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  34243. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  34244. }
  34245. }
  34246. declare module BABYLON {
  34247. /**
  34248. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  34249. */
  34250. interface CubeMapInfo {
  34251. /**
  34252. * The pixel array for the front face.
  34253. * This is stored in format, left to right, up to down format.
  34254. */
  34255. front: Nullable<ArrayBufferView>;
  34256. /**
  34257. * The pixel array for the back face.
  34258. * This is stored in format, left to right, up to down format.
  34259. */
  34260. back: Nullable<ArrayBufferView>;
  34261. /**
  34262. * The pixel array for the left face.
  34263. * This is stored in format, left to right, up to down format.
  34264. */
  34265. left: Nullable<ArrayBufferView>;
  34266. /**
  34267. * The pixel array for the right face.
  34268. * This is stored in format, left to right, up to down format.
  34269. */
  34270. right: Nullable<ArrayBufferView>;
  34271. /**
  34272. * The pixel array for the up face.
  34273. * This is stored in format, left to right, up to down format.
  34274. */
  34275. up: Nullable<ArrayBufferView>;
  34276. /**
  34277. * The pixel array for the down face.
  34278. * This is stored in format, left to right, up to down format.
  34279. */
  34280. down: Nullable<ArrayBufferView>;
  34281. /**
  34282. * The size of the cubemap stored.
  34283. *
  34284. * Each faces will be size * size pixels.
  34285. */
  34286. size: number;
  34287. /**
  34288. * The format of the texture.
  34289. *
  34290. * RGBA, RGB.
  34291. */
  34292. format: number;
  34293. /**
  34294. * The type of the texture data.
  34295. *
  34296. * UNSIGNED_INT, FLOAT.
  34297. */
  34298. type: number;
  34299. /**
  34300. * Specifies whether the texture is in gamma space.
  34301. */
  34302. gammaSpace: boolean;
  34303. }
  34304. /**
  34305. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  34306. */
  34307. class PanoramaToCubeMapTools {
  34308. private static FACE_FRONT;
  34309. private static FACE_BACK;
  34310. private static FACE_RIGHT;
  34311. private static FACE_LEFT;
  34312. private static FACE_DOWN;
  34313. private static FACE_UP;
  34314. /**
  34315. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  34316. *
  34317. * @param float32Array The source data.
  34318. * @param inputWidth The width of the input panorama.
  34319. * @param inputhHeight The height of the input panorama.
  34320. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  34321. * @return The cubemap data
  34322. */
  34323. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  34324. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  34325. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  34326. }
  34327. }
  34328. declare module BABYLON {
  34329. class CustomProceduralTexture extends ProceduralTexture {
  34330. private _animate;
  34331. private _time;
  34332. private _config;
  34333. private _texturePath;
  34334. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  34335. private loadJson(jsonUrl);
  34336. isReady(): boolean;
  34337. render(useCameraPostProcess?: boolean): void;
  34338. updateTextures(): void;
  34339. updateShaderUniforms(): void;
  34340. animate: boolean;
  34341. }
  34342. }
  34343. declare module BABYLON {
  34344. class ProceduralTexture extends Texture {
  34345. isCube: boolean;
  34346. private _size;
  34347. _generateMipMaps: boolean;
  34348. isEnabled: boolean;
  34349. private _currentRefreshId;
  34350. private _refreshRate;
  34351. onGenerated: () => void;
  34352. private _vertexBuffers;
  34353. private _indexBuffer;
  34354. private _effect;
  34355. private _uniforms;
  34356. private _samplers;
  34357. private _fragment;
  34358. _textures: {
  34359. [key: string]: Texture;
  34360. };
  34361. private _floats;
  34362. private _floatsArrays;
  34363. private _colors3;
  34364. private _colors4;
  34365. private _vectors2;
  34366. private _vectors3;
  34367. private _matrices;
  34368. private _fallbackTexture;
  34369. private _fallbackTextureUsed;
  34370. private _engine;
  34371. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  34372. private _createIndexBuffer();
  34373. _rebuild(): void;
  34374. reset(): void;
  34375. isReady(): boolean;
  34376. resetRefreshCounter(): void;
  34377. setFragment(fragment: any): void;
  34378. refreshRate: number;
  34379. _shouldRender(): boolean;
  34380. getRenderSize(): number;
  34381. resize(size: number, generateMipMaps: boolean): void;
  34382. private _checkUniform(uniformName);
  34383. setTexture(name: string, texture: Texture): ProceduralTexture;
  34384. setFloat(name: string, value: number): ProceduralTexture;
  34385. setFloats(name: string, value: number[]): ProceduralTexture;
  34386. setColor3(name: string, value: Color3): ProceduralTexture;
  34387. setColor4(name: string, value: Color4): ProceduralTexture;
  34388. setVector2(name: string, value: Vector2): ProceduralTexture;
  34389. setVector3(name: string, value: Vector3): ProceduralTexture;
  34390. setMatrix(name: string, value: Matrix): ProceduralTexture;
  34391. render(useCameraPostProcess?: boolean): void;
  34392. clone(): ProceduralTexture;
  34393. dispose(): void;
  34394. }
  34395. }
  34396. declare module BABYLON {
  34397. /**
  34398. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  34399. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  34400. */
  34401. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  34402. private _scene;
  34403. private _originalCameras;
  34404. /**
  34405. * ID of the sharpen post process,
  34406. */
  34407. private readonly SharpenPostProcessId;
  34408. /**
  34409. * ID of the image processing post process;
  34410. */
  34411. readonly ImageProcessingPostProcessId: string;
  34412. /**
  34413. * ID of the Fast Approximate Anti-Aliasing post process;
  34414. */
  34415. readonly FxaaPostProcessId: string;
  34416. /**
  34417. * ID of the chromatic aberration post process,
  34418. */
  34419. private readonly ChromaticAberrationPostProcessId;
  34420. /**
  34421. * ID of the grain post process
  34422. */
  34423. private readonly GrainPostProcessId;
  34424. /**
  34425. * Sharpen post process which will apply a sharpen convolution to enhance edges
  34426. */
  34427. sharpen: SharpenPostProcess;
  34428. private _sharpenEffect;
  34429. private bloom;
  34430. /**
  34431. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  34432. */
  34433. depthOfField: DepthOfFieldEffect;
  34434. /**
  34435. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  34436. */
  34437. fxaa: FxaaPostProcess;
  34438. /**
  34439. * Image post processing pass used to perform operations such as tone mapping or color grading.
  34440. */
  34441. imageProcessing: ImageProcessingPostProcess;
  34442. /**
  34443. * Chromatic aberration post process which will shift rgb colors in the image
  34444. */
  34445. chromaticAberration: ChromaticAberrationPostProcess;
  34446. private _chromaticAberrationEffect;
  34447. /**
  34448. * Grain post process which add noise to the image
  34449. */
  34450. grain: GrainPostProcess;
  34451. private _grainEffect;
  34452. /**
  34453. * Animations which can be used to tweak settings over a period of time
  34454. */
  34455. animations: Animation[];
  34456. private _imageProcessingConfigurationObserver;
  34457. private _sharpenEnabled;
  34458. private _bloomEnabled;
  34459. private _depthOfFieldEnabled;
  34460. private _depthOfFieldBlurLevel;
  34461. private _fxaaEnabled;
  34462. private _imageProcessingEnabled;
  34463. private _defaultPipelineTextureType;
  34464. private _bloomScale;
  34465. private _chromaticAberrationEnabled;
  34466. private _grainEnabled;
  34467. private _buildAllowed;
  34468. /**
  34469. * Enable or disable the sharpen process from the pipeline
  34470. */
  34471. sharpenEnabled: boolean;
  34472. private _resizeObserver;
  34473. private _hardwareScaleLevel;
  34474. private _bloomKernel;
  34475. /**
  34476. * Specifies the size of the bloom blur kernel, relative to the final output size
  34477. */
  34478. bloomKernel: number;
  34479. /**
  34480. * Specifies the weight of the bloom in the final rendering
  34481. */
  34482. private _bloomWeight;
  34483. /**
  34484. * Specifies the luma threshold for the area that will be blurred by the bloom
  34485. */
  34486. private _bloomThreshold;
  34487. private _hdr;
  34488. /**
  34489. * The strength of the bloom.
  34490. */
  34491. bloomWeight: number;
  34492. /**
  34493. * The strength of the bloom.
  34494. */
  34495. bloomThreshold: number;
  34496. /**
  34497. * The scale of the bloom, lower value will provide better performance.
  34498. */
  34499. bloomScale: number;
  34500. /**
  34501. * Enable or disable the bloom from the pipeline
  34502. */
  34503. bloomEnabled: boolean;
  34504. private _rebuildBloom();
  34505. /**
  34506. * If the depth of field is enabled.
  34507. */
  34508. depthOfFieldEnabled: boolean;
  34509. /**
  34510. * Blur level of the depth of field effect. (Higher blur will effect performance)
  34511. */
  34512. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  34513. /**
  34514. * If the anti aliasing is enabled.
  34515. */
  34516. fxaaEnabled: boolean;
  34517. private _samples;
  34518. /**
  34519. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  34520. */
  34521. samples: number;
  34522. /**
  34523. * If image processing is enabled.
  34524. */
  34525. imageProcessingEnabled: boolean;
  34526. /**
  34527. * Enable or disable the chromaticAberration process from the pipeline
  34528. */
  34529. chromaticAberrationEnabled: boolean;
  34530. /**
  34531. * Enable or disable the grain process from the pipeline
  34532. */
  34533. grainEnabled: boolean;
  34534. /**
  34535. * @constructor
  34536. * @param {string} name - The rendering pipeline name
  34537. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34538. * @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)
  34539. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34540. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline
  34541. */
  34542. constructor(name: string, hdr: boolean, scene: Scene, cameras?: Camera[], automaticBuild?: boolean);
  34543. /**
  34544. * Force the compilation of the entire pipeline.
  34545. */
  34546. prepare(): void;
  34547. private _hasCleared;
  34548. private _prevPostProcess;
  34549. private _prevPrevPostProcess;
  34550. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  34551. private _buildPipeline();
  34552. private _disposePostProcesses(disposeNonRecreated?);
  34553. /**
  34554. * Dispose of the pipeline and stop all post processes
  34555. */
  34556. dispose(): void;
  34557. /**
  34558. * Serialize the rendering pipeline (Used when exporting)
  34559. * @returns the serialized object
  34560. */
  34561. serialize(): any;
  34562. /**
  34563. * Parse the serialized pipeline
  34564. * @param source Source pipeline.
  34565. * @param scene The scene to load the pipeline to.
  34566. * @param rootUrl The URL of the serialized pipeline.
  34567. * @returns An instantiated pipeline from the serialized object.
  34568. */
  34569. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  34570. }
  34571. }
  34572. declare module BABYLON {
  34573. class LensRenderingPipeline extends PostProcessRenderPipeline {
  34574. /**
  34575. * The chromatic aberration PostProcess id in the pipeline
  34576. */
  34577. LensChromaticAberrationEffect: string;
  34578. /**
  34579. * The highlights enhancing PostProcess id in the pipeline
  34580. */
  34581. HighlightsEnhancingEffect: string;
  34582. /**
  34583. * The depth-of-field PostProcess id in the pipeline
  34584. */
  34585. LensDepthOfFieldEffect: string;
  34586. private _scene;
  34587. private _depthTexture;
  34588. private _grainTexture;
  34589. private _chromaticAberrationPostProcess;
  34590. private _highlightsPostProcess;
  34591. private _depthOfFieldPostProcess;
  34592. private _edgeBlur;
  34593. private _grainAmount;
  34594. private _chromaticAberration;
  34595. private _distortion;
  34596. private _highlightsGain;
  34597. private _highlightsThreshold;
  34598. private _dofDistance;
  34599. private _dofAperture;
  34600. private _dofDarken;
  34601. private _dofPentagon;
  34602. private _blurNoise;
  34603. /**
  34604. * @constructor
  34605. *
  34606. * Effect parameters are as follow:
  34607. * {
  34608. * chromatic_aberration: number; // from 0 to x (1 for realism)
  34609. * edge_blur: number; // from 0 to x (1 for realism)
  34610. * distortion: number; // from 0 to x (1 for realism)
  34611. * grain_amount: number; // from 0 to 1
  34612. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  34613. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  34614. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  34615. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  34616. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  34617. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  34618. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  34619. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  34620. * }
  34621. * Note: if an effect parameter is unset, effect is disabled
  34622. *
  34623. * @param {string} name - The rendering pipeline name
  34624. * @param {object} parameters - An object containing all parameters (see above)
  34625. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34626. * @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)
  34627. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34628. */
  34629. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  34630. setEdgeBlur(amount: number): void;
  34631. disableEdgeBlur(): void;
  34632. setGrainAmount(amount: number): void;
  34633. disableGrain(): void;
  34634. setChromaticAberration(amount: number): void;
  34635. disableChromaticAberration(): void;
  34636. setEdgeDistortion(amount: number): void;
  34637. disableEdgeDistortion(): void;
  34638. setFocusDistance(amount: number): void;
  34639. disableDepthOfField(): void;
  34640. setAperture(amount: number): void;
  34641. setDarkenOutOfFocus(amount: number): void;
  34642. enablePentagonBokeh(): void;
  34643. disablePentagonBokeh(): void;
  34644. enableNoiseBlur(): void;
  34645. disableNoiseBlur(): void;
  34646. setHighlightsGain(amount: number): void;
  34647. setHighlightsThreshold(amount: number): void;
  34648. disableHighlights(): void;
  34649. /**
  34650. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  34651. */
  34652. dispose(disableDepthRender?: boolean): void;
  34653. private _createChromaticAberrationPostProcess(ratio);
  34654. private _createHighlightsPostProcess(ratio);
  34655. private _createDepthOfFieldPostProcess(ratio);
  34656. private _createGrainTexture();
  34657. }
  34658. }
  34659. declare module BABYLON {
  34660. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  34661. /**
  34662. * The PassPostProcess id in the pipeline that contains the original scene color
  34663. */
  34664. SSAOOriginalSceneColorEffect: string;
  34665. /**
  34666. * The SSAO PostProcess id in the pipeline
  34667. */
  34668. SSAORenderEffect: string;
  34669. /**
  34670. * The horizontal blur PostProcess id in the pipeline
  34671. */
  34672. SSAOBlurHRenderEffect: string;
  34673. /**
  34674. * The vertical blur PostProcess id in the pipeline
  34675. */
  34676. SSAOBlurVRenderEffect: string;
  34677. /**
  34678. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  34679. */
  34680. SSAOCombineRenderEffect: string;
  34681. /**
  34682. * The output strength of the SSAO post-process. Default value is 1.0.
  34683. */
  34684. totalStrength: number;
  34685. /**
  34686. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  34687. */
  34688. maxZ: number;
  34689. /**
  34690. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  34691. */
  34692. minZAspect: number;
  34693. /**
  34694. * Number of samples used for the SSAO calculations. Default value is 8
  34695. */
  34696. private _samples;
  34697. /**
  34698. * Ratio object used for SSAO ratio and blur ratio
  34699. */
  34700. private _ratio;
  34701. /**
  34702. * Dynamically generated sphere sampler.
  34703. */
  34704. private _sampleSphere;
  34705. /**
  34706. * Blur filter offsets
  34707. */
  34708. private _samplerOffsets;
  34709. samples: number;
  34710. /**
  34711. * Are we using bilateral blur ?
  34712. */
  34713. private _expensiveBlur;
  34714. expensiveBlur: boolean;
  34715. /**
  34716. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  34717. */
  34718. radius: number;
  34719. /**
  34720. * The base color of the SSAO post-process
  34721. * The final result is "base + ssao" between [0, 1]
  34722. */
  34723. base: number;
  34724. /**
  34725. * Support test.
  34726. */
  34727. static readonly IsSupported: boolean;
  34728. private _scene;
  34729. private _depthTexture;
  34730. private _normalTexture;
  34731. private _randomTexture;
  34732. private _originalColorPostProcess;
  34733. private _ssaoPostProcess;
  34734. private _blurHPostProcess;
  34735. private _blurVPostProcess;
  34736. private _ssaoCombinePostProcess;
  34737. private _firstUpdate;
  34738. /**
  34739. * @constructor
  34740. * @param {string} name - The rendering pipeline name
  34741. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34742. * @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 }
  34743. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34744. */
  34745. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  34746. /**
  34747. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  34748. */
  34749. dispose(disableGeometryBufferRenderer?: boolean): void;
  34750. private _createBlurPostProcess(ssaoRatio, blurRatio);
  34751. _rebuild(): void;
  34752. private _generateHemisphere();
  34753. private _createSSAOPostProcess(ratio);
  34754. private _createSSAOCombinePostProcess(ratio);
  34755. private _createRandomTexture();
  34756. /**
  34757. * Serialize the rendering pipeline (Used when exporting)
  34758. * @returns the serialized object
  34759. */
  34760. serialize(): any;
  34761. /**
  34762. * Parse the serialized pipeline
  34763. * @param source Source pipeline.
  34764. * @param scene The scene to load the pipeline to.
  34765. * @param rootUrl The URL of the serialized pipeline.
  34766. * @returns An instantiated pipeline from the serialized object.
  34767. */
  34768. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  34769. }
  34770. }
  34771. declare module BABYLON {
  34772. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  34773. /**
  34774. * The PassPostProcess id in the pipeline that contains the original scene color
  34775. */
  34776. SSAOOriginalSceneColorEffect: string;
  34777. /**
  34778. * The SSAO PostProcess id in the pipeline
  34779. */
  34780. SSAORenderEffect: string;
  34781. /**
  34782. * The horizontal blur PostProcess id in the pipeline
  34783. */
  34784. SSAOBlurHRenderEffect: string;
  34785. /**
  34786. * The vertical blur PostProcess id in the pipeline
  34787. */
  34788. SSAOBlurVRenderEffect: string;
  34789. /**
  34790. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  34791. */
  34792. SSAOCombineRenderEffect: string;
  34793. /**
  34794. * The output strength of the SSAO post-process. Default value is 1.0.
  34795. */
  34796. totalStrength: number;
  34797. /**
  34798. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  34799. */
  34800. radius: number;
  34801. /**
  34802. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  34803. * Must not be equal to fallOff and superior to fallOff.
  34804. * Default value is 0.975
  34805. */
  34806. area: number;
  34807. /**
  34808. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  34809. * Must not be equal to area and inferior to area.
  34810. * Default value is 0.0
  34811. */
  34812. fallOff: number;
  34813. /**
  34814. * The base color of the SSAO post-process
  34815. * The final result is "base + ssao" between [0, 1]
  34816. */
  34817. base: number;
  34818. private _scene;
  34819. private _depthTexture;
  34820. private _randomTexture;
  34821. private _originalColorPostProcess;
  34822. private _ssaoPostProcess;
  34823. private _blurHPostProcess;
  34824. private _blurVPostProcess;
  34825. private _ssaoCombinePostProcess;
  34826. private _firstUpdate;
  34827. /**
  34828. * @constructor
  34829. * @param {string} name - The rendering pipeline name
  34830. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34831. * @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 }
  34832. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34833. */
  34834. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  34835. /**
  34836. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  34837. */
  34838. dispose(disableDepthRender?: boolean): void;
  34839. private _createBlurPostProcess(ratio);
  34840. _rebuild(): void;
  34841. private _createSSAOPostProcess(ratio);
  34842. private _createSSAOCombinePostProcess(ratio);
  34843. private _createRandomTexture();
  34844. }
  34845. }
  34846. declare module BABYLON {
  34847. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  34848. /**
  34849. * Public members
  34850. */
  34851. originalPostProcess: Nullable<PostProcess>;
  34852. downSampleX4PostProcess: Nullable<PostProcess>;
  34853. brightPassPostProcess: Nullable<PostProcess>;
  34854. blurHPostProcesses: PostProcess[];
  34855. blurVPostProcesses: PostProcess[];
  34856. textureAdderPostProcess: Nullable<PostProcess>;
  34857. volumetricLightPostProcess: Nullable<PostProcess>;
  34858. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  34859. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  34860. volumetricLightMergePostProces: Nullable<PostProcess>;
  34861. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  34862. luminancePostProcess: Nullable<PostProcess>;
  34863. luminanceDownSamplePostProcesses: PostProcess[];
  34864. hdrPostProcess: Nullable<PostProcess>;
  34865. textureAdderFinalPostProcess: Nullable<PostProcess>;
  34866. lensFlareFinalPostProcess: Nullable<PostProcess>;
  34867. hdrFinalPostProcess: Nullable<PostProcess>;
  34868. lensFlarePostProcess: Nullable<PostProcess>;
  34869. lensFlareComposePostProcess: Nullable<PostProcess>;
  34870. motionBlurPostProcess: Nullable<PostProcess>;
  34871. depthOfFieldPostProcess: Nullable<PostProcess>;
  34872. brightThreshold: number;
  34873. blurWidth: number;
  34874. horizontalBlur: boolean;
  34875. exposure: number;
  34876. lensTexture: Nullable<Texture>;
  34877. volumetricLightCoefficient: number;
  34878. volumetricLightPower: number;
  34879. volumetricLightBlurScale: number;
  34880. sourceLight: Nullable<SpotLight | DirectionalLight>;
  34881. hdrMinimumLuminance: number;
  34882. hdrDecreaseRate: number;
  34883. hdrIncreaseRate: number;
  34884. lensColorTexture: Nullable<Texture>;
  34885. lensFlareStrength: number;
  34886. lensFlareGhostDispersal: number;
  34887. lensFlareHaloWidth: number;
  34888. lensFlareDistortionStrength: number;
  34889. lensStarTexture: Nullable<Texture>;
  34890. lensFlareDirtTexture: Nullable<Texture>;
  34891. depthOfFieldDistance: number;
  34892. depthOfFieldBlurWidth: number;
  34893. motionStrength: number;
  34894. animations: Animation[];
  34895. /**
  34896. * Private members
  34897. */
  34898. private _scene;
  34899. private _currentDepthOfFieldSource;
  34900. private _basePostProcess;
  34901. private _hdrCurrentLuminance;
  34902. private _floatTextureType;
  34903. private _ratio;
  34904. private _bloomEnabled;
  34905. private _depthOfFieldEnabled;
  34906. private _vlsEnabled;
  34907. private _lensFlareEnabled;
  34908. private _hdrEnabled;
  34909. private _motionBlurEnabled;
  34910. private _motionBlurSamples;
  34911. private _volumetricLightStepsCount;
  34912. BloomEnabled: boolean;
  34913. DepthOfFieldEnabled: boolean;
  34914. LensFlareEnabled: boolean;
  34915. HDREnabled: boolean;
  34916. VLSEnabled: boolean;
  34917. MotionBlurEnabled: boolean;
  34918. volumetricLightStepsCount: number;
  34919. motionBlurSamples: number;
  34920. /**
  34921. * @constructor
  34922. * @param {string} name - The rendering pipeline name
  34923. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  34924. * @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)
  34925. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  34926. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  34927. */
  34928. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  34929. private _buildPipeline();
  34930. private _createDownSampleX4PostProcess(scene, ratio);
  34931. private _createBrightPassPostProcess(scene, ratio);
  34932. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  34933. private _createTextureAdderPostProcess(scene, ratio);
  34934. private _createVolumetricLightPostProcess(scene, ratio);
  34935. private _createLuminancePostProcesses(scene, textureType);
  34936. private _createHdrPostProcess(scene, ratio);
  34937. private _createLensFlarePostProcess(scene, ratio);
  34938. private _createDepthOfFieldPostProcess(scene, ratio);
  34939. private _createMotionBlurPostProcess(scene, ratio);
  34940. private _getDepthTexture();
  34941. private _disposePostProcesses();
  34942. /**
  34943. * Dispose of the pipeline and stop all post processes
  34944. */
  34945. dispose(): void;
  34946. /**
  34947. * Serialize the rendering pipeline (Used when exporting)
  34948. * @returns the serialized object
  34949. */
  34950. serialize(): any;
  34951. /**
  34952. * Parse the serialized pipeline
  34953. * @param source Source pipeline.
  34954. * @param scene The scene to load the pipeline to.
  34955. * @param rootUrl The URL of the serialized pipeline.
  34956. * @returns An instantiated pipeline from the serialized object.
  34957. */
  34958. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  34959. static LuminanceSteps: number;
  34960. }
  34961. }